From 99b3058c90c61928a3f06f13449c08e980402323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Tue, 13 Mar 2018 17:25:56 +0100 Subject: [PATCH] Add irrigation --- simulation/devicepluginsimulation.cpp | 17 +++++ simulation/devicepluginsimulation.json | 89 ++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/simulation/devicepluginsimulation.cpp b/simulation/devicepluginsimulation.cpp index b007eb33..51710ab3 100644 --- a/simulation/devicepluginsimulation.cpp +++ b/simulation/devicepluginsimulation.cpp @@ -220,6 +220,15 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, return DeviceManager::DeviceErrorActionTypeNotFound; } + if (device->deviceClassId() == waterValveDeviceClassId) { + if (action.actionTypeId() == waterValvePowerActionTypeId) { + bool power = action.param(waterValvePowerStateParamTypeId).value().toBool(); + device->setStateValue(waterValvePowerStateTypeId, power); + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + return DeviceManager::DeviceErrorDeviceClassNotFound; } @@ -263,6 +272,14 @@ void DevicePluginSimulation::onPluginTimer20Seconds() device->setStateValue(motionDetectorBatteryLevelStateTypeId, generateRandomIntValue(25, 40)); device->setStateValue(motionDetectorBatteryCriticalStateTypeId, device->stateValue(motionDetectorBatteryLevelStateTypeId).toInt() <= 30); device->setStateValue(motionDetectorConnectedStateTypeId, true); + } else if (device->deviceClassId() == gardenSensorDeviceClassId) { + // Garden sensor + device->setStateValue(gardenSensorTemperatureStateTypeId, generateRandomDoubleValue(20, 23)); + device->setStateValue(gardenSensorSoilMoistureStateTypeId, generateRandomIntValue(40, 60)); + device->setStateValue(gardenSensorLightIntensityStateTypeId, generateRandomIntValue(40, 60)); + device->setStateValue(gardenSensorBatteryLevelStateTypeId, generateRandomIntValue(25, 90)); + device->setStateValue(gardenSensorBatteryCriticalStateTypeId, device->stateValue(gardenSensorBatteryLevelStateTypeId).toDouble() <= 30); + device->setStateValue(gardenSensorConnectedStateTypeId, true); } else if(device->deviceClassId() == netatmoIndoorDeviceClassId) { // Netatmo device->setStateValue(netatmoIndoorUpdateTimeStateTypeId, QDateTime::currentDateTime().toTime_t()); diff --git a/simulation/devicepluginsimulation.json b/simulation/devicepluginsimulation.json index f3429e72..691c36b3 100644 --- a/simulation/devicepluginsimulation.json +++ b/simulation/devicepluginsimulation.json @@ -730,6 +730,95 @@ "defaultValue": 87 } ] + }, + { + "id": "b759f558-b484-45b6-9132-218d135c27d6", + "name": "gardenSensor", + "displayName": "Garden sensor", + "createMethods": ["user"], + "deviceIcon": "Thermometer", + "interfaces": ["temperaturesensor", "battery", "connectable"], + "basicTags": ["Device", "Sensor" ], + "paramTypes": [ ], + "stateTypes": [ + { + "id": "63eb7cdd-d16e-4baf-820b-7ad9f0a2b2a8", + "name": "soilMoisture", + "displayName": "Soil moisture", + "displayNameEvent": "Soil moisture changed", + "type": "double", + "minValue": 0, + "maxValue": 100, + "unit": "Percentage", + "defaultValue": 0 + }, + { + "id": "169d7a2a-d1c9-4578-bb30-fc7d25690e59", + "name": "temperature", + "displayName": "Temperature", + "displayNameEvent": "Temperature changed", + "type": "double", + "unit": "DegreeCelsius", + "defaultValue": 0 + }, + { + "id": "9781f0a5-3478-4291-ab51-9daa1ba0e44e", + "name": "lightIntensity", + "displayName": "Light intensity", + "displayNameEvent": "Light intensity changed", + "type": "double", + "unit": "Candela", + "defaultValue": 0 + }, + { + "id": "45c0de32-b519-47d7-9f82-e5f09d1542d4", + "name": "batteryLevel", + "displayName": "Battery", + "displayNameEvent": "Battery level changed", + "type": "int", + "minValue": 0, + "maxValue": 100, + "unit": "Percentage", + "defaultValue": 0 + }, + { + "id": "295b9a17-a4b1-4cc9-8ebb-2309b72c75f6", + "name": "batteryCritical", + "displayName": "Battery critical", + "displayNameEvent": "Battery critical changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "e66aba37-2647-4b6b-8740-d59eb98d846c", + "name": "connected", + "displayName": "Connected", + "displayNameEvent": "Connected changed", + "type": "bool", + "defaultValue": true + } + ] + }, + { + "id": "8fc2e79b-1770-4b18-bf01-78ed15893a81", + "name": "waterValve", + "displayName": "Water valve", + "createMethods": ["user"], + "deviceIcon": "None", + "basicTags": ["Device", "Actuator"], + "paramTypes": [ ], + "stateTypes": [ + { + "id": "b7ff029d-f3a6-4b47-978a-ac1a581aac0f", + "name": "power", + "displayName": "Power", + "displayNameEvent": "Power changed", + "displayNameAction": "Set power", + "type": "bool", + "defaultValue": false, + "writable": true + } + ] } ] }