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
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
Just wanted to reply to your post and say thanks for the workaround, I was tearing my hair out to try to fix the issue, this workaround is a good solution.
@nir_livne Thanks for the approach to solving this. Your exact solution didn’t work for me, but I have roller shades so maybe there’s something different about mine from yours. I thought I’d share what I did in case it helps others. I renamed all of my shades in ZigbeeMQTT to add a prefix of MQTT and set them up in with Invert Cover set to True. I was having the same issue where Home Assistant would show Closed when the Cover was open and vice versa. In my template, I simply override close_cover and over_cover to reverse the buttons and the open/close state of the Cover. I now use this template cover in my Automations, Dashboards, and to share with Alexa through emulated Hue and everything works as expected.
Here is my template
cover:
- platform: template
covers:
office_blind:
device_class: shade
friendly_name: "Office Blind"
# just take the current position of the MQTT version as the position since it's already inverted there.
position_template: >-
{{ state_attr('cover.mqtt_office_blind', 'current_position') | int }}
# The following reverses the behavior of the up/down buttons and Closed/Open
open_cover:
- condition: numeric_state
entity_id: cover.mqtt_office_blind
attribute: current_position
below: 100
- action: cover.close_cover
target:
entity_id: cover.mqtt_office_blind
close_cover:
- condition: numeric_state
entity_id: cover.mqtt_office_blind
attribute: current_position
above: 0
- action: cover.open_cover
target:
entity_id: cover.mqtt_office_blind
# For stop and set cover position, just send theseon to the MQTT version
stop_cover:
action: cover.stop_cover
target:
entity_id: cover.mqtt_office_blind
set_cover_position:
action: cover.set_cover_position
target:
entity_id: cover.mqtt_office_blind
data:
position: "{{ position }}"
# When the shade is completely open, use the blinds-open icon
icon_template: >-
{% if state_attr('cover.mqtt_office_blind' , 'current_position') | int > 99 %}
mdi:blinds-open
{% endif %}
optimistic: false