seba
(Seb)
February 27, 2019, 10:27pm
1
Hello
I have many RF light switches using RF1 for ON and RF2 for off. So I’d need to copy and paste the following code many times changing only three parameters: name, payload_on and payload_off. Any better way ?
thanks
light:
- platform: mqtt
name: "entrance"
command_topic: cmnd/bridge/rfcode
availability_topic: "tele/bridge/LWT"
payload_available: "Online"
payload_not_available: "Offline"
payload_on: "#71D3A1"
payload_off: "#71D3A2"
optimistic: true
state_topic: "tele/bridge/RESULT"
state_value_template: '#{{value_json.RfReceived.Data}}'
seba
(Seb)
February 27, 2019, 10:55pm
3
yes, that is what I was trying:
bridgeSwitch: &bridgeSwitch
platform: mqtt
command_topic: cmnd/bridge/rfcode
availability_topic: "tele/bridge/LWT"
payload_available: "Online"
payload_not_available: "Offline"
optimistic: true
state_topic: "tele/bridge/RESULT"
state_value_template: '#{{value_json.RfReceived.Data}}'
light:
- <<: *bridgeSwitch
name: "entrance"
payload_on: "#71D3A1"
payload_off: "#71D3A2"
but I’m getting
Configuration invalidCHECK CONFIG
Component not found: bridgeSwitch
so I’m assuming that HA doesn’t allow objects not supported (?) (bridgeSwitch)
seba
(Seb)
February 27, 2019, 11:19pm
4
ok, here a “partial solution”… not sure it is the best but it is better than nothing
light:
- &bridgeSwitch
platform: mqtt
command_topic: cmnd/bridge/rfcode
availability_topic: "tele/bridge/LWT"
payload_available: "Online"
payload_not_available: "Offline"
optimistic: true
retain: true
state_topic: "tele/bridge/RESULT"
state_value_template: '#{{value_json.RfReceived.Data}}'
name: "entrance"
payload_on: "#71D3A1"
payload_off: "#71D3A2"
- <<: *bridgeSwitch
name: "porch"
payload_on: "#71D3A4"
payload_off: "#71D3A8"
I was just basically typing out exactly that. Not sure why you think it’s a partial solution, it does exactly what you want.
1 Like
seba
(Seb)
March 8, 2019, 8:06am
7
True, it works… i said “partial” as I was trying to put the common configurations in some other file to keep things more tidy . For example , the light part of the mqtt could be used also in the switch file …