Philips Hue - add support for Friends of Hue switches
This commit is contained in:
parent
f500fdb49a
commit
154730c5dc
@ -10,6 +10,7 @@ This plugin allows to interact with the Hue bridge. Each light bulb, sensor and
|
||||
* No internet or cloud connection required
|
||||
* Hue Dimmer switch V1 and V2
|
||||
* Hue Tap Switch
|
||||
* Friends of Hue Switch (e.g. Niko, ...)
|
||||
* Hue Smart Button
|
||||
* Hue Motion Sensor
|
||||
* Hue Outdoor Motion Sensor
|
||||
|
||||
@ -516,6 +516,21 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
||||
return info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
// Friends of Hue switch
|
||||
if (thing->thingClassId() == fohThingClassId) {
|
||||
HueRemote *hueFoh = new HueRemote(bridge, this);
|
||||
hueFoh->setName(thing->name());
|
||||
hueFoh->setId(thing->paramValue(fohThingSensorIdParamTypeId).toInt());
|
||||
hueFoh->setModelId(thing->paramValue(fohThingModelIdParamTypeId).toString());
|
||||
hueFoh->setUuid(thing->paramValue(fohThingUuidParamTypeId).toString());
|
||||
|
||||
connect(hueFoh, &HueRemote::stateChanged, this, &IntegrationPluginPhilipsHue::remoteStateChanged);
|
||||
connect(hueFoh, &HueRemote::buttonPressed, this, &IntegrationPluginPhilipsHue::onRemoteButtonEvent);
|
||||
|
||||
m_remotes.insert(hueFoh, thing);
|
||||
return info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
// Hue smart button
|
||||
if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
HueRemote *smartButton = new HueRemote(bridge, this);
|
||||
@ -644,7 +659,7 @@ void IntegrationPluginPhilipsHue::thingRemoved(Thing *thing)
|
||||
light->deleteLater();
|
||||
}
|
||||
|
||||
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == dimmerSwitch2ThingClassId|| thing->thingClassId() == tapThingClassId || thing->thingClassId() == smartButtonThingClassId) {
|
||||
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == dimmerSwitch2ThingClassId|| thing->thingClassId() == tapThingClassId || thing->thingClassId() == fohThingClassId || thing->thingClassId() == smartButtonThingClassId) {
|
||||
HueRemote *remote = m_remotes.key(thing);
|
||||
m_remotes.remove(remote);
|
||||
remote->deleteLater();
|
||||
@ -1160,6 +1175,8 @@ void IntegrationPluginPhilipsHue::remoteStateChanged()
|
||||
thing->setStateValue(dimmerSwitch2BatteryCriticalStateTypeId, remote->battery() < 5);
|
||||
} else if (thing->thingClassId() == tapThingClassId) {
|
||||
thing->setStateValue(tapConnectedStateTypeId, remote->reachable());
|
||||
} else if (thing->thingClassId() == fohThingClassId) {
|
||||
thing->setStateValue(fohConnectedStateTypeId, remote->reachable());
|
||||
} else if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
thing->setStateValue(smartButtonConnectedStateTypeId, remote->reachable());
|
||||
thing->setStateValue(smartButtonBatteryLevelStateTypeId, remote->battery());
|
||||
@ -1282,6 +1299,28 @@ void IntegrationPluginPhilipsHue::onRemoteButtonEvent(int buttonCode)
|
||||
qCDebug(dcPhilipsHue()) << "Received unhandled button code from Hue Tap:" << buttonCode;
|
||||
return;
|
||||
}
|
||||
} else if (thing->thingClassId() == fohThingClassId) {
|
||||
switch (buttonCode) {
|
||||
case 20:
|
||||
param = Param(fohPressedEventButtonNameParamTypeId, "UPPER LEFT");
|
||||
id = fohPressedEventTypeId;
|
||||
break;
|
||||
case 21:
|
||||
param = Param(fohPressedEventButtonNameParamTypeId, "LOWER LEFT");
|
||||
id = fohPressedEventTypeId;
|
||||
break;
|
||||
case 23:
|
||||
param = Param(fohPressedEventButtonNameParamTypeId, "UPPER RIGHT");
|
||||
id = fohPressedEventTypeId;
|
||||
break;
|
||||
case 22:
|
||||
param = Param(fohPressedEventButtonNameParamTypeId, "LOWER RIGHT");
|
||||
id = fohPressedEventTypeId;
|
||||
break;
|
||||
default:
|
||||
qCDebug(dcPhilipsHue()) << "Received unhandled button code from Friends of Hue switch:" << buttonCode;
|
||||
return;
|
||||
}
|
||||
} else if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
switch (buttonCode) {
|
||||
case 1002:
|
||||
@ -1648,6 +1687,18 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
|
||||
emit autoThingsAppeared({descriptor});
|
||||
qCDebug(dcPhilipsHue) << "Found new smart button" << 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());
|
||||
ParamList params;
|
||||
params.append(Param(fohThingModelIdParamTypeId, model));
|
||||
params.append(Param(fohThingTypeParamTypeId, sensorMap.value("type").toString()));
|
||||
params.append(Param(fohThingUuidParamTypeId, uuid));
|
||||
params.append(Param(fohThingSensorIdParamTypeId, sensorId));
|
||||
descriptor.setParams(params);
|
||||
emit autoThingsAppeared({descriptor});
|
||||
qCDebug(dcPhilipsHue) << "Found new friends of hue switch" << sensorMap.value("name").toString() << model;
|
||||
|
||||
// Hue Tap
|
||||
} else if (sensorMap.value("type").toString() == "ZGPSwitch") {
|
||||
ThingDescriptor descriptor(tapThingClassId, sensorMap.value("name").toString(), "Philips Hue Tap", thing->id());
|
||||
@ -2015,6 +2066,8 @@ void IntegrationPluginPhilipsHue::bridgeReachableChanged(Thing *thing, bool reac
|
||||
m_remotes.value(remote)->setStateValue(dimmerSwitch2ConnectedStateTypeId, false);
|
||||
} else if (m_remotes.value(remote)->thingClassId() == tapThingClassId) {
|
||||
m_remotes.value(remote)->setStateValue(tapConnectedStateTypeId, false);
|
||||
} else if (m_remotes.value(remote)->thingClassId() == fohThingClassId) {
|
||||
m_remotes.value(remote)->setStateValue(fohConnectedStateTypeId, false);
|
||||
} else if (m_remotes.value(remote)->thingClassId() == smartButtonThingClassId) {
|
||||
m_remotes.value(remote)->setStateValue(smartButtonConnectedStateTypeId, false);
|
||||
}
|
||||
@ -2097,6 +2150,13 @@ bool IntegrationPluginPhilipsHue::sensorAlreadyAdded(const QString &uuid)
|
||||
}
|
||||
}
|
||||
|
||||
// Friends of Hue
|
||||
if (thing->thingClassId() == fohThingClassId) {
|
||||
if (thing->paramValue(fohThingUuidParamTypeId).toString() == uuid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Hue smart button
|
||||
if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
if (thing->paramValue(smartButtonThingUuidParamTypeId).toString() == uuid) {
|
||||
|
||||
@ -815,6 +815,70 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "692bc4be-07b8-4b77-ab0b-a36185b17d76",
|
||||
"name": "foh",
|
||||
"displayName": "Friends of Hue Switch",
|
||||
"interfaces": ["multibutton", "wirelessconnectable"],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "664c7091-12eb-4402-8239-31da85f73d38",
|
||||
"name": "modelId",
|
||||
"displayName": "Model ID",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "16ca2ee1-d738-4f51-8f9a-53547d3d824e",
|
||||
"name": "type",
|
||||
"displayName": "Type",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "2ca66286-1caf-4e09-8e18-05bb7d7df314",
|
||||
"name": "uuid",
|
||||
"displayName": "UUID",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "7559d16c-b56b-42e2-8347-65582fa276c0",
|
||||
"name": "sensorId",
|
||||
"displayName": "Sensor ID",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "840b220c-656b-4f56-bbaa-ce818cffad64",
|
||||
"name": "connected",
|
||||
"displayName": "Reachable",
|
||||
"displayNameEvent": "Reachable changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "2cc68bd3-ad73-4bf3-9905-639870d071bd",
|
||||
"name": "pressed",
|
||||
"displayName": "Button pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "f1da229e-fce2-4329-8850-1c92b5bc5925",
|
||||
"name": "buttonName",
|
||||
"displayName": "Button name",
|
||||
"type": "QString",
|
||||
"allowedValues": ["UPPER LEFT", "LOWER LEFT", "UPPER RIGHT", "LOWER RIGHT"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "32dc6390-600f-4eb4-b349-cc2d6796a82a",
|
||||
"name": "outdoorSensor",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user