Hi,
I use zigbee2mqtt with my tuya cover switch and it used to work
I noticed that the state reported by zigbee2mqtt
is opposite to the state HA report
Any ideas how to fix it?
In the case below, the cover is fully open
z2m state is “OPEN”
while HA state is “closed”
using the “invert_cover” settings, invert the state for both so I still get opposite values
I am using HA version 2023.04, but I think the cover state has been broken for some time. However, I’m not sure which upgrade broke it.
nir_livne
(Nir Livne)
June 14, 2023, 6:34pm
2
Anyone? This issue is very annoying
IN z2m go to settings(specific) and change invert_cover
1 Like
nir_livne
(Nir Livne)
June 15, 2023, 2:14pm
4
I already mentioned that invert_cover didn’t help
It did invert. Now I get “CLOSED and open” instead of “OPEN and closed” … still opposite states
then you may have to manually change the direction of the motor itself
nir_livne
(Nir Livne)
June 19, 2023, 6:39pm
6
I don’t see how it will help …
It feels like a software/configuration mismatch between hass and z2m
it used to work… something changed in one of the last releases
I ended up creating a new templated cover sensor
# fix my z2m cover
cover:
- platform: template
covers:
bedroom_template_cover:
device_class: shutter
friendly_name: "Bedroom shutters"
# invert the position
position_template: >-
{{ 100-state_attr('cover.z2m_tuya_curtain_bedroom', 'current_position') | int }}
# for 'opening' and 'closing' states
value_template: >-
{{ states('cover.z2m_tuya_curtain_bedroom') }}
close_cover:
- condition: numeric_state
entity_id: cover.z2m_tuya_curtain_bedroom
attribute: current_position
below: 100
- service: cover.close_cover
target:
entity_id: cover.z2m_tuya_curtain_bedroom
open_cover:
- condition: numeric_state
entity_id: cover.z2m_tuya_curtain_bedroom
attribute: current_position
above: 0
- service: cover.open_cover
target:
entity_id: cover.z2m_tuya_curtain_bedroom
stop_cover:
service: cover.stop_cover
target:
entity_id: cover.z2m_tuya_curtain_bedroom
set_cover_position:
service: cover.set_cover_position
target:
entity_id: cover.z2m_tuya_curtain_bedroom
data:
position: "{{ 100-state_attr('cover.z2m_tuya_curtain_bedroom', 'current_position') | int }}"