PhilipsHue: Add support for the Hue smart button
This commit is contained in:
parent
20ca551b75
commit
99671b4912
@ -45,8 +45,10 @@ class HueRemote : public HueDevice
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum ButtonCode {
|
enum ButtonCode {
|
||||||
|
SmartButtonPressed = 1000,
|
||||||
OnLongPressed = 1001,
|
OnLongPressed = 1001,
|
||||||
OnPressed = 1002,
|
OnPressed = 1002,
|
||||||
|
SmartButtonLongPressed = 1003,
|
||||||
DimUpLongPressed = 2001,
|
DimUpLongPressed = 2001,
|
||||||
DimUpPressed = 2002,
|
DimUpPressed = 2002,
|
||||||
DimDownLongPressed = 3001,
|
DimDownLongPressed = 3001,
|
||||||
|
|||||||
@ -422,6 +422,20 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
|||||||
return info->finish(Thing::ThingErrorNoError);
|
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
|
// Hue Motion sensor
|
||||||
if (thing->thingClassId() == motionSensorThingClassId) {
|
if (thing->thingClassId() == motionSensorThingClassId) {
|
||||||
qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << thing->params();
|
qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << thing->params();
|
||||||
@ -515,7 +529,7 @@ void IntegrationPluginPhilipsHue::thingRemoved(Thing *thing)
|
|||||||
light->deleteLater();
|
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);
|
HueRemote *remote = m_remotes.key(thing);
|
||||||
m_remotes.remove(remote);
|
m_remotes.remove(remote);
|
||||||
remote->deleteLater();
|
remote->deleteLater();
|
||||||
@ -1053,6 +1067,12 @@ void IntegrationPluginPhilipsHue::onRemoteButtonEvent(int buttonCode)
|
|||||||
param = Param(tapPressedEventButtonNameParamTypeId, "••••");
|
param = Param(tapPressedEventButtonNameParamTypeId, "••••");
|
||||||
id = tapPressedEventTypeId;
|
id = tapPressedEventTypeId;
|
||||||
break;
|
break;
|
||||||
|
case HueRemote::SmartButtonPressed:
|
||||||
|
id = smartButtonPressedEventTypeId;
|
||||||
|
break;
|
||||||
|
case HueRemote::SmartButtonLongPressed:
|
||||||
|
id = smartButtonLongPressedEventTypeId;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1341,7 +1361,8 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
|
|||||||
if (sensorAlreadyAdded(uuid))
|
if (sensorAlreadyAdded(uuid))
|
||||||
continue;
|
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());
|
ThingDescriptor descriptor(remoteThingClassId, sensorMap.value("name").toString(), "Philips Hue Remote", thing->id());
|
||||||
ParamList params;
|
ParamList params;
|
||||||
params.append(Param(remoteThingModelIdParamTypeId, model));
|
params.append(Param(remoteThingModelIdParamTypeId, model));
|
||||||
@ -1351,6 +1372,20 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
|
|||||||
descriptor.setParams(params);
|
descriptor.setParams(params);
|
||||||
emit autoThingsAppeared({descriptor});
|
emit autoThingsAppeared({descriptor});
|
||||||
qCDebug(dcPhilipsHue) << "Found new remote" << sensorMap.value("name").toString() << model;
|
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") {
|
} else if (sensorMap.value("type").toString() == "ZGPSwitch") {
|
||||||
ThingDescriptor descriptor(tapThingClassId, sensorMap.value("name").toString(), "Philips Hue Tap", thing->id());
|
ThingDescriptor descriptor(tapThingClassId, sensorMap.value("name").toString(), "Philips Hue Tap", thing->id());
|
||||||
ParamList params;
|
ParamList params;
|
||||||
@ -1695,6 +1730,8 @@ void IntegrationPluginPhilipsHue::bridgeReachableChanged(Thing *thing, const boo
|
|||||||
m_remotes.value(remote)->setStateValue(remoteConnectedStateTypeId, false);
|
m_remotes.value(remote)->setStateValue(remoteConnectedStateTypeId, false);
|
||||||
} else if (m_remotes.value(remote)->thingClassId() == tapThingClassId) {
|
} else if (m_remotes.value(remote)->thingClassId() == tapThingClassId) {
|
||||||
m_remotes.value(remote)->setStateValue(tapConnectedStateTypeId, false);
|
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
|
// Outdoor sensor consits out of 3 sensors
|
||||||
if (thing->thingClassId() == outdoorSensorThingClassId) {
|
if (thing->thingClassId() == outdoorSensorThingClassId) {
|
||||||
if (thing->paramValue(outdoorSensorThingSensorUuidLightParamTypeId).toString() == uuid) {
|
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",
|
"id": "2b8c1fb8-67ee-42e9-947b-16e0a09f0d4e",
|
||||||
"name": "tap",
|
"name": "tap",
|
||||||
"displayName": "Hue Tap",
|
"displayName": "Hue Tap",
|
||||||
"interfaces": ["simplemultibutton", "connectable"],
|
"interfaces": ["multibutton", "connectable"],
|
||||||
"createMethods": ["auto"],
|
"createMethods": ["auto"],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "62d92175-db3a-4da2-a72b-f58f34cb6911",
|
"id": "62d92175-db3a-4da2-a72b-f58f34cb6911",
|
||||||
"name": "modelId",
|
"name": "modelId",
|
||||||
"displayName": "model id",
|
"displayName": "Model ID",
|
||||||
"type" : "QString",
|
"type" : "QString",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "eace85b9-5369-466f-89eb-46c4de718305",
|
"id": "eace85b9-5369-466f-89eb-46c4de718305",
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"displayName": "type",
|
"displayName": "Type",
|
||||||
"type" : "QString",
|
"type" : "QString",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "25cf4167-6c28-4497-9fa9-3d02faf4f3ed",
|
"id": "25cf4167-6c28-4497-9fa9-3d02faf4f3ed",
|
||||||
"name": "uuid",
|
"name": "uuid",
|
||||||
"displayName": "uuid",
|
"displayName": "UUID",
|
||||||
"type" : "QString",
|
"type" : "QString",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "5eca2b24-8986-4487-bc12-50e91d023d97",
|
"id": "5eca2b24-8986-4487-bc12-50e91d023d97",
|
||||||
"name": "sensorId",
|
"name": "sensorId",
|
||||||
"displayName": "sensor id",
|
"displayName": "Sensor ID",
|
||||||
"type" : "int",
|
"type" : "int",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
}
|
}
|
||||||
@ -562,8 +622,8 @@
|
|||||||
{
|
{
|
||||||
"id": "5e21b032-1230-4e93-8543-0c4773da17d3",
|
"id": "5e21b032-1230-4e93-8543-0c4773da17d3",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "reachable",
|
"displayName": "Reachable",
|
||||||
"displayNameEvent": "reachable changed",
|
"displayNameEvent": "Reachable changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"cached": false
|
"cached": false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user