Merge PR #371: Simulation: Add a simulated water sensor
This commit is contained in:
commit
32c5edaa0d
@ -71,7 +71,8 @@ void IntegrationPluginSimulation::setupThing(ThingSetupInfo *info)
|
|||||||
thing->thingClassId() == rollerShutterThingClassId ||
|
thing->thingClassId() == rollerShutterThingClassId ||
|
||||||
thing->thingClassId() == fingerPrintSensorThingClassId ||
|
thing->thingClassId() == fingerPrintSensorThingClassId ||
|
||||||
thing->thingClassId() == barcodeScannerThingClassId ||
|
thing->thingClassId() == barcodeScannerThingClassId ||
|
||||||
thing->thingClassId() == contactSensorThingClassId) {
|
thing->thingClassId() == contactSensorThingClassId ||
|
||||||
|
thing->thingClassId() == waterSensorThingClassId) {
|
||||||
m_simulationTimers.insert(thing, new QTimer(thing));
|
m_simulationTimers.insert(thing, new QTimer(thing));
|
||||||
connect(m_simulationTimers[thing], &QTimer::timeout, this, &IntegrationPluginSimulation::simulationTimerTimeout);
|
connect(m_simulationTimers[thing], &QTimer::timeout, this, &IntegrationPluginSimulation::simulationTimerTimeout);
|
||||||
}
|
}
|
||||||
@ -127,6 +128,9 @@ void IntegrationPluginSimulation::setupThing(ThingSetupInfo *info)
|
|||||||
if (thing->thingClassId() == contactSensorThingClassId) {
|
if (thing->thingClassId() == contactSensorThingClassId) {
|
||||||
m_simulationTimers.value(thing)->start(10000);
|
m_simulationTimers.value(thing)->start(10000);
|
||||||
}
|
}
|
||||||
|
if (thing->thingClassId() == waterSensorThingClassId) {
|
||||||
|
m_simulationTimers.value(thing)->start(10000);
|
||||||
|
}
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,10 +632,12 @@ void IntegrationPluginSimulation::onPluginTimer20Seconds()
|
|||||||
thing->setStateValue(temperatureSensorConnectedStateTypeId, true);
|
thing->setStateValue(temperatureSensorConnectedStateTypeId, true);
|
||||||
} else if (thing->thingClassId() == motionDetectorThingClassId) {
|
} else if (thing->thingClassId() == motionDetectorThingClassId) {
|
||||||
// Motion detector
|
// Motion detector
|
||||||
thing->setStateValue(motionDetectorActiveStateTypeId, generateRandomBoolValue());
|
thing->setStateValue(motionDetectorIsPresentStateTypeId, generateRandomBoolValue());
|
||||||
thing->setStateValue(motionDetectorBatteryLevelStateTypeId, generateBatteryValue(13, 1));
|
thing->setStateValue(motionDetectorBatteryLevelStateTypeId, generateBatteryValue(13, 1));
|
||||||
thing->setStateValue(motionDetectorBatteryCriticalStateTypeId, thing->stateValue(motionDetectorBatteryLevelStateTypeId).toInt() <= 30);
|
thing->setStateValue(motionDetectorBatteryCriticalStateTypeId, thing->stateValue(motionDetectorBatteryLevelStateTypeId).toInt() <= 30);
|
||||||
thing->setStateValue(motionDetectorConnectedStateTypeId, true);
|
thing->setStateValue(motionDetectorConnectedStateTypeId, true);
|
||||||
|
} else if (thing->thingClassId() == waterSensorThingClassId) {
|
||||||
|
thing->setStateValue(waterSensorWaterDetectedStateTypeId, generateRandomBoolValue());
|
||||||
} else if (thing->thingClassId() == gardenSensorThingClassId) {
|
} else if (thing->thingClassId() == gardenSensorThingClassId) {
|
||||||
// Garden sensor
|
// Garden sensor
|
||||||
thing->setStateValue(gardenSensorTemperatureStateTypeId, generateSinValue(-4, 17, 5));
|
thing->setStateValue(gardenSensorTemperatureStateTypeId, generateSinValue(-4, 17, 5));
|
||||||
@ -787,5 +793,8 @@ void IntegrationPluginSimulation::simulationTimerTimeout()
|
|||||||
} else {
|
} else {
|
||||||
thing->setStateValue(contactSensorBatteryCriticalStateTypeId, false);
|
thing->setStateValue(contactSensorBatteryCriticalStateTypeId, false);
|
||||||
}
|
}
|
||||||
|
} else if (thing->thingClassId() == waterSensorThingClassId) {
|
||||||
|
bool wet = qrand() > (RAND_MAX / 2);
|
||||||
|
thing->setStateValue(waterSensorWaterDetectedStateTypeId, wet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,12 +115,12 @@
|
|||||||
"name": "motionDetector",
|
"name": "motionDetector",
|
||||||
"displayName": "Motion Detector",
|
"displayName": "Motion Detector",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"interfaces": ["battery", "connectable"],
|
"interfaces": ["presencesensor", "battery", "connectable"],
|
||||||
"paramTypes": [ ],
|
"paramTypes": [ ],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "5ab00bfc-7345-44a2-90d4-852c810e59ec",
|
"id": "5ab00bfc-7345-44a2-90d4-852c810e59ec",
|
||||||
"name": "active",
|
"name": "isPresent",
|
||||||
"displayName": "Active",
|
"displayName": "Active",
|
||||||
"displayNameEvent": "Motion detected",
|
"displayNameEvent": "Motion detected",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
@ -153,6 +153,15 @@
|
|||||||
"displayNameEvent": "Connected changed",
|
"displayNameEvent": "Connected changed",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": true
|
"defaultValue": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "17874952-a1ab-467f-9786-29ffe3196a8c",
|
||||||
|
"name": "lastSeenTime",
|
||||||
|
"displayName": "Last seen",
|
||||||
|
"displayNameEvent": "Last seen changed",
|
||||||
|
"type": "int",
|
||||||
|
"unit": "UnixTime",
|
||||||
|
"defaultValue": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1026,7 +1035,7 @@
|
|||||||
"name": "waterValve",
|
"name": "waterValve",
|
||||||
"displayName": "Water valve",
|
"displayName": "Water valve",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"paramTypes": [ ],
|
"interfaces": ["irrigation"],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "194f05a9-2c54-466c-a2a9-3d278fb41a2a",
|
"id": "194f05a9-2c54-466c-a2a9-3d278fb41a2a",
|
||||||
@ -1108,6 +1117,23 @@
|
|||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "088aa0cb-61e8-46b6-b99d-699a29fd79c7",
|
||||||
|
"name": "waterSensor",
|
||||||
|
"displayName": "Water sensor",
|
||||||
|
"createMethods": ["user"],
|
||||||
|
"interfaces": ["watersensor"],
|
||||||
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "764cbbbf-6a5c-4265-9424-fc9e6dd86fda",
|
||||||
|
"name": "waterDetected",
|
||||||
|
"displayName": "Wet",
|
||||||
|
"displayNameEvent": "Water detected",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -513,7 +513,7 @@
|
|||||||
"id": "e8e18bbe-27bb-4fd7-98fc-f5cef3b5f213",
|
"id": "e8e18bbe-27bb-4fd7-98fc-f5cef3b5f213",
|
||||||
"setupMethod": "JustAdd",
|
"setupMethod": "JustAdd",
|
||||||
"createMethods": [ "Auto" ],
|
"createMethods": [ "Auto" ],
|
||||||
"interfaces": [ "sensor", "battery", "wirelessconnectable" ],
|
"interfaces": [ "watersensor", "battery", "wirelessconnectable" ],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "e12453e7-5fc3-4549-b4fc-8b85f78607c6",
|
"id": "e12453e7-5fc3-4549-b4fc-8b85f78607c6",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user