1 #pragma once 2 3 #define SensorZLLSwitchEventInitialPress 0 4 #define SensorZLLSwitchEventRepeat 1 5 #define SensorZLLSwitchEventShortRelease 2 6 #define SensorZLLSwitchEventLongRelease 3 7 #define SensorZLLSwitchEventSimple 5 8 9 #define EVENT_INITIAL_PRESS "initial_press" 10 #define EVENT_REPEAT "repeat" 11 #define EVENT_SHORT_RELEASE "short_release" 12 #define EVENT_LONG_RELEASE "long_release" 13 14 namespace Json 15 { 16 class Value; 17 }; 18 19 class CPHSensorState 20 { 21 public: CPHSensorState()22 CPHSensorState() {}; 23 CPHSensorState(const Json::Value& state, const Json::Value& capabilities); 24 25 bool operator==(const CPHSensorState& other); 26 27 void ExtractButtonInfo(const Json::Value& state, const Json::Value& capabilities); 28 int32_t GetSelectorLevel(const CPHSensorState& previous_state); 29 std::map<std::string, std::string> GetButtonOptions(); 30 31 std::string m_lastupdated; 32 int m_buttonevent = 0; 33 bool m_presence = false; 34 int m_temperature = 0; 35 int m_lightlevel = 0; 36 bool m_dark = false; 37 bool m_daylight = false; 38 bool m_button_valid = false; 39 int m_button_count = 0; 40 bool m_button_can_long_press = false; 41 int m_button_nr = 0; 42 int m_button_eventtype = SensorZLLSwitchEventSimple; 43 44 }; 45 46 class CPHSensorConfig 47 { 48 public: CPHSensorConfig()49 CPHSensorConfig() {}; 50 CPHSensorConfig(const Json::Value& config); 51 52 bool m_on = false; 53 bool m_reachable = false; 54 int m_battery = 255; 55 int m_tholddark = 0; 56 int m_tholdoffset = 0; 57 int m_sunriseoffset = 0; 58 int m_sunsetoffset = 0; 59 bool m_configured = false; 60 }; 61 62 63 class CPHSensor 64 { 65 public: CPHSensor()66 CPHSensor() {}; 67 CPHSensor(const Json::Value& sensor); 68 69 std::string m_name; 70 std::string m_type; 71 std::string m_model_id; 72 std::string m_manufacturer_name; 73 std::string m_sw_version; 74 std::string m_uniqueid; 75 CPHSensorState m_state; 76 CPHSensorConfig m_config; 77 }; 78