implement interface longpressmultibutton in for Hue switch

This commit is contained in:
Michael Zanetti 2017-10-24 00:16:47 +02:00
parent 835ff26956
commit ac48210953
2 changed files with 49 additions and 0 deletions

View File

@ -557,35 +557,55 @@ void DevicePluginPhilipsHue::onRemoteButtonEvent(const int &buttonCode)
{
HueRemote *remote = static_cast<HueRemote *>(sender());
Param param(hueRemoteButtonNameParamTypeId);
EventTypeId id;
// TODO: Legacy events should be removed eventually
switch (buttonCode) {
case HueRemote::OnPressed:
emitEvent(Event(hueRemoteOnPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("ON");
id = hueRemotePressedEventTypeId;
break;
case HueRemote::OnLongPressed:
emitEvent(Event(hueRemoteOnLongPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("ON");
id = hueRemoteLongPressedEventTypeId;
break;
case HueRemote::DimUpPressed:
emitEvent(Event(hueRemoteDimUpPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("DIM UP");
id = hueRemotePressedEventTypeId;
break;
case HueRemote::DimUpLongPressed:
emitEvent(Event(hueRemoteDimUpLongPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("DIM UP");
id = hueRemoteLongPressedEventTypeId;
break;
case HueRemote::DimDownPressed:
emitEvent(Event(hueRemoteDimDownPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("DIM DOWN");
id = hueRemotePressedEventTypeId;
break;
case HueRemote::DimDownLongPressed:
emitEvent(Event(hueRemoteDimDownLongPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("DIM DOWN");
id = hueRemoteLongPressedEventTypeId;
break;
case HueRemote::OffPressed:
emitEvent(Event(hueRemoteOffPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("OFF");
id = hueRemotePressedEventTypeId;
break;
case HueRemote::OffLongPressed:
emitEvent(Event(hueRemoteOffLongPressedEventTypeId, m_remotes.value(remote)->id()));
param.setValue("OFF");
id = hueRemoteLongPressedEventTypeId;
break;
default:
break;
}
emitEvent(Event(id, m_remotes.value(remote)->id(), ParamList() << param));
}
void DevicePluginPhilipsHue::onPluginTimer()

View File

@ -449,6 +449,7 @@
"name": "hueRemote",
"displayName": "Hue Remote",
"deviceIcon": "Switch",
"interfaces": ["longpressmultibutton"],
"basicTags": [
"Device",
"Sensor"
@ -577,6 +578,34 @@
"id": "d69306eb-ea52-4841-9e26-89c69e9cf6fc",
"name": "offLongPressed",
"displayName": "off long pressed"
},
{
"id": "8da28cf1-2457-451e-953e-2685f8daeda8",
"name": "pressed",
"displayName": "Button pressed",
"paramTypes": [
{
"id": "e4e3eb3a-a7c4-49e3-9344-0b3f213e0b42",
"name": "buttonName",
"displayName": "Button name",
"type": "QString",
"possibleValues": ["ON", "OFF", "DIM UP", "DIM DOWN"]
}
]
},
{
"id": "2c64561b-2381-4769-8e21-0e206c84bbcc",
"name": "longPressed",
"displayName": "Button longpressed",
"paramTypes": [
{
"id": "e4e3eb3a-a7c4-49e3-9344-0b3f213e0b42",
"name": "buttonName",
"displayName": "Button name",
"type": "QString",
"possibleValues": ["ON", "OFF", "DIM UP", "DIM DOWN"]
}
]
}
]
}