Cover not reporting position correctly

I programmed a cover using Arduino on a esp8266. The cover post to MQTT this config:

device_class: shade
name: Rho1 Cover
unique_id: rho1_cover
device:
  identifiers: rho1
  name: rho1
  model: PLATFORMIO_D1_MINI
  manufacturer: espressif
availability_topic: homeassistant/binary_sensor/connectivity/rho1/out
command_topic: homeassistant/cover/rho1/in
set_position_topic: homeassistant/cover/rho1/in
position_topic: homeassistant/cover/rho1/out
json_attributes_topic: homeassistant/cover/rho1/out
json_attributes_template: '{{ value_json.position | tojson }}'
payload_open: '0'
payload_close: '100'
value_template: '{{ value_json.position }}'
platform: mqtt

On MQTT I can see
out={ “set”:79, “position”:79 }

On the dashboard I use a
type: custom:slider-entity-row

On HA everything works perfect except showing the current position. When I open the dashboard, the slider is always at 0. Also if I check history it always shows Unknow as the state.

I think my MQTT config is not good, or maybe I should use 2 different topics for the set and position info, I can change my Arduino code, so maybe suggest the ideal MQTT I should use and I would change my code to follow along.

Use position_template to extract the actual position from the payload, e.g.

 position_template: '{{ value_json.position }}'

value_template should return open, closed, opening… i.e. the state of the cover.

1 Like