Simulation: Make use of thermostat interface
This commit is contained in:
parent
a884d3af85
commit
51c39fe08a
@ -59,7 +59,8 @@ DeviceManager::DeviceSetupStatus DevicePluginSimulation::setupDevice(Device *dev
|
|||||||
device->deviceClassId() == extendedAwningDeviceClassId ||
|
device->deviceClassId() == extendedAwningDeviceClassId ||
|
||||||
device->deviceClassId() == extendedBlindDeviceClassId ||
|
device->deviceClassId() == extendedBlindDeviceClassId ||
|
||||||
device->deviceClassId() == rollerShutterDeviceClassId ||
|
device->deviceClassId() == rollerShutterDeviceClassId ||
|
||||||
device->deviceClassId() == fingerPrintSensorDeviceClassId) {
|
device->deviceClassId() == fingerPrintSensorDeviceClassId ||
|
||||||
|
device->deviceClassId() == thermostatDeviceClassId) {
|
||||||
m_simulationTimers.insert(device, new QTimer(device));
|
m_simulationTimers.insert(device, new QTimer(device));
|
||||||
connect(m_simulationTimers[device], &QTimer::timeout, this, &DevicePluginSimulation::simulationTimerTimeout);
|
connect(m_simulationTimers[device], &QTimer::timeout, this, &DevicePluginSimulation::simulationTimerTimeout);
|
||||||
}
|
}
|
||||||
@ -143,6 +144,37 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
|
|||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->deviceClassId() == thermostatDeviceClassId) {
|
||||||
|
if (action.actionTypeId() == thermostatPowerActionTypeId) {
|
||||||
|
bool power = action.param(thermostatPowerActionPowerParamTypeId).value().toBool();
|
||||||
|
if (!power && device->stateValue(thermostatBoostStateTypeId).toBool()) {
|
||||||
|
device->setStateValue(thermostatBoostStateTypeId, false);
|
||||||
|
}
|
||||||
|
qCDebug(dcSimulation()) << "Set power" << power << "for thermostat device" << device->name();
|
||||||
|
device->setStateValue(thermostatPowerStateTypeId, power);
|
||||||
|
return DeviceManager::DeviceErrorNoError;
|
||||||
|
}
|
||||||
|
if (action.actionTypeId() == thermostatBoostActionTypeId) {
|
||||||
|
bool boost = action.param(thermostatBoostActionBoostParamTypeId).value().toBool();
|
||||||
|
if (boost && !device->stateValue(thermostatPowerStateTypeId).toBool()) {
|
||||||
|
device->setStateValue(thermostatPowerStateTypeId, true);
|
||||||
|
}
|
||||||
|
qCDebug(dcSimulation()) << "Set boost" << boost << "for thermostat device" << device->name();
|
||||||
|
device->setStateValue(thermostatBoostStateTypeId, boost);
|
||||||
|
m_simulationTimers.value(device)->start(5 * 60 * 1000);
|
||||||
|
return DeviceManager::DeviceErrorNoError;
|
||||||
|
}
|
||||||
|
if (action.actionTypeId() == thermostatTargetTemperatureActionTypeId) {
|
||||||
|
if (!device->stateValue(thermostatPowerStateTypeId).toBool()) {
|
||||||
|
device->setStateValue(thermostatPowerStateTypeId, true);
|
||||||
|
}
|
||||||
|
double targetTemp = action.param(thermostatTargetTemperatureActionTargetTemperatureParamTypeId).value().toDouble();
|
||||||
|
qCDebug(dcSimulation()) << "Set targetTemp" << targetTemp << "for thermostat device" << device->name();
|
||||||
|
device->setStateValue(thermostatTargetTemperatureStateTypeId, targetTemp);
|
||||||
|
return DeviceManager::DeviceErrorNoError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == evChargerDeviceClassId){
|
if (device->deviceClassId() == evChargerDeviceClassId){
|
||||||
|
|
||||||
if (action.actionTypeId() == evChargerPowerActionTypeId){
|
if (action.actionTypeId() == evChargerPowerActionTypeId){
|
||||||
@ -668,5 +700,8 @@ void DevicePluginSimulation::simulationTimerTimeout()
|
|||||||
}
|
}
|
||||||
Event event(evt, device->id(), params);
|
Event event(evt, device->id(), params);
|
||||||
emitEvent(event);
|
emitEvent(event);
|
||||||
|
} else if (device->deviceClassId() == thermostatDeviceClassId) {
|
||||||
|
device->setStateValue(thermostatBoostStateTypeId, false);
|
||||||
|
t->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -202,7 +202,8 @@
|
|||||||
"minValue": 0,
|
"minValue": 0,
|
||||||
"maxValue": 100,
|
"maxValue": 100,
|
||||||
"defaultValue": 100,
|
"defaultValue": 100,
|
||||||
"writable": true
|
"writable": true,
|
||||||
|
"unit": "Percentage"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -249,18 +250,43 @@
|
|||||||
"name": "thermostat",
|
"name": "thermostat",
|
||||||
"displayName": "Thermostat",
|
"displayName": "Thermostat",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"interfaces": ["temperaturesensor"],
|
"interfaces": ["heating", "thermostat"],
|
||||||
"paramTypes": [ ],
|
"paramTypes": [ ],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "edc0ccb6-3a78-44b9-8c7d-638142c27e10",
|
"id": "edc0ccb6-3a78-44b9-8c7d-638142c27e10",
|
||||||
"name": "temperature",
|
"name": "targetTemperature",
|
||||||
"displayName": "Target temperature",
|
"displayName": "Target temperature",
|
||||||
"displayNameEvent": "Target temperature changed",
|
"displayNameEvent": "Target temperature changed",
|
||||||
|
"displayNameAction": "Set target temperature",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "DegreeCelsius",
|
"unit": "DegreeCelsius",
|
||||||
"defaultValue": 0
|
"defaultValue": 5,
|
||||||
|
"minValue": 5,
|
||||||
|
"maxValue": 30,
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "94a7d50c-df3b-4590-a89e-9dae40ad84fa",
|
||||||
|
"name": "power",
|
||||||
|
"displayName": "Power",
|
||||||
|
"displayNameEvent": "Power changed",
|
||||||
|
"displayNameAction": "Set power",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false,
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "f892f660-87ff-458a-bfa0-5af08591233e",
|
||||||
|
"name": "boost",
|
||||||
|
"displayName": "Boost",
|
||||||
|
"displayNameEvent": "Boost enabled changed",
|
||||||
|
"displayNameAction": "Enable/disable boost",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false,
|
||||||
|
"writable": true
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user