Hi,
I’m sure this is an easy one for someone. I’m trying to add more than one switch in the light switch platform but all the methods to add a second switch have failed.can someone tell me the right way to do it?
Thanks
Hi,
I’m sure this is an easy one for someone. I’m trying to add more than one switch in the light switch platform but all the methods to add a second switch have failed.can someone tell me the right way to do it?
Thanks
Do you have any example code?
I am guessing you might be doing something like:
light:
- platform: mqtt
name: "KitchenCupboards"
state_topic: "stat/sonoffKit/POWER1"
command_topic: "cmnd/sonoffKit/POWER1"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
light:
- platform: mqtt
name: "KitchenCeiling"
state_topic: "stat/sonoffKit/POWER2"
command_topic: "cmnd/sonoffKit/POWER2"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
But you need to have it like:
light:
- platform: mqtt
name: "KitchenCupboards"
state_topic: "stat/sonoffKit/POWER1"
command_topic: "cmnd/sonoffKit/POWER1"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
- platform: mqtt
name: "KitchenCeiling"
state_topic: "stat/sonoffKit/POWER2"
command_topic: "cmnd/sonoffKit/POWER2"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
You also could do it like this, but I prefer the first option:
light 1:
- platform: mqtt
name: "KitchenCupboards"
state_topic: "stat/sonoffKit/POWER1"
command_topic: "cmnd/sonoffKit/POWER1"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
light 2:
- platform: mqtt
name: "KitchenCeiling"
state_topic: "stat/sonoffKit/POWER2"
command_topic: "cmnd/sonoffKit/POWER2"
availability_topic: "tele/sonoffKit/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
Hi Will,
It’s the light switch platform
light:
- platform: switch
name: Christmas Tree Lights
entity_id: switch.christmas_tree_lights
How are you adding the additional ones?
Do the switches work OK before adding them as lights?
Then you should be able to define extra lights like so:
light:
- platform: switch
name: Christmas Tree Lights
entity_id: switch.christmas_tree_lights
- platform: switch
name: Thermonuclear War Launch
entity_id: switch.thermonuclear_war_launch
Thanks Tom, I had not tried that! Works great!
I presume it is not possible to simplify the code further? I was thinking since all the light’s platforms are switches, it would be nice to somehow indicate that outside the list and apply to all, ie:
light:
platform: switch
- name: Christmas Tree Lights
entity_id: switch.christmas_tree_lights
- name: Thermonuclear War Launch
entity_id: switch.thermonuclear_war_launch