S
S
Stan_12021-11-09 09:18:01
Smart House
Stan_1, 2021-11-09 09:18:01

Should HASS MQTT-switch switch if state-topic is changed?

The second day I can not deal with mqtt-switch. Set up switch like this:

- platform: mqtt
  command_topic: "koridor/light/main/set"
  state_topic: "koridor/light/main/state"
  name: light_koridor_main
  payload_on: 1
  payload_off: 0
  state_on: 1
  state_off: 0
  qos: 0
  optimistic: false


When I click on the switch in the UI, everything is fine. I see a change in the topic koridor/light/main/set in the MQTT broker, after a second - a change in the topic koridor/light/main/state. Things are good. But sometimes corridor/light/main/state changes without UI, through external control. I expect that if I change koridor/light/main/state, then the switch will change in the UI (become enabled), and koridor/light/main/set will change, which will become equal to koridor/light/main/state.

But I see a strange situation. Indeed, the engine itself in the UI changes, the light "lights up" and turns yellow. But in the MQTT broker, the topic koridor/light/main/set remains the same.

So the question is, is this normal behavior? Or am I not understanding something? Or is it necessary to fence a complex construction from a template switch and artificially publish data to the koridor/light/main/set through the mqtt.publish service?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
whitefooot, 2022-04-06
@whitefooot

I'm afraid it's not relevant anymore, but I'll answer the question anyway.
The behavior is completely normal.
Device status should only be viewed in the status topic. In a management topic, you should not expect any changes when the state changes, it serves only for management and only for it. In other words, the desired state is sent to the topic for management, the actual state is taken from the state topic.
If you track changes in the koridor/light/main/set topic, then this is incorrect, you need to rely on the koridor/light/main/state topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question