Skip to content

Improve ZNCLBL01LM support #5104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 17, 2022
Merged

Conversation

mandrean
Copy link
Contributor

@mandrean mandrean commented Dec 7, 2022

New features:

  • Calibrating limits (start, end, reset)
  • Opening/closing hooks
  • Enabling/disabling "pull to open/close"

@mandrean mandrean force-pushed the ZNCLBL01LM_converters branch 2 times, most recently from ef5a09b to f3187ad Compare December 8, 2022 02:24
- Refactor converters
- Clearing limits calibration
- Opening/closing hooks
- Enabling/disabling "pull to open/close"
@mandrean mandrean force-pushed the ZNCLBL01LM_converters branch from f3187ad to 66018ba Compare December 8, 2022 02:26
@mandrean mandrean force-pushed the ZNCLBL01LM_converters branch from 66018ba to e272344 Compare December 8, 2022 02:37
@mandrean mandrean force-pushed the ZNCLBL01LM_converters branch from 3b69f6b to 32d6ee5 Compare December 8, 2022 03:06
.withDescription('Hooks state'),
exposes.enum('motor_state', ea.STATE, ['stopped', 'opening', 'closing', 'pause']).withDescription('Motor state'),
exposes.binary('running', ea.STATE, true, false).withDescription('Whether the motor is moving or not'),
exposes.enum('hooks_action', ea.SET, ['unlock', 'lock']).withDescription('Hooks action'),
Copy link
Owner

@Koenkk Koenkk Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to change this to action and rename the unlock/lock to hooks_unlock/hooks_lock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that collide somehow with the existing read-only field also called action?

Skärmavbild 2022-12-09 kl  01 51 18

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, since action is not a state (something that has to be persisted).

