Fix state when controlling brightness via brightness_percent. https://github.com/Koenkk/zigbee2mqtt/issues/902

This commit is contained in:
Koen Kanters
2019-01-21 18:02:50 +01:00
parent 86f19affa1
commit fcfeac81e4
+2 -2
View File
@@ -163,10 +163,10 @@ class DevicePublish {
(error, rsp) => {
// Devices do not report when they go off, this ensures state (on/off) is always in sync.
if (entity.type === 'device' && topic.type === 'set' &&
!error && (key.startsWith('state') || key === 'brightness')) {
!error && (key.startsWith('state') || key.startsWith('brightness'))) {
const msg = {};
const _key = topic.postfix ? `state_${topic.postfix}` : 'state';
msg[_key] = key === 'brightness' ? 'ON' : json['state'];
msg[_key] = key.startsWith('brightness') ? 'ON' : json['state'];
this.publishDeviceState(device, msg, true);
}