diff --git a/zigbee-generic-lights/integrationpluginzigbeegenericlights.cpp b/zigbee-generic-lights/integrationpluginzigbeegenericlights.cpp index a5f3ca25..47872aef 100644 --- a/zigbee-generic-lights/integrationpluginzigbeegenericlights.cpp +++ b/zigbee-generic-lights/integrationpluginzigbeegenericlights.cpp @@ -66,7 +66,7 @@ IntegrationPluginZigbeeGenericLights::IntegrationPluginZigbeeGenericLights() m_modelIdParamTypeIds[colorLightThingClassId] = colorLightThingModelParamTypeId; - // Common sates map + // Common states map m_connectedStateTypeIds[onOffLightThingClassId] = onOffLightConnectedStateTypeId; m_connectedStateTypeIds[dimmableLightThingClassId] = dimmableLightConnectedStateTypeId; m_connectedStateTypeIds[colorTemperatureLightThingClassId] = colorTemperatureLightConnectedStateTypeId; diff --git a/zigbee-lumi/integrationpluginzigbee-lumi.json b/zigbee-lumi/integrationpluginzigbee-lumi.json index 06775ce5..d18de87d 100644 --- a/zigbee-lumi/integrationpluginzigbee-lumi.json +++ b/zigbee-lumi/integrationpluginzigbee-lumi.json @@ -717,6 +717,94 @@ ], "eventTypes": [ + ] + }, + { + "name": "lumiRemote", + "displayName": "Switch", + "id": "f8aa2ba1-ce74-4691-b97d-85427f4cf8bd", + "setupMethod": "JustAdd", + "createMethods": [ "Auto" ], + "interfaces": [ "longpressmultibutton", "wirelessconnectable" ], + "paramTypes": [ + { + "id": "cce8b39c-ac8a-4a8f-b66e-b6100a209fb8", + "name": "ieeeAddress", + "displayName": "IEEE adress", + "type": "QString", + "defaultValue": "00:00:00:00:00:00:00:00" + }, + { + "id": "8eec3cae-8f3b-4c32-b26a-f7c49844841e", + "name": "networkUuid", + "displayName": "Zigbee network UUID", + "type": "QString", + "defaultValue": "" + } + ], + "stateTypes": [ + { + "id": "d1afa3ba-f3bd-47e5-90fa-9d80dcce91d8", + "name": "connected", + "displayName": "Connected", + "displayNameEvent": "Connected changed", + "type": "bool", + "cached": false, + "defaultValue": false + }, + { + "id": "a764dbfb-7b86-439b-94ea-aec742dcb13e", + "name": "signalStrength", + "displayName": "Signal strength", + "displayNameEvent": "Signal strength changed", + "defaultValue": 0, + "maxValue": 100, + "minValue": 0, + "type": "uint", + "unit": "Percentage" + }, + { + "id": "8164c1d0-657e-4347-99fb-f3fdc07af6de", + "name": "version", + "displayName": "Version", + "displayNameEvent": "Version changed", + "type": "QString", + "cached": true, + "defaultValue": "" + } + ], + "actionTypes": [ + + ], + "eventTypes": [ + { + "id": "9a0c5f37-e346-41d9-93a4-4877c012b805", + "name": "pressed", + "displayName": "Button pressed", + "paramTypes": [ + { + "id": "72df572a-77d2-42b4-8ffa-cde70ccca37c", + "name": "buttonName", + "displayName": "Button name", + "type": "QString", + "allowedValues": ["1", "2", "1+2"] + } + ] + }, + { + "id": "9a7a3d9e-faa3-471f-8c82-0bb98d9a788a", + "name": "longPressed", + "displayName": "Button longpressed", + "paramTypes": [ + { + "id": "0a8d4da6-be6e-4b7d-92d7-5cf35d74042f", + "name": "buttonName", + "displayName": "Button name", + "type": "QString", + "allowedValues": ["1", "2", "1+2"] + } + ] + } ] } ] diff --git a/zigbee-lumi/integrationpluginzigbeelumi.cpp b/zigbee-lumi/integrationpluginzigbeelumi.cpp index fc261f86..eddaf8f2 100644 --- a/zigbee-lumi/integrationpluginzigbeelumi.cpp +++ b/zigbee-lumi/integrationpluginzigbeelumi.cpp @@ -48,6 +48,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_networkUuidParamTypeIds[lumiVibrationSensorThingClassId] = lumiVibrationSensorThingNetworkUuidParamTypeId; m_networkUuidParamTypeIds[lumiPowerSocketThingClassId] = lumiPowerSocketThingNetworkUuidParamTypeId; m_networkUuidParamTypeIds[lumiRelayThingClassId] = lumiRelayThingNetworkUuidParamTypeId; + m_networkUuidParamTypeIds[lumiRemoteThingClassId] = lumiRemoteThingNetworkUuidParamTypeId; m_zigbeeAddressParamTypeIds[lumiHTSensorThingClassId] = lumiHTSensorThingIeeeAddressParamTypeId; m_zigbeeAddressParamTypeIds[lumiButtonSensorThingClassId] = lumiButtonSensorThingIeeeAddressParamTypeId; @@ -58,6 +59,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_zigbeeAddressParamTypeIds[lumiVibrationSensorThingClassId] = lumiVibrationSensorThingIeeeAddressParamTypeId; m_zigbeeAddressParamTypeIds[lumiPowerSocketThingClassId] = lumiPowerSocketThingIeeeAddressParamTypeId; m_zigbeeAddressParamTypeIds[lumiRelayThingClassId] = lumiRelayThingIeeeAddressParamTypeId; + m_zigbeeAddressParamTypeIds[lumiRemoteThingClassId] = lumiRemoteThingIeeeAddressParamTypeId; m_connectedStateTypeIds[lumiHTSensorThingClassId] = lumiHTSensorConnectedStateTypeId; m_connectedStateTypeIds[lumiButtonSensorThingClassId] = lumiButtonSensorConnectedStateTypeId; @@ -68,6 +70,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_connectedStateTypeIds[lumiVibrationSensorThingClassId] = lumiVibrationSensorConnectedStateTypeId; m_connectedStateTypeIds[lumiPowerSocketThingClassId] = lumiPowerSocketConnectedStateTypeId; m_connectedStateTypeIds[lumiRelayThingClassId] = lumiRelayConnectedStateTypeId; + m_connectedStateTypeIds[lumiRemoteThingClassId] = lumiRemoteConnectedStateTypeId; m_versionStateTypeIds[lumiHTSensorThingClassId] = lumiHTSensorVersionStateTypeId; m_versionStateTypeIds[lumiButtonSensorThingClassId] = lumiButtonSensorVersionStateTypeId; @@ -78,6 +81,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_versionStateTypeIds[lumiVibrationSensorThingClassId] = lumiVibrationSensorVersionStateTypeId; m_versionStateTypeIds[lumiPowerSocketThingClassId] = lumiPowerSocketVersionStateTypeId; m_versionStateTypeIds[lumiRelayThingClassId] = lumiRelayVersionStateTypeId; + m_versionStateTypeIds[lumiRemoteThingClassId] = lumiRemoteVersionStateTypeId; m_signalStrengthStateTypeIds[lumiHTSensorThingClassId] = lumiHTSensorSignalStrengthStateTypeId; m_signalStrengthStateTypeIds[lumiButtonSensorThingClassId] = lumiButtonSensorSignalStrengthStateTypeId; @@ -88,6 +92,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_signalStrengthStateTypeIds[lumiVibrationSensorThingClassId] = lumiVibrationSensorSignalStrengthStateTypeId; m_signalStrengthStateTypeIds[lumiPowerSocketThingClassId] = lumiPowerSocketSignalStrengthStateTypeId; m_signalStrengthStateTypeIds[lumiRelayThingClassId] = lumiRelaySignalStrengthStateTypeId; + m_signalStrengthStateTypeIds[lumiRemoteThingClassId] = lumiRemoteSignalStrengthStateTypeId; // Known model identifier m_knownLumiDevices.insert("lumi.sensor_ht", lumiHTSensorThingClassId); @@ -99,6 +104,7 @@ IntegrationPluginZigbeeLumi::IntegrationPluginZigbeeLumi() m_knownLumiDevices.insert("lumi.vibration", lumiVibrationSensorThingClassId); m_knownLumiDevices.insert("lumi.plug", lumiPowerSocketThingClassId); m_knownLumiDevices.insert("lumi.relay", lumiRelayThingClassId); + m_knownLumiDevices.insert("lumi.remote", lumiRemoteThingClassId); } QString IntegrationPluginZigbeeLumi::name() const @@ -442,6 +448,47 @@ void IntegrationPluginZigbeeLumi::setupThing(ThingSetupInfo *info) } } + if (thing->thingClassId() == lumiRemoteThingClassId) { + // Since we are here again out of spec, we just can react on cluster and endpoint signals + connect(node, &ZigbeeNode::endpointClusterAttributeChanged, thing, [this, thing](ZigbeeNodeEndpoint *endpoint, ZigbeeCluster *cluster, const ZigbeeClusterAttribute &attribute){ + switch (endpoint->endpointId()) { + case 0x01: + if (cluster->clusterId() == ZigbeeClusterLibrary::ClusterIdMultistateInput && attribute.id() == ZigbeeClusterMultistateInput::AttributePresentValue) { + quint16 value = attribute.dataType().toUInt16(); + if (value == 1) { + emit emitEvent(Event(lumiRemotePressedEventTypeId, thing->id(), ParamList() << Param(lumiRemotePressedEventButtonNameParamTypeId, "1"))); + } else { + emit emitEvent(Event(lumiRemoteLongPressedEventTypeId, thing->id(), ParamList() << Param(lumiRemoteLongPressedEventButtonNameParamTypeId, "1"))); + } + } + break; + case 0x02: + if (cluster->clusterId() == ZigbeeClusterLibrary::ClusterIdMultistateInput && attribute.id() == ZigbeeClusterMultistateInput::AttributePresentValue) { + quint16 value = attribute.dataType().toUInt16(); + if (value == 1) { + emit emitEvent(Event(lumiRemotePressedEventTypeId, thing->id(), ParamList() << Param(lumiRemotePressedEventButtonNameParamTypeId, "2"))); + } else { + emit emitEvent(Event(lumiRemoteLongPressedEventTypeId, thing->id(), ParamList() << Param(lumiRemoteLongPressedEventButtonNameParamTypeId, "2"))); + } + } + break; + case 0x03: + if (cluster->clusterId() == ZigbeeClusterLibrary::ClusterIdMultistateInput && attribute.id() == ZigbeeClusterMultistateInput::AttributePresentValue) { + quint16 value = attribute.dataType().toUInt16(); + if (value == 1) { + emit emitEvent(Event(lumiRemotePressedEventTypeId, thing->id(), ParamList() << Param(lumiRemotePressedEventButtonNameParamTypeId, "1+2"))); + } else { + emit emitEvent(Event(lumiRemoteLongPressedEventTypeId, thing->id(), ParamList() << Param(lumiRemoteLongPressedEventButtonNameParamTypeId, "1+2"))); + } + } + break; + default: + qCWarning(dcZigbeeLumi()) << "Received attribute changed signal from unhandled endpoint" << thing << endpoint << cluster << attribute; + break; + } + }); + } + if (thing->thingClassId() == lumiRelayThingClassId) { // Get the 2 endpoints ZigbeeNodeEndpoint *endpoint1 = node->getEndpoint(0x01);