forked from u236/homed-service-zigbee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty.cpp
141 lines (127 loc) · 10.4 KB
/
property.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "properties/byun.h"
#include "properties/common.h"
#include "properties/efekta.h"
#include "properties/hue.h"
#include "properties/ias.h"
#include "properties/ikea.h"
#include "properties/lumi.h"
#include "properties/modkam.h"
#include "properties/other.h"
#include "properties/ptvo.h"
#include "properties/tuya.h"
void PropertyObject::registerMetaTypes(void)
{
qRegisterMetaType <Properties::BatteryVoltage> ("batteryVoltageProperty");
qRegisterMetaType <Properties::BatteryPercentage> ("batteryPercentageProperty");
qRegisterMetaType <Properties::DeviceTemperature> ("deviceTemperatureProperty");
qRegisterMetaType <Properties::Status> ("statusProperty");
qRegisterMetaType <Properties::PowerOnStatus> ("powerOnStatusProperty");
qRegisterMetaType <Properties::SwitchType> ("switchTypeProperty");
qRegisterMetaType <Properties::SwitchMode> ("switchModeProperty");
qRegisterMetaType <Properties::Level> ("levelProperty");
qRegisterMetaType <Properties::AnalogInput> ("analogInputProperty");
qRegisterMetaType <Properties::AnalogOutput> ("analogOutputProperty");
qRegisterMetaType <Properties::CoverPosition> ("coverPositionProperty");
qRegisterMetaType <Properties::CoverTilt> ("coverTiltProperty");
qRegisterMetaType <Properties::Thermostat> ("thermostatProperty");
qRegisterMetaType <Properties::DisplayMode> ("displayModeProperty");
qRegisterMetaType <Properties::ColorHS> ("colorHSProperty");
qRegisterMetaType <Properties::ColorXY> ("colorXYProperty");
qRegisterMetaType <Properties::ColorTemperature> ("colorTemperatureProperty");
qRegisterMetaType <Properties::Illuminance> ("illuminanceProperty");
qRegisterMetaType <Properties::Temperature> ("temperatureProperty");
qRegisterMetaType <Properties::Pressure> ("pressureProperty");
qRegisterMetaType <Properties::Humidity> ("humidityProperty");
qRegisterMetaType <Properties::Occupancy> ("occupancyProperty");
qRegisterMetaType <Properties::OccupancyTimeout> ("occupancyTimeoutProperty");
qRegisterMetaType <Properties::Moisture> ("moistureProperty");
qRegisterMetaType <Properties::CO2> ("co2Property");
qRegisterMetaType <Properties::PM25> ("pm25Property");
qRegisterMetaType <Properties::Energy> ("energyProperty");
qRegisterMetaType <Properties::Voltage> ("voltageProperty");
qRegisterMetaType <Properties::Current> ("currentProperty");
qRegisterMetaType <Properties::Power> ("powerProperty");
qRegisterMetaType <Properties::Scene> ("sceneProperty");
qRegisterMetaType <Properties::StatusAction> ("statusActionProperty");
qRegisterMetaType <Properties::LevelAction> ("levelActionProperty");
qRegisterMetaType <Properties::CoverAction> ("coverActionProperty");
qRegisterMetaType <Properties::ColorAction> ("colorActionProperty");
qRegisterMetaType <PropertiesIAS::Contact> ("iasContactProperty");
qRegisterMetaType <PropertiesIAS::Gas> ("iasGasProperty");
qRegisterMetaType <PropertiesIAS::Occupancy> ("iasOccupancyProperty");
qRegisterMetaType <PropertiesIAS::Smoke> ("iasSmokeProperty");
qRegisterMetaType <PropertiesIAS::WaterLeak> ("iasWaterLeakProperty");
qRegisterMetaType <PropertiesByun::GasSensor> ("byunGasSensorProperty");
qRegisterMetaType <PropertiesByun::SmokeSensor> ("byunSmokeSensorProperty");
qRegisterMetaType <PropertiesHUE::IndicatorMode> ("hueIndicatorModeProperty");
qRegisterMetaType <PropertiesHUE::SensivivityMode> ("hueSensivivityModeProperty");
qRegisterMetaType <PropertiesIKEA::Occupancy> ("ikeaOccupancyProperty");
qRegisterMetaType <PropertiesIKEA::StatusAction> ("ikeaStatusActionProperty");
qRegisterMetaType <PropertiesIKEA::ArrowAction> ("ikeaArrowActionProperty");
qRegisterMetaType <PropertiesLUMI::Data> ("lumiDataProperty");
qRegisterMetaType <PropertiesLUMI::Basic> ("lumiBasicProperty");
qRegisterMetaType <PropertiesLUMI::ButtonMode> ("lumiButtonModeProperty");
qRegisterMetaType <PropertiesLUMI::Contact> ("lumiContactProperty");
qRegisterMetaType <PropertiesLUMI::Interlock> ("lumiInterlockProperty");
qRegisterMetaType <PropertiesLUMI::Power> ("lumiPowerProperty");
qRegisterMetaType <PropertiesLUMI::Cover> ("lumiCoverProperty");
qRegisterMetaType <PropertiesLUMI::Illuminance> ("lumiIlluminanceProperty");
qRegisterMetaType <PropertiesLUMI::ButtonAction> ("lumiButtonActionProperty");
qRegisterMetaType <PropertiesLUMI::SwitchAction> ("lumiSwitchActionProperty");
qRegisterMetaType <PropertiesLUMI::CubeRotation> ("lumiCubeRotationProperty");
qRegisterMetaType <PropertiesLUMI::CubeMovement> ("lumiCubeMovementProperty");
qRegisterMetaType <PropertiesLUMI::Vibration> ("lumiVibrationProperty");
qRegisterMetaType <PropertiesTUYA::DataPoints> ("tuyaDataPointsProperty");
qRegisterMetaType <PropertiesTUYA::WeekdayThermostatProgram> ("tuyaWeekdayThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::HolidayThermostatProgram> ("tuyaHolidayThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::MoesThermostatProgram> ("tuyaMoesThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::CoverMotor> ("tuyaCoverMotorProperty");
qRegisterMetaType <PropertiesTUYA::CoverSwitch> ("tuyaCoverSwitchProperty");
qRegisterMetaType <PropertiesTUYA::ChildLock> ("tuyaChildLockProperty");
qRegisterMetaType <PropertiesTUYA::OperationMode> ("tuyaOperationModeProperty");
qRegisterMetaType <PropertiesTUYA::IndicatorMode> ("tuyaIndicatorModeProperty");
qRegisterMetaType <PropertiesTUYA::SensitivityMode> ("tuyaSensitivityModeProperty");
qRegisterMetaType <PropertiesTUYA::TimeoutMode> ("tuyaTimeoutModeProperty");
qRegisterMetaType <PropertiesTUYA::SwitchType> ("tuyaSwitchTypeProperty");
qRegisterMetaType <PropertiesTUYA::PowerOnStatus> ("tuyaPowerOnStatusProperty");
qRegisterMetaType <PropertiesTUYA::ButtonAction> ("tuyaButtonActionProperty");
qRegisterMetaType <PropertiesEfekta::ReportingDelay> ("efektaReportingDelayProperty");
qRegisterMetaType <PropertiesEfekta::TemperatureSettings> ("efektaTemperatureSettingsProperty");
qRegisterMetaType <PropertiesEfekta::HumiditySettings> ("efektaHumiditySettingsProperty");
qRegisterMetaType <PropertiesEfekta::CO2Settings> ("efektaCO2SettingsProperty");
qRegisterMetaType <PropertiesEfekta::PMSensor> ("efektaPMSensorProperty");
qRegisterMetaType <PropertiesEfekta::VOCSensor> ("efektaVOCSensorProperty");
qRegisterMetaType <PropertiesModkam::ButtonAction> ("modkamButtonActionProperty");
qRegisterMetaType <PropertiesModkam::TemperatureOffset> ("modkamTemperatureOffsetProperty");
qRegisterMetaType <PropertiesModkam::HumidityOffset> ("modkamHumidityOffsetProperty");
qRegisterMetaType <PropertiesModkam::PressureOffset> ("modkamPressureOffsetProperty");
qRegisterMetaType <PropertiesModkam::CO2Settings> ("modkamCO2SettingsProperty");
qRegisterMetaType <PropertiesModkam::Geiger> ("modkamGeigerProperty");
qRegisterMetaType <PropertiesPTVO::ChangePattern> ("ptvoChangePatternProperty");
qRegisterMetaType <PropertiesPTVO::Contact> ("ptvoContactProperty");
qRegisterMetaType <PropertiesPTVO::Occupancy> ("ptvoOccupancyProperty");
qRegisterMetaType <PropertiesPTVO::WaterLeak> ("ptvoWaterLeakProperty");
qRegisterMetaType <PropertiesPTVO::CO2> ("ptvoCO2Property");
qRegisterMetaType <PropertiesPTVO::Temperature> ("ptvoTemperatureProperty");
qRegisterMetaType <PropertiesPTVO::Humidity> ("ptvoHumidityProperty");
qRegisterMetaType <PropertiesPTVO::Count> ("ptvoCountProperty");
qRegisterMetaType <PropertiesPTVO::Pattern> ("ptvoPatternProperty");
qRegisterMetaType <PropertiesPTVO::ButtonAction> ("ptvoButtonActionProperty");
qRegisterMetaType <PropertiesPTVO::SwitchAction> ("ptvoSwitchActionProperty");
qRegisterMetaType <PropertiesPTVO::SerialData> ("ptvoSerialDataProperty");
qRegisterMetaType <PropertiesOther::KonkeButtonAction> ("konkeButtonActionProperty");
qRegisterMetaType <PropertiesOther::SonoffButtonAction> ("sonoffButtonActionProperty");
qRegisterMetaType <PropertiesOther::LifeControlAirQuality> ("lifeControlAirQualityProperty");
qRegisterMetaType <PropertiesOther::PerenioSmartPlug> ("perenioSmartPlugProperty");
qRegisterMetaType <PropertiesOther::WoolleySmartPlug> ("woolleySmartPlugProperty");
qRegisterMetaType <PropertiesOther::WaterMeterVolume> ("waterMeterVolumeProperty");
qRegisterMetaType <PropertiesOther::WaterMeterSettings> ("waterMeterSettingsProperty");
}
quint8 PropertyObject::percentage(double min, double max, double value)
{
if (value < min)
value = min;
if (value > max)
value = max;
return static_cast <quint8> ((value - min) / (max - min) * 100);
}