Configure on_level via config #14779
Wireheadbe
started this conversation in
Devices
Replies: 1 comment 2 replies
-
I'm guessing it needs another branch here to restore on_level too /~https://github.com/Koenkk/zigbee-herdsman-converters/blob/e4317cc8704211e8a56b3cc98da4f25580fafc33/devices/ikea.js#L19 Probably replacing the function with this one should work. const bulbOnEvent = async (type, data, device, options, state) => {
/**
* IKEA bulbs lose their configured reportings when losing power.
* A deviceAnnounce indicates they are powered on again.
* Reconfigure the configured reoprting here.
*
* Additionally some other information is lost like
* color_options.execute_if_off. We also restore these.
*
* NOTE: binds are not lost so rebinding is not needed!
*/
if (type === 'deviceAnnounce') {
for (const endpoint of device.endpoints) {
for (const c of endpoint.configuredReportings) {
await endpoint.configureReporting(c.cluster.name, [{
attribute: c.attribute.name, minimumReportInterval: c.minimumReportInterval,
maximumReportInterval: c.maximumReportInterval, reportableChange: c.reportableChange,
}]);
}
}
// NOTE: execute_if_off default is false
// we only restore if true, to save unneeded network writes
if (state !== undefined && state.color_options !== undefined && state.color_options.execute_if_off === true) {
device.endpoints[0].write('lightingColorCtrl', {'options': 1});
}
if (state !== undefined && state.level_config !== undefined && state.level_config.execute_if_off === true) {
device.endpoints[0].write('genLevelCtrl', {'options': 1});
}
if (state !== undefined && state.level_config !== undefined && state.level_config.on_level !== undefined) {
let onLevel = state.level_config.on_level;
if (typeof onLevel === 'string' && onLevel.toLowerCase() == 'previous') {
onLevel = 255;
} else {
onLevel = Number(onLevel);
}
if (onLevel > 255) onLevel = 254;
if (onLevel < 1) onLevel = 1;
device.endpoints[0].write('genLevelCtrl', {onLevel});
}
}
}; I'm away from my dev setup at the moment so I didn't test this code. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
Question - I've got a bunch of Ikea lights, but when they lose power, they lose the following configured parameter - and revert to "previous":
Is there a way this parameter can be configured for devices, upon start-up of zigbee2mqtt? It's a very handy setting to be able to control from the start, as it improves the way adaptive lighting works.
Beta Was this translation helpful? Give feedback.
All reactions