Add support for Hue Wall Switch Module

button codes not yet correct
This commit is contained in:
loosrob 2021-08-13 16:57:47 +02:00
parent 154730c5dc
commit cc3771f0c8
2 changed files with 124 additions and 1 deletions

View File

@ -546,6 +546,21 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
return info->finish(Thing::ThingErrorNoError);
}
// Hue Wall Switch module
if (thing->thingClassId() == wallSwitchThingClassId) {
HueRemote *wallSwitch = new HueRemote(bridge, this);
wallSwitch->setName(thing->name());
wallSwitch->setId(thing->paramValue(wallSwitchThingSensorIdParamTypeId).toInt());
wallSwitch->setModelId(thing->paramValue(wallSwitchThingModelIdParamTypeId).toString());
wallSwitch->setUuid(thing->paramValue(wallSwitchThingUuidParamTypeId).toString());
connect(wallSwitch, &HueRemote::stateChanged, this, &IntegrationPluginPhilipsHue::remoteStateChanged);
connect(wallSwitch, &HueRemote::buttonPressed, this, &IntegrationPluginPhilipsHue::onRemoteButtonEvent);
m_remotes.insert(smarwallSwitchtButton, thing);
return info->finish(Thing::ThingErrorNoError);
}
// Hue Motion sensor
if (thing->thingClassId() == motionSensorThingClassId) {
qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << thing->params();
@ -659,7 +674,7 @@ void IntegrationPluginPhilipsHue::thingRemoved(Thing *thing)
light->deleteLater();
}
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == dimmerSwitch2ThingClassId|| thing->thingClassId() == tapThingClassId || thing->thingClassId() == fohThingClassId || thing->thingClassId() == smartButtonThingClassId) {
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == dimmerSwitch2ThingClassId|| thing->thingClassId() == tapThingClassId || thing->thingClassId() == fohThingClassId || thing->thingClassId() == smartButtonThingClassId|| thing->thingClassId() == wallSwitchThingClassId) {
HueRemote *remote = m_remotes.key(thing);
m_remotes.remove(remote);
remote->deleteLater();
@ -1181,6 +1196,10 @@ void IntegrationPluginPhilipsHue::remoteStateChanged()
thing->setStateValue(smartButtonConnectedStateTypeId, remote->reachable());
thing->setStateValue(smartButtonBatteryLevelStateTypeId, remote->battery());
thing->setStateValue(smartButtonBatteryCriticalStateTypeId, remote->battery() < 5);
} else if (thing->thingClassId() == wallSwitchThingClassId) {
thing->setStateValue(wallSwitchConnectedStateTypeId, remote->reachable());
thing->setStateValue(wallSwitchBatteryLevelStateTypeId, remote->battery());
thing->setStateValue(wallSwitchBatteryCriticalStateTypeId, remote->battery() < 5);
}
}
@ -1333,6 +1352,15 @@ void IntegrationPluginPhilipsHue::onRemoteButtonEvent(int buttonCode)
qCDebug(dcPhilipsHue()) << "Received unhandled button code from Hue Smart Button:" << buttonCode;
return;
}
} else if (thing->thingClassId() == wallSwitchThingClassId) {
switch (buttonCode) {
case 999999: // temporary number, replace with code (codes for on and off?)
id = wallSwitchPressedEventTypeId;
break;
default:
qCDebug(dcPhilipsHue()) << "Received unhandled button code from Hue Wall Switch Module:" << buttonCode;
return;
}
}
emitEvent(Event(id, m_remotes.value(remote)->id(), ParamList() << param));
}
@ -1687,6 +1715,18 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
emit autoThingsAppeared({descriptor});
qCDebug(dcPhilipsHue) << "Found new smart button" << sensorMap.value("name").toString() << model;
// Wall Switch Module
} else if (model == "RDM001") {
ThingDescriptor descriptor(wallSwitchThingClassId, sensorMap.value("name").toString(), "Philips Hue Wall Switch Module", thing->id());
ParamList params;
params.append(Param(wallSwitchThingModelIdParamTypeId, model));
params.append(Param(wallSwitchThingTypeParamTypeId, sensorMap.value("type").toString()));
params.append(Param(wallSwitchThingUuidParamTypeId, uuid));
params.append(Param(wallSwitchThingSensorIdParamTypeId, sensorId));
descriptor.setParams(params);
emit autoThingsAppeared({descriptor});
qCDebug(dcPhilipsHue) << "Found new wall switch module" << sensorMap.value("name").toString() << model;
// Friends of Hue switch
} else if (model == "FOHSWITCH") {
ThingDescriptor descriptor(fohThingClassId, sensorMap.value("name").toString(), "Friends of Hue Switch", thing->id());
@ -2070,6 +2110,8 @@ void IntegrationPluginPhilipsHue::bridgeReachableChanged(Thing *thing, bool reac
m_remotes.value(remote)->setStateValue(fohConnectedStateTypeId, false);
} else if (m_remotes.value(remote)->thingClassId() == smartButtonThingClassId) {
m_remotes.value(remote)->setStateValue(smartButtonConnectedStateTypeId, false);
} else if (m_remotes.value(remote)->thingClassId() == wallSwitchThingClassId) {
m_remotes.value(remote)->setStateValue(wallSwitchConnectedStateTypeId, false);
}
}
}
@ -2164,6 +2206,13 @@ bool IntegrationPluginPhilipsHue::sensorAlreadyAdded(const QString &uuid)
}
}
// Hue wall switch module
if (thing->thingClassId() == wallSwitchThingClassId) {
if (thing->paramValue(wallSwitchThingUuidParamTypeId).toString() == uuid) {
return true;
}
}
// Outdoor sensor consits out of 3 sensors
if (thing->thingClassId() == outdoorSensorThingClassId) {
if (thing->paramValue(outdoorSensorThingSensorUuidLightParamTypeId).toString() == uuid) {

View File

@ -751,6 +751,80 @@
}
]
},
{
"id": "e967027f-f8fc-410c-8b48-6ac4c42e2777",
"name": "wallSwitch",
"displayName": "Hue Wall Switch Module",
"interfaces": ["button", "wirelessconnectable"],
"createMethods": ["auto"],
"paramTypes": [
{
"id": "71c2c485-6a09-4bcd-80e5-24cdc45d323f",
"name": "modelId",
"displayName": "Model ID",
"type": "QString",
"readOnly": true
},
{
"id": "08606780-2251-4c15-bb7d-7506535e14ed",
"name": "type",
"displayName": "Type",
"type" : "QString",
"readOnly": true
},
{
"id": "4cdab881-5d2d-4443-816a-231bbb331f22",
"name": "uuid",
"displayName": "UUID",
"type" : "QString",
"readOnly": true
},
{
"id": "62a9df8c-51b5-434f-9d5d-5fa97144076a",
"name": "sensorId",
"displayName": "Sensor ID",
"type" : "int",
"readOnly": true
}
],
"stateTypes": [
{
"id": "b51071af-1290-41f1-b2eb-e84527342ade",
"name": "connected",
"displayName": "Reachable",
"displayNameEvent": "Reachable changed",
"defaultValue": false,
"type": "bool",
"cached": false
},
{
"id": "b025cab6-d128-43eb-ba63-b16861d6ab10",
"name": "batteryLevel",
"displayName": "Battery level",
"displayNameEvent": "Battery level changed",
"type": "int",
"unit": "Percentage",
"defaultValue": 0,
"minValue": 0,
"maxValue": 100
},
{
"id": "7fcf84e4-5638-46ce-9a7c-85b8bd466b38",
"name": "batteryCritical",
"displayName": "Battery critical",
"displayNameEvent": "Battery critical changed",
"type": "bool",
"defaultValue": false
}
],
"eventTypes": [
{
"id": "4623b5ff-b999-4200-ba38-89435d78fcae",
"name": "pressed",
"displayName": "Button pressed"
}
]
},
{
"id": "2b8c1fb8-67ee-42e9-947b-16e0a09f0d4e",
"name": "tap",