Hello. I’m trying to add a custom switch via the python code (not the configuration file). I currently have the following code:
attributes = {"platform" : "mqtt", "assumed_state" : True , "name" : "Bedroom Switch", "state_topic" : "home/bedroom/switch1", "command_topic" : "home/bedroom/switch1/set", "payload_on:" : "ON", "payload_off" : "OFF", "optimistic" : False, "qos" : 0, "retain" : True, "value_template" : "{{ value.x }}"}
hass.states.set("switch.coded_switch", "off", attributes)
This works completely, but in the Home Assistant UI the “Coded Switch” does not turn up as a switch. It has all the attributes, but it shows up just in state “Off”, where I wanted it to be a switch that’s off.
Thanks in advance for helping!