Add lumi button sensor

master
Simon Stürz 2020-11-12 14:07:41 +01:00
parent 1748cdaafe
commit 07b27c2272
1 changed files with 15 additions and 0 deletions

View File

@ -402,6 +402,21 @@ void IntegrationPluginZigbeeLumi::setupThing(ThingSetupInfo *info)
});
}
if (thing->thingClassId() == lumiButtonSensorThingClassId) {
ZigbeeClusterOnOff *onOffCluster = endpoint->inputCluster<ZigbeeClusterOnOff>(ZigbeeClusterLibrary::ClusterIdOnOff);
if (onOffCluster) {
connect(onOffCluster, &ZigbeeClusterOnOff::powerChanged, thing, [this, thing](bool power){
qCDebug(dcZigbeeLumi()) << thing << "state changed" << (power ? "closed" : "open");
if (!power) {
emitEvent(Event(lumiButtonSensorPressedEventTypeId, thing->id()));
}
});
} else {
qCWarning(dcZigbeeLumi()) << "Could not find the OnOff input cluster on" << thing << endpoint;
}
}
info->finish(Thing::ThingErrorNoError);