MaxCommon.pm 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package MaxCommon;
  2. require Exporter;
  3. @ISA = qw(Exporter);
  4. @EXPORT = qw(%device_types %msgId2Cmd %msgCmd2Id $defaultWeekProfile MAX_ParseTemperature validTemperature);
  5. %device_types = (
  6. 0 => "Cube",
  7. 1 => "HeatingThermostat",
  8. 2 => "HeatingThermostatPlus",
  9. 3 => "WallMountedThermostat",
  10. 4 => "ShutterContact",
  11. 5 => "PushButton"
  12. );
  13. %msgId2Cmd = (
  14. "00" => "PairPing",
  15. "01" => "PairPong",
  16. "02" => "Ack",
  17. "03" => "TimeInformation",
  18. "10" => "ConfigWeekProfile",
  19. "11" => "ConfigTemperatures", #like eco/comfort etc
  20. "12" => "ConfigValve",
  21. "20" => "AddLinkPartner",
  22. "21" => "RemoveLinkPartner",
  23. "22" => "SetGroupId",
  24. "23" => "RemoveGroupId",
  25. "30" => "ShutterContactState",
  26. "40" => "SetTemperature", #to thermostat
  27. "42" => "WallThermostatControl", #by WallMountedThermostat
  28. #Sending this without payload to thermostat sets desiredTempeerature to the comfort/eco temperature
  29. #We don't use it, we just do SetTemperature
  30. "43" => "SetComfortTemperature",
  31. "44" => "SetEcoTemperature",
  32. "50" => "PushButtonState",
  33. "60" => "ThermostatState", #by HeatingThermostat
  34. "70" => "WallThermostatState",
  35. "82" => "SetDisplayActualTemperature",
  36. "F1" => "WakeUp",
  37. "F0" => "Reset",
  38. );
  39. %msgCmd2Id = reverse %msgId2Cmd;
  40. $defaultWeekProfile = "444855084520452045204520452045204520452045204520452044485508452045204520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc5514452045204520452045204520452045204520";
  41. sub validTemperature { return $_[0] eq "on" || $_[0] eq "off" || ($_[0] =~ /^\d+(\.[05])?$/ && $_[0] >= 5 && $_[0] <= 30); }
  42. #Identify for numeric values and maps "on" and "off" to their temperatures
  43. sub
  44. MAX_ParseTemperature($)
  45. {
  46. return $_[0] eq "on" ? 30.5 : ($_[0] eq "off" ? 4.5 :$_[0]);
  47. }
  48. 1;