PhilipsHue: Add support for the Hue smart button
parent
20ca551b75
commit
99671b4912
|
|
@ -45,8 +45,10 @@ class HueRemote : public HueDevice
|
|||
Q_OBJECT
|
||||
public:
|
||||
enum ButtonCode {
|
||||
SmartButtonPressed = 1000,
|
||||
OnLongPressed = 1001,
|
||||
OnPressed = 1002,
|
||||
SmartButtonLongPressed = 1003,
|
||||
DimUpLongPressed = 2001,
|
||||
DimUpPressed = 2002,
|
||||
DimDownLongPressed = 3001,
|
||||
|
|
|
|||
|
|
@ -422,6 +422,20 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
|||
return info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
// Hue smart button
|
||||
if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
HueRemote *smartButton = new HueRemote(this);
|
||||
smartButton->setName(thing->name());
|
||||
smartButton->setId(thing->paramValue(tapThingSensorIdParamTypeId).toInt());
|
||||
smartButton->setModelId(thing->paramValue(tapThingModelIdParamTypeId).toString());
|
||||
|
||||
connect(smartButton, &HueRemote::stateChanged, this, &IntegrationPluginPhilipsHue::remoteStateChanged);
|
||||
connect(smartButton, &HueRemote::buttonPressed, this, &IntegrationPluginPhilipsHue::onRemoteButtonEvent);
|
||||
|
||||
m_remotes.insert(smartButton, thing);
|
||||
return info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
// Hue Motion sensor
|
||||
if (thing->thingClassId() == motionSensorThingClassId) {
|
||||
qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << thing->params();
|
||||
|
|
@ -515,7 +529,7 @@ void IntegrationPluginPhilipsHue::thingRemoved(Thing *thing)
|
|||
light->deleteLater();
|
||||
}
|
||||
|
||||
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == tapThingClassId) {
|
||||
if (thing->thingClassId() == remoteThingClassId || thing->thingClassId() == tapThingClassId || thing->thingClassId() == smartButtonThingClassId) {
|
||||
HueRemote *remote = m_remotes.key(thing);
|
||||
m_remotes.remove(remote);
|
||||
remote->deleteLater();
|
||||
|
|
@ -1053,6 +1067,12 @@ void IntegrationPluginPhilipsHue::onRemoteButtonEvent(int buttonCode)
|
|||
param = Param(tapPressedEventButtonNameParamTypeId, "••••");
|
||||
id = tapPressedEventTypeId;
|
||||
break;
|
||||
case HueRemote::SmartButtonPressed:
|
||||
id = smartButtonPressedEventTypeId;
|
||||
break;
|
||||
case HueRemote::SmartButtonLongPressed:
|
||||
id = smartButtonLongPressedEventTypeId;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -1341,7 +1361,8 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
|
|||
if (sensorAlreadyAdded(uuid))
|
||||
continue;
|
||||
|
||||
if (sensorMap.value("type").toString() == "ZLLSwitch") {
|
||||
// Dimmer Switch: RWL020 == US, RWL021 == EU
|
||||
if (model == "RWL020" || model == "RWL021") {
|
||||
ThingDescriptor descriptor(remoteThingClassId, sensorMap.value("name").toString(), "Philips Hue Remote", thing->id());
|
||||
ParamList params;
|
||||
params.append(Param(remoteThingModelIdParamTypeId, model));
|
||||
|
|
@ -1351,6 +1372,20 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
|
|||
descriptor.setParams(params);
|
||||
emit autoThingsAppeared({descriptor});
|
||||
qCDebug(dcPhilipsHue) << "Found new remote" << sensorMap.value("name").toString() << model;
|
||||
|
||||
// Smart Button
|
||||
} else if (model == "ROM001") {
|
||||
ThingDescriptor descriptor(smartButtonThingClassId, sensorMap.value("name").toString(), "Philips Hue Smart Button", thing->id());
|
||||
ParamList params;
|
||||
params.append(Param(smartButtonThingModelIdParamTypeId, model));
|
||||
params.append(Param(smartButtonThingTypeParamTypeId, sensorMap.value("type").toString()));
|
||||
params.append(Param(smartButtonThingUuidParamTypeId, uuid));
|
||||
params.append(Param(smartButtonThingSensorIdParamTypeId, sensorId));
|
||||
descriptor.setParams(params);
|
||||
emit autoThingsAppeared({descriptor});
|
||||
qCDebug(dcPhilipsHue) << "Found new smart button" << 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());
|
||||
ParamList params;
|
||||
|
|
@ -1695,6 +1730,8 @@ void IntegrationPluginPhilipsHue::bridgeReachableChanged(Thing *thing, const boo
|
|||
m_remotes.value(remote)->setStateValue(remoteConnectedStateTypeId, false);
|
||||
} else if (m_remotes.value(remote)->thingClassId() == tapThingClassId) {
|
||||
m_remotes.value(remote)->setStateValue(tapConnectedStateTypeId, false);
|
||||
} else if (m_remotes.value(remote)->thingClassId() == smartButtonThingClassId) {
|
||||
m_remotes.value(remote)->setStateValue(smartButtonConnectedStateTypeId, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1759,6 +1796,13 @@ bool IntegrationPluginPhilipsHue::sensorAlreadyAdded(const QString &uuid)
|
|||
}
|
||||
}
|
||||
|
||||
// Hue smart button
|
||||
if (thing->thingClassId() == smartButtonThingClassId) {
|
||||
if (thing->paramValue(smartButtonThingUuidParamTypeId).toString() == uuid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Outdoor sensor consits out of 3 sensors
|
||||
if (thing->thingClassId() == outdoorSensorThingClassId) {
|
||||
if (thing->paramValue(outdoorSensorThingSensorUuidLightParamTypeId).toString() == uuid) {
|
||||
|
|
|
|||
|
|
@ -522,38 +522,98 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1e34a056-9f37-4741-b249-a5eca7a4ab4e",
|
||||
"name": "smartButton",
|
||||
"displayName": "Hue Smart Button",
|
||||
"interfaces": ["longpressbutton", "connectable"],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9271179f-5fe1-4005-9f97-ccde33b1b2c4",
|
||||
"name": "modelId",
|
||||
"displayName": "Model ID",
|
||||
"type": "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "7221aacc-1420-43f2-a05a-448a0f783713",
|
||||
"name": "type",
|
||||
"displayName": "Type",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "2378a06d-b748-445b-94e2-4dd885a54f22",
|
||||
"name": "uuid",
|
||||
"displayName": "UUID",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "54744fcc-c052-4c16-a857-fbe0b791e538",
|
||||
"name": "sensorId",
|
||||
"displayName": "Sensor ID",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "b449cca5-19a0-483f-b4bd-b9b43b4f8ed4",
|
||||
"name": "connected",
|
||||
"displayName": "Reachable",
|
||||
"displayNameEvent": "Reachable changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "c809179e-effa-4717-9172-11df7e80d109",
|
||||
"name": "pressed",
|
||||
"displayName": "Button pressed"
|
||||
},
|
||||
{
|
||||
"id": "25803922-37f1-47c8-ac00-2d3acb9eb634",
|
||||
"name": "longPressed",
|
||||
"displayName": "Long pressed"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "2b8c1fb8-67ee-42e9-947b-16e0a09f0d4e",
|
||||
"name": "tap",
|
||||
"displayName": "Hue Tap",
|
||||
"interfaces": ["simplemultibutton", "connectable"],
|
||||
"interfaces": ["multibutton", "connectable"],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "62d92175-db3a-4da2-a72b-f58f34cb6911",
|
||||
"name": "modelId",
|
||||
"displayName": "model id",
|
||||
"displayName": "Model ID",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "eace85b9-5369-466f-89eb-46c4de718305",
|
||||
"name": "type",
|
||||
"displayName": "type",
|
||||
"displayName": "Type",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "25cf4167-6c28-4497-9fa9-3d02faf4f3ed",
|
||||
"name": "uuid",
|
||||
"displayName": "uuid",
|
||||
"displayName": "UUID",
|
||||
"type" : "QString",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "5eca2b24-8986-4487-bc12-50e91d023d97",
|
||||
"name": "sensorId",
|
||||
"displayName": "sensor id",
|
||||
"displayName": "Sensor ID",
|
||||
"type" : "int",
|
||||
"readOnly": true
|
||||
}
|
||||
|
|
@ -562,8 +622,8 @@
|
|||
{
|
||||
"id": "5e21b032-1230-4e93-8543-0c4773da17d3",
|
||||
"name": "connected",
|
||||
"displayName": "reachable",
|
||||
"displayNameEvent": "reachable changed",
|
||||
"displayName": "Reachable",
|
||||
"displayNameEvent": "Reachable changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
|
|
|
|||
Loading…
Reference in New Issue