Merge pull request #9849 from s-hadinger/zigbee_zblight_fix

Zigbee fix missing Light attribute in ZbLight
This commit is contained in:
Theo Arends 2020-11-14 11:37:31 +01:00 committed by GitHub
commit 2ff1188a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -702,14 +702,19 @@ void Z_Device::jsonLightState(Z_attribute_list & attr_list) const {
// dump all known values
attr_list.addAttribute(F("Reachable")).setBool(getReachable());
if (validPower()) { attr_list.addAttribute(F("Power")).setUInt(getPower()); }
int32_t light_mode = -1;
const Z_Data_Light & light = data.find<Z_Data_Light>(0);
if (&light != nullptr) {
if (light.validConfig()) {
light_mode = light.getConfig();
}
light.toAttributes(attr_list);
// Exception, we need to convert Hue to 0..360 instead of 0..254
if (light.validHue()) {
attr_list.findOrCreateAttribute(PSTR("Hue")).setUInt(light.getHue());
}
}
attr_list.addAttribute(F("Light")).setInt(light_mode);
}
}