convertGet: async (entity, key, meta) => {
await entity.read('aqaraOpple', [0x040B], manufacturerOptions.xiaomi);
ZNCLBL01LM_action: {
key: ['action'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just see now that this a settable thing, then action should not be used, my apologies.

Can we rename this to hooks_lock and then accept the values LOCK and UNLOCK?

We can then use the following expose:

exposes.binary('hooks_lock', ea.STATE_SET, 'LOCK', 'UNLOCK').withDescription('Lock the curtain hooks'),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better now?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, I added one more improvement to also have the hooks_lock present in the state. It also changes based on the hooks_action now. Can you check if it works correctly? If yes then this can be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Koenkk Works great!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you get motor_state even when it isn't running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this when its not running:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And when it runs:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this when its not running:

image

Nah, still the same issue in MQTT log:

2023-01-02 10:20:00.421 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on zigbee2mqtt/Bedroom Curtain Left: b'{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}'
2023-01-02 10:20:00.424 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'switch.bedroom_curtain_left_hand_open', 'name': 'Bedroom Curtain Left hand_open', 'this': <template TemplateStateFromEntityId(switch.bedroom_curtain_left_hand_open)>} and Template("{% if value_json.hand_open %} true {% else %} false {% endif %}")
2023-01-02 10:20:00.425 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_battery', 'name': 'Bedroom Curtain Left battery', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_battery)>} with default value 'default' and Template("{{ value_json.battery }}")
2023-01-02 10:20:00.427 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_device_temperature', 'name': 'Bedroom Curtain Left device temperature', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_device_temperature)>} with default value 'default' and Template("{{ value_json.device_temperature }}")
2023-01-02 10:20:00.428 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_action', 'name': 'Bedroom Curtain Left action', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_action)>} with default value 'default' and Template("{{ value_json.action }}")
2023-01-02 10:20:00.430 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_motor_state', 'name': 'Bedroom Curtain Left motor state', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_motor_state)>} with default value 'default' and Template("{{ value_json.motor_state }}")
2023-01-02 10:20:00.430 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'motor_state' when rendering '{{ value_json.motor_state }}'
2023-01-02 10:20:00.435 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_hooks_state', 'name': 'Bedroom Curtain Left hooks state', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_hooks_state)>} with default value 'default' and Template("{{ value_json.hooks_state }}")
2023-01-02 10:20:00.435 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_target_position', 'name': 'Bedroom Curtain Left target position', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_target_position)>} with default value 'default' and Template("{{ value_json.target_position }}")
2023-01-02 10:20:00.436 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'sensor.bedroom_curtain_left_power_source', 'name': 'Bedroom Curtain Left power source', 'this': <template TemplateStateFromEntityId(sensor.bedroom_curtain_left_power_source)>} with default value 'default' and Template("{{ value_json.power_source }}")
2023-01-02 10:20:00.436 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'select.bedroom_curtain_left_hooks_lock', 'name': 'Bedroom Curtain Left hooks lock', 'this': <template TemplateStateFromEntityId(select.bedroom_curtain_left_hooks_lock)>} and Template("{{ value_json.hooks_lock }}")
2023-01-02 10:20:00.436 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'binary_sensor.bedroom_curtain_left_running', 'name': 'Bedroom Curtain Left running', 'this': <template TemplateStateFromEntityId(binary_sensor.bedroom_curtain_left_running)>} and Template("{{ value_json.running }}")
2023-01-02 10:20:00.436 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'binary_sensor.bedroom_curtain_left_charging', 'name': 'Bedroom Curtain Left charging', 'this': <template TemplateStateFromEntityId(binary_sensor.bedroom_curtain_left_charging)>} and Template("{{ value_json.charging }}")
2023-01-02 10:20:00.437 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'binary_sensor.bedroom_curtain_left_update_available', 'name': 'Bedroom Curtain Left update available', 'this': <template TemplateStateFromEntityId(binary_sensor.bedroom_curtain_left_update_available)>} and Template("{{ value_json['update']['state'] == "available" }}")
2023-01-02 10:20:00.437 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'position_open': 100, 'position_closed': 0, 'tilt_min': 0, 'tilt_max': 100, 'entity_id': 'cover.bedroom_curtain_left', 'name': 'Bedroom Curtain Left', 'this': <template TemplateStateFromEntityId(cover.bedroom_curtain_left)>} and Template("{{ value_json.position }}")
2023-01-02 10:20:00.437 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'update.bedroom_curtain_left', 'name': 'Bedroom Curtain Left', 'this': <template TemplateStateFromEntityId(update.bedroom_curtain_left)>} and Template("{{ value_json['update']['installed_version'] }}")
2023-01-02 10:20:00.437 DEBUG (MainThread) [homeassistant.components.mqtt.update] Non-dictionary JSON payload detected after processing payload '6168' on topic zigbee2mqtt/Bedroom Curtain Left
2023-01-02 10:20:00.438 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"action":null,"battery":100,"charging":false,"device_temperature":19,"hand_open":null,"hooks_lock":"UNLOCK","hooks_state":"unlocked","last_seen":"2023-01-02T09:20:00.397Z","linkquality":255,"position":83,"power_outage_count":7,"power_source":"battery","running":false,"state":"OPEN","target_position":83,"update":{"installed_version":6168,"latest_version":6168,"state":"idle"},"update_available":false,"voltage":3000}' with variables {'entity_id': 'cover.bedroom_curtain_left', 'name': 'Bedroom Curtain Left', 'this': <template TemplateStateFromEntityId(cover.bedroom_curtain_left)>} and Template("{{ value_json.motor_state if value_json.motor_state and value_json.motor_state != 'stopped' else value_json.state }}")

@mandrean mandrean force-pushed the ZNCLBL01LM_converters branch from 93a5ed0 to 6be390d Compare December 14, 2022 19:36
@mandrean mandrean requested a review from Koenkk December 15, 2022 09:05
@Koenkk Koenkk merged commit 4793794 into Koenkk:master Dec 17, 2022
@Koenkk
Copy link
Owner

Koenkk commented Dec 17, 2022

Thanks!

@mandrean mandrean deleted the ZNCLBL01LM_converters branch December 17, 2022 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants