-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
property.cpp
143 lines (128 loc) · 9.7 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
142
143
#include "properties/common.h"
#include "properties/efekta.h"
#include "properties/ias.h"
#include "properties/lumi.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::Level> ("levelProperty");
qRegisterMetaType <Properties::AnalogInput> ("analogInputProperty");
qRegisterMetaType <Properties::AnalogOutput> ("analogOutputProperty");
qRegisterMetaType <Properties::CoverPosition> ("coverPositionProperty");
qRegisterMetaType <Properties::CoverTilt> ("coverTiltProperty");
qRegisterMetaType <Properties::Thermostat> ("thermostatProperty");
qRegisterMetaType <Properties::ColorHS> ("colorHSProperty");
qRegisterMetaType <Properties::ColorXY> ("colorXYProperty");
qRegisterMetaType <Properties::ColorTemperature> ("colorTemperatureProperty");
qRegisterMetaType <Properties::ColorMode> ("colorModeProperty");
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::ChildLock> ("childLockProperty");
qRegisterMetaType <Properties::Scene> ("sceneProperty");
qRegisterMetaType <Properties::StatusAction> ("statusActionProperty");
qRegisterMetaType <Properties::LevelAction> ("levelActionProperty");
qRegisterMetaType <Properties::CoverAction> ("coverActionProperty");
qRegisterMetaType <Properties::ColorAction> ("colorActionProperty");
qRegisterMetaType <Properties::PowerOnStatus> ("powerOnStatusProperty");
qRegisterMetaType <Properties::SwitchType> ("switchTypeProperty");
qRegisterMetaType <Properties::SwitchMode> ("switchModeProperty");
qRegisterMetaType <Properties::FanMode> ("fanModeProperty");
qRegisterMetaType <Properties::DisplayMode> ("displayModeProperty");
qRegisterMetaType <PropertiesIAS::Warning> ("iasWarningProperty");
qRegisterMetaType <PropertiesIAS::Contact> ("iasContactProperty");
qRegisterMetaType <PropertiesIAS::Gas> ("iasGasProperty");
qRegisterMetaType <PropertiesIAS::Occupancy> ("iasOccupancyProperty");
qRegisterMetaType <PropertiesIAS::Smoke> ("iasSmokeProperty");
qRegisterMetaType <PropertiesIAS::WaterLeak> ("iasWaterLeakProperty");
qRegisterMetaType <PropertiesIAS::Rain> ("iasRainProperty");
qRegisterMetaType <PropertiesIAS::ContolAction> ("iasContolActionProperty");
qRegisterMetaType <PropertiesLUMI::Data> ("lumiDataProperty");
qRegisterMetaType <PropertiesLUMI::Basic> ("lumiBasicProperty");
qRegisterMetaType <PropertiesLUMI::ButtonMode> ("lumiButtonModeProperty");
qRegisterMetaType <PropertiesLUMI::Contact> ("lumiContactProperty");
qRegisterMetaType <PropertiesLUMI::Power> ("lumiPowerProperty");
qRegisterMetaType <PropertiesLUMI::Cover> ("lumiCoverProperty");
qRegisterMetaType <PropertiesLUMI::ButtonAction> ("lumiButtonActionProperty");
qRegisterMetaType <PropertiesLUMI::SwitchAction> ("lumiSwitchActionProperty");
qRegisterMetaType <PropertiesLUMI::DimmerAction> ("lumiDimmerActionProperty");
qRegisterMetaType <PropertiesLUMI::CubeRotation> ("lumiCubeRotationProperty");
qRegisterMetaType <PropertiesLUMI::CubeMovement> ("lumiCubeMovementProperty");
qRegisterMetaType <PropertiesLUMI::Vibration> ("lumiVibrationProperty");
qRegisterMetaType <PropertiesTUYA::DataPoints> ("tuyaDataPointsProperty");
qRegisterMetaType <PropertiesTUYA::HolidayThermostatProgram> ("tuyaHolidayThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::DailyThermostatProgram> ("tuyaDailyThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::MoesThermostatProgram> ("tuyaMoesThermostatProgramProperty");
qRegisterMetaType <PropertiesTUYA::CoverMotor> ("tuyaCoverMotorProperty");
qRegisterMetaType <PropertiesTUYA::CoverSwitch> ("tuyaCoverSwitchProperty");
qRegisterMetaType <PropertiesTUYA::ChildLock> ("tuyaChildLockProperty");
qRegisterMetaType <PropertiesTUYA::ButtonAction> ("tuyaButtonActionProperty");
qRegisterMetaType <PropertiesTUYA::IRCode> ("tuyaIRCodeProperty");
qRegisterMetaType <PropertiesTUYA::OperationMode> ("tuyaOperationModeProperty");
qRegisterMetaType <PropertiesTUYA::IndicatorMode> ("tuyaIndicatorModeProperty");
qRegisterMetaType <PropertiesTUYA::SwitchType> ("tuyaSwitchTypeProperty");
qRegisterMetaType <PropertiesTUYA::PowerOnStatus> ("tuyaPowerOnStatusProperty");
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 <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::SwitchAction> ("ptvoSwitchActionProperty");
qRegisterMetaType <PropertiesPTVO::SerialData> ("ptvoSerialDataProperty");
qRegisterMetaType <PropertiesPTVO::ButtonAction> ("ptvoButtonActionProperty");
qRegisterMetaType <PropertiesByun::GasSensor> ("byunGasSensorProperty");
qRegisterMetaType <PropertiesByun::SmokeSensor> ("byunSmokeSensorProperty");
qRegisterMetaType <PropertiesIKEA::Occupancy> ("ikeaOccupancyProperty");
qRegisterMetaType <PropertiesIKEA::StatusAction> ("ikeaStatusActionProperty");
qRegisterMetaType <PropertiesIKEA::ArrowAction> ("ikeaArrowActionProperty");
}
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);
}
QVariant PropertyObject::enumValue(const QString &name, int index)
{
QVariant data = option(name).toMap().value("enum");
switch (data.type())
{
case QVariant::Map: return data.toMap().value(QString::number(index));
case QVariant::List: return data.toList().value(index);
default: return QVariant();
}
}
void EnumProperty::parseAttribte(quint16, quint16 attributeId, const QByteArray &data)
{
if (attributeId != m_attributeId)
return;
m_value = enumValue(m_name, static_cast <quint8> (data.at(0)));
}