zigbee-herdsman-converters 14.0.612 → 14.0.613

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -859,7 +859,6 @@ const converters = {
859
859
  state = meta.message.state = brightness === 0 ? 'off' : 'on';
860
860
  }
861
861
 
862
- let publishFakeOnLevel = false;
863
862
  let publishBrightness = brightness !== undefined;
864
863
  const targetState = state === 'toggle' ? (meta.state.state === 'ON' ? 'off' : 'on') : state;
865
864
  if (targetState === 'off') {
@@ -886,27 +885,17 @@ const converters = {
886
885
  // TODO: same problem as above.
887
886
  // TODO: if transition is not specified, should use device default (OnTransitionTime), not 0.
888
887
  if (transition.specified || globalStore.getValue(entity, 'turnedOffWithTransition') === true) {
889
- const levelConfig = utils.getObjectProperty(meta.state, 'level_config', {});
890
- let onLevel = utils.getObjectProperty(levelConfig, 'on_level', 0);
891
- if (onLevel === 0) {
892
- try {
893
- const attributeRead = await entity.read('genLevelCtrl', ['onLevel']);
894
- if (attributeRead !== undefined) {
895
- onLevel = attributeRead['onLevel'];
896
- }
897
- } catch (e) {
898
- // OnLevel not supported; write a 'previous' value to state to avoid re-reads
888
+ const current = utils.getObjectProperty(meta.state, 'brightness', 254);
889
+ brightness = globalStore.getValue(entity, 'brightness', current);
890
+ try {
891
+ const attributeRead = await entity.read('genLevelCtrl', ['onLevel']);
892
+ // TODO: for groups, `read` does not wait for responses. If it did, we could still issue a single
893
+ // command if all values of `OnLevel` are equal, or split into one command per device if not.
894
+ if (attributeRead !== undefined && attributeRead['onLevel'] != 255) {
895
+ brightness = attributeRead['onLevel'];
899
896
  }
900
- }
901
- if (onLevel === 0) {
902
- onLevel = 'previous';
903
- publishFakeOnLevel = true;
904
- }
905
- if (onLevel === 255 || onLevel === 'previous') {
906
- const current = utils.getObjectProperty(meta.state, 'brightness', 254);
907
- brightness = globalStore.getValue(entity, 'brightness', current);
908
- } else {
909
- brightness = onLevel;
897
+ } catch (e) {
898
+ // OnLevel not supported
910
899
  }
911
900
  // Published state might have gotten clobbered by reporting.
912
901
  publishBrightness = true;
@@ -944,9 +933,6 @@ const converters = {
944
933
  if (publishBrightness) {
945
934
  result.state.brightness = Number(brightness);
946
935
  }
947
- if (publishFakeOnLevel) {
948
- result.state.level_config = {on_level: 'previous'};
949
- }
950
936
  if (state !== null) {
951
937
  result.state.state = brightness === 0 ? 'OFF' : 'ON';
952
938
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zigbee-herdsman-converters",
3
- "version": "14.0.612",
3
+ "version": "14.0.613",
4
4
  "description": "Collection of device converters to be used with zigbee-herdsman",
5
5
  "main": "index.js",
6
6
  "files": [