MQTT Sensor good - Switch not working

I need some help here because I looked at this now trillion times but I cant get there error.

I want to control a switch and a sensor via MQTT.

This is my mqtt related part in the configuration

  broker: mqtt.domain.lcl
  - platform: yr
  - platform: mqtt
    name: "Stimmung"
    state_topic: "house/hagen/mood"

 - platform: mqtt
   name: 'dash'
   command_topic: 'house/switch/dash/set'
   state_topic: 'house/switch/dash/status'
   payload_on: "1"
   payload_off: "0"
   retain: true
   optimistic: false

Both items show up on the HA Dashboard. The sensor is working but for the switch HA does not recognize the mqtt message

 mosquitto_pub -h -t "house/hagen/mood" -m "bad"
 EBUG:homeassistant.components.mqtt:Received message on house/hagen/mood: bad

 mosquitto_pub -h -t "house/switch/dash/set" -m "1"

no result in HA Log or on the dashboard.

Both messages show up on the mqtt bus
Any ideas what I do wrong?

try removing the state_topic from the switch configuration and see if it works.

HA doesn’t subscribe to the command_topic: so wouldn’t see any messages being published to that topic in HA. If you publish to the state_topic: you should see something.



mosquitto_pub -h -t "house/switch/dash/status" -m 1
mosquitto_pub -h -t "house/switch/dash/status" -m 0

is the way to go.
Thank you