Hello,
this is my first discussion here even if I’m using Home Assistant since some years.
I’ve faced an issue today with my shelly 2.5 used for a cover, seems that home assistant entity is not updated correctly even if MQTT message contains the updated value.
This misalignment always happens when shelly reboots, the reboot sometimes happens when moving cover with manual switches so the “real cover position” is different than what home assistant shows.
I thought that the issue was related to what shelly publishes to MQTT, but today I’ve investigated deeply and I can state that shelly works correct, the issue is in HA, here are my checks.
This is my mqtt cover (I know I’ll move away from yaml, I’ll do next months):
cover:
- platform: mqtt
unique_id: "camera_matr.finestra"
name: "Finestra Camera matr."
command_topic: "shellies/tapp/camera_matr/fin/roller/0/command"
position_topic: "shellies/tapp/camera_matr/fin/info"
#position_topic: "shellies/tapp/camera_matr/fin/info"
#position_template: "{{ value_json.rollers[0].current_pos }}"
position_topic: "shellies/tapp/camera_matr/fin/roller/0/pos"
position_template: "{{ value }}"
set_position_topic: "shellies/tapp/camera_matr/fin/roller/0/command/pos"
availability_topic: "shellies/tapp/camera_matr/fin/online"
payload_available: "true"
payload_not_available: "false"
retain: false
payload_open: "open"
payload_close: "close"
payload_stop: "stop"
position_open: 100
position_closed: 15
optimistic: false
qos: 0
The main point is “position_topic” and “position_template”, I’ve tested two way to get the current position but no one works.
Using the MQTT dump service for both position_topic I get:
- “info” topic
shellies/tapp/camera_matr/fin/info,{"wifi_sta":{"connected":true,"ssid":"my_ssid","ip":"my_ip","rssi":-72},"cloud":{"enabled":false,"connected":false},"mqtt":{"connected":true},"time":"08:18","unixtime":1656055080,"serial":4,"has_update":false,"mac":"mac_addr","cfg_changed_cnt":0,"actions_stats":{"skipped":0},"rollers":[{"state":"stop","source":"input","power":0.00,"is_valid":true,"safety_switch":false,"overtemperature":false,"stop_reason":"normal","last_direction":"close","current_pos":22,"calibrating":false,"positioning":true}],"meters":[{"power":0.00,"overpower":0.00,"is_valid":true,"timestamp":1656058680,"counters":[0.000, 0.000, 0.000],"total":0},{"power":0.00,"overpower":0.00,"is_valid":true,"timestamp":1656058680,"counters":[0.000, 0.000, 0.000],"total":0}],"inputs":[{"input":0,"event":"","event_cnt":0},{"input":0,"event":"","event_cnt":0}],"temperature":49.50,"overtemperature":false,"tmp":{"tC":49.50,"tF":121.11, "is_valid":true},"temperature_status":"Normal","update":{"status":"idle","has_update":false,"new_version":"20220209-093016/v1.11.8-g8c7bb8d","old_version":"20220209-093016/v1.11.8-g8c7bb8d"},"ram_total":49920,"ram_free":36808,"fs_size":233681,"fs_free":144325,"voltage":237.87,"uptime":38362}
to extract the current_pos I’ve used the following template, tested on developer’s template tab
{{ value_json.rollers[0].current_pos }}
using this template on developer’s tab with the same son gives me the correct value “22”, but using into yaml it gives a different value ( 8 )
- “roller/0/pos” topic
the dump is :
shellies/tapp/camera_matr/fin/roller/0/pos,22
when testing in developer mode the template position_template: "{{ value }}"
I get 22, using it into yaml configuration I get again a different value ( 8 again).
After every yaml changes I’ve reloaded MQTT and template configuration from settings, but it never worked.
Even restarting HA does not solve.
EDIT: the only way to “solve” this issue is to completely open the cover, so the value 100% in HA is aligned to the real cover position.
Is it a configuration issue ?
What’s wrong ?
I’m using Home Assistant docker image 2022.6.6 .
Thank you all and sorry for this long first topic