I have four SwitchBot switches attached to my pool remote. The remote has on/off buttons for the lights and separate on/off buttons for the spa heater.
Currently, I have four instances in HA for the switches (Pool Lights On, Pool Lights Off, Spa Heater On, and Spa Heater Off). On/Off for each instance does the same thing, triggers the switch.
I’d light to just have a rocker On/Off so “On” triggers the SwitchBot attached to “Pool Lights On” and “Off” triggers the SwitchBot attached to “Pool Lights Off.” Same for the Spa Heater.
I’ve tried coding a “template switch” and an automation to no avail.
I’d start with a helper for pool lights and spa heater.
Go to Configuration | Helpers
Tap the ( + ADD HELPER ) button on the bottom right
Select a Toggle
Name it “Pool Lights”
Do the same for “Spa Heater”
Now you’ve got your toggles, but they don’t do anything. You need some automations as follows:
# When Pool Lights turns on, push the Switchbot for Pool Lights On
- alias: 'pool lights on'
trigger:
platform: state
entity_id: input_boolean.pool_lights
to: 'on'
action:
service: homeassistant.turn_on
entity_id: switch.switchbot_pool_lights_on
(I’m not sure how you activate a switchbot, so you might have to change those last two lines.)
Do the same thing for pool lights off, spa heater on, and spa heater off using the corresponding helpers (input_booleans) and switchbot commands.
It looks like it should work as you have it. Check the indentations. (I can’t see that from your copies.) Hint: if you use three tildes (```) before and after your copied automations, it shows exact indentation and highlights parts of text like this:
#When Spa Heater turns off, push the Switchbot for Spa Heater Off
- alias: ‘spa heater off’
trigger:
platform: state
entity_id: input_boolean.spa_heater
to: ‘off’
action:
service: homeassistant.turn_on
entity_id: switch.spa_heater_off
It appears I had the incorrect MAC address in the Config file for Spa Heater Off. Human Error!
Here is my code with the correct indentations (thanks for the tip!):
# When Pool Lights turns on, push the Switchbot for Pool Lights On
- alias: 'pool lights on'
trigger:
platform: state
entity_id: input_boolean.pool_lights
to: 'on'
action:
service: homeassistant.turn_on
entity_id: switch.pool_lights_on
# When Pool Lights turns off, push the Switchbot for Pool Lights Off
- alias: 'pool lights off'
trigger:
platform: state
entity_id: input_boolean.pool_lights
to: 'off'
action:
service: homeassistant.turn_on
entity_id: switch.pool_lights_off
# When Spa Heater turns on, push the Switchbot for Spa Heater On
- alias: 'spa heater on'
trigger:
platform: state
entity_id: input_boolean.spa_heater
to: 'on'
action:
service: homeassistant.turn_on
entity_id: switch.spa_heater_on
# When Spa Heater turns off, push the Switchbot for Spa Heater Off
- alias: 'spa heater off'
trigger:
platform: state
entity_id: input_boolean.spa_heater
to: 'on'
action:
service: homeassistant.turn_on
entity_id: switch.spa_heater_off