Hi, I need some help with a MQTT switch where the state keeps going to off when you click the switch. I have been trying different solutions for weeks now and combing through the forum and Youtube.
So here is what I have set / happens.
* THE PROBLEM
When I toggle the switch for my pool pump (Sonoff POWR2 with Tasmota) the pump turns on and remains on while the switch in homeassistant turns to the off state after a second. If I double click the switch in HA quickly, the pump will turn off. So in short the issue seems to only be with the state of the switch.
* THE CONFIG / INFO
- I am running the latest version of HASS.IO and I have installed the Mosquitto broker via the addon section.
- I have configured numerous (light mqtt: - platform: mqtt) switches (The Sonoff TX ones also with Tasmota) and these are working fine or as I would expect.
###################################
# MQTT LIGHTS SECTION #
###################################
light mqtt:
- platform: mqtt
name: "Pool Light"
state_topic: "pool_light/stat/POWER"
command_topic: "pool_light/cmnd/POWER"
payload_on: "ON"
payload_off: "OFF"
- My broker section of the configuration.yaml looks like this:
###################################
# MQTT BROKER SECTION #
###################################
mqtt:
broker: 127.0.0.1
port: 1883
client_id: 2WLS-HA
username: mqtt
password: mypassword
# discovery: false
# discovery_prefix: homeassistant
- And my switch (not working) section of the configuration.yaml looks like this:
###################################
# MQTT SWITCHES SECTION #
###################################
switch:
- platform: mqtt
name: "Pool Pump"
state_topic: "poolpump/stat/POWER"
command_topic: "poolpump/cmnd/POWER"
payload_on: ON
payload_off: OFF
- If I listen to the state topic via the Dev Tools/MQTT section, I can see that the broker is communicating to and from the switch. These messages are successfully posted if I use the switches on either the homeassistant or the sonoff web page.
Listen to a topic
Listening to
poolpump/stat/POWER
Message 0 received on poolpump/stat/POWER at 9:46 AM:
ON
QoS: 0 - Retain: true
I have also reset my config and started again but ended at the same result, so I do not believe its a typo. The next step would have been to pull in the power usage for the pool pump and add some automation around that but if I cant even get the switch to work correctly 0_o …
Thank you in advance for any assistance