MQTT cover configuration help

Hi,

I need some help with my mqtt cover setup for my blind.
I have managed to get the topic right and can control it through HA, the thing is that the state shows unknown but I want to see if it is open or closed. Guess its something to do with the value_template.
Also the position slider resets after the page is refreshed witch is annoying.

This is my config:

cover:
  - platform: mqtt
    device_class: shade
    name: 'Bedroom'
    command_topic: '/raw/esp8266/2410879/in'
    state_topic:  '/raw/esp8266/2410879/out'
    position_topic: '/raw/esp8266/2410879/in'
    set_position_topic: '/raw/esp8266/2410879/in'
    value_template: '{{ value_json.position }}'
    position_closed: 100
    position_open: 0
    payload_open: 0
    payload_close: 100
    payload_stop: (0)

This is the MQTT message that is recived:
image

image

From the docs:

position_topic

(string)(Optional)

The MQTT topic subscribed to receive cover position messages. If position_topic is set state_topic is ignored.

So remove the state_topic line.
I think your position_topic should be ‘/raw/esp8266/2410879/out’, as I assume that you read the state in the “out” topic and set the state in the “in” topic, correct?

Also the position_closed is normaly 0 and position_open normaly 100.
Remove them for testing, as these are default values.

You cannot use the same topic for incoming and outgoing messages, being the Outgoing ones, those that go from the Control to the Device and vice versa for incoming ones.

I suggest you use something like:

cover:
  - platform: mqtt
    device_class: shade
    name: 'Bedroom'
    command_topic: '/raw/esp8266/2410879/out'
    position_topic: '/raw/esp8266/2410879/pos'
    set_position_topic: '/raw/esp8266/2410879/set'
    payload_open: "0"
    payload_close: "100"
    payload_stop: "0"

incoming topics:
sate_topic (If you use position_topic will be ignored)
position_topic (position of the cover)

outgoing topics:
command_topic (control by arrows of Lovelace)
set_position_topic (control by slider-entity-row, to see thomas Lo)

value_template: ‘{{ value_json.position }}’: Do not use it unless the Device sends a message formatted in Jason to indicate the position of the cover.

payload_open and payload_close are Strings, you can use numbers or texts but always in single or double quotes

Did you guys know about this

image

just give it the cover

How should he get the position level then? Did you see the screenshot of the MQTT payload he posted?

position_topic (position of the cover)

For example, in my case I use:
position_topic: “vaalos/despacho/persiana/position”

And of course on the Device it must be published the same topic:
“vaalos/despacho/persiana/position” Every time changes the Roller Shutter (Cover) Level

Wonderful, finally! I’ve been waiting a long time for a Card like this

Then he would need to change the payload if I understand correctly, because the payload he posted is in json and he needs the value template to extract the position key:value pair.

Exactly, it is simpler.
It’s a pain in the ass to use Jason on the Device, the used library has changed incompatible and frankly for Lovelace I see no reason for use

Good to know, thanks for the clarification.

Thanks, that did the trick.

Thanks for all the answer!