Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95399

Understanding state_topic

$
0
0

@sean.mcgrath wrote:

Hi all,

I would like to get state_topic working on my switch, and would love some feedback.

I have an MQTT switch that sends messages to my ESP32 Arduino board to turn irrigation valves on and off – this works fine. I would like to make it a closed loop system: have the switch receive a message that the action has been carried out, and only then would the HA dashboard show the change in state.

I have set it up so that the ESP32 sends out the MQTT confirmation when it receives the command – this also works fine. However, the HA dashboard does not react to the message at all. Here’s the part of my config:

switch:
# Arduino switches for four garden valves
  - platform: mqtt
    name: 'In1'
    state_topic: 'garden/state'
    command_topic: 'garden/valve1'
    retain: true
    state_on: '{"valve": "In1", "value": 1}'
    state_off: '{"valve": "In1", "value": 0}'
    payload_on: '{"valve": "In1", "value": 1}'
    payload_off: '{"valve": "In1", "value": 0}'
    icon: mdi:water

I’ve tried with and without the state_on / _off lines, and have restarted HA, but no luck. I’m not even sure where to look. Does anyone have tips on how to debug this?

cheers,
Sean

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95399

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>