A: The switch must have a state that goes ON when you switch / press it, and then when you switch / press it again the state goes OFF. If you have a push button that goes ON/OFF in one press and when you press it again it will go ON/OFF then I have a different Blueprint called Push Button Relay - Contactor. It works the same as this blueprint but the trigger is different.
Q: Can I put the same entity into the normally open & normally closed fields?
A: No, you must only choose one field, normally open or normally closed per entity.
How can this handle dual input switches?
Switch 1: Shelly running in detached mode, this works fine by itself
Switch 2: EP1 showing presence as (Detected/Clear)
Then I have 2 separate inputs that I would like to control them from.
The first is a wall switch that is exposed to HA, with ON/OFF.
The second is mmWave presence, this reports Detected/Clear.
At the moment I have your blueprint working only with the switch, but without the mmWave.
Using the blueprint without adding lots of extra logic would be great as I will need to replicate it for each room.
In the sensor light blueprint, your MMWave would be the trigger and your wall switch would be the by-pass. For by-pass selection you would select “Enable the By-pass - Turn lights ON”. Then you would just add all your lights in as entities.
Code Update - This is a major code and blueprint update. It will break your existing blueprint. Hopefully this is a lot cleaner & will survive a HA restart. Sorry it had to be done.
If you like this blueprint? Consider hitting the button in the top post
If you like my blueprints, and would like to show your support or just say thank you? Click Here
Some work is required in this upgrade. Please see below on the steps when upgrading. It is easy and not a breaking change.
New Feature
Switch - You can add as many switches as you like. If any switch is ON it will turn ON the main entity. All switches must be OFF to turn OFF the main entity.
Why multiple switches? I use this to control my WLED lights transformer. WLED has a feature for adding in a relay but you have to wire it all up etc. What I do is add all my lights (In WLED it is call segments) into the switch. In the main entity I add my smart plug (plug my transformer into smart plug) and the main switch for WLED. The transformer feeds the LED’s not the ESP32 and I have another cable (USB C) supplying the ESP32 so everything is available in HA 24/7. Now when any light is turned ON, it turns on the main entities that are my smart plug (transformer) and WLED main switch and the lights turn ON. When all the light are turned OFF the transformer and WLED main switch is turned OFF.
Why do this? Because even though the LED lights are turned OFF they still draw power. This way they only draw power when they are turned ON
You can do other things with it but this is one example.
STEPS REQUIRED WHEN UPGRADING
1 - Upgrade your blueprint.
2 - Go into your automation (the ones using this blueprint). You will see the switch has a missing input.
Not sure what you are referring to. We use this to turn on our transformers for our LED lighting so power is not used when the LED lights are OFF and it works. Maybe if you can give us some more information so we can look at it.
I found a solution to my problem. I modified the code that you posted. The idea is that when the first switch is working, the second switch should be turned off, and when the electricity goes out and then comes back on, the second switch should turn off automatically after a short period because the first switch in on .
blueprint:
name: Switch - Turn ON & OFF Entities
description: "# \U0001F51B Switch - Turn ON & OFF Entities\n**Version: 1.3**\n\nLet us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/switch-turn-on-off-entities/481546)\n\n**The Automation Process:**\n - When you turn any switch ON it will turn ON the main entity input.\n - When you turn all the switches OFF it will turn OFF the main entity input.\n - You have the option to input an alternating entity that will be the opposite state to the main entity when the switch is ON.\n\n**NOTE** - The switch can be any entity with an ON & OFF state.\n\nRequired = *\n\nNeed help? See our FAQ: [Click Here](https://community.home-assistant.io/t/switch-turn-on-off-entities/481546/2?u=blacky)\n\n**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) \U0001F642\n"
domain: automation
input:
switch:
name: Switch *
description: The switch that controls the entities.
selector:
entity:
multiple: true
main_entity:
name: Main Entity *
description: The main entity that will be turned ON when the switch is ON.
selector:
entity:
multiple: true
alternating_entity:
name: Alternating Entity (optional)
description: The alternating entity that will be the opposite state to the main entity when the switch is ON.
default: []
selector:
entity:
multiple: true
source_url: https://gist.github.com/Blackshome/dbcd8ebfdd0350144fc1503fc0fa8112
variables:
switch: !input switch
main_entity: !input main_entity
alternating_entity: !input alternating_entity
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: !input switch
from: 'off'
to: 'on'
- platform: state
entity_id: !input switch
from: 'on'
to: 'off'
for:
milliseconds: 200
- platform: state
entity_id: !input main_entity
from: 'off'
to: 'on'
- platform: state
entity_id: !input main_entity
from: 'on'
to: 'off'
for:
milliseconds: 200
action:
- choose:
- alias: Check if any alternating entity is entered
conditions:
- '{{ alternating_entity == [] }}'
sequence:
- choose:
- alias: Check if switch is on
conditions:
- condition: state
entity_id: !input switch
state: 'on'
match: any
sequence:
- alias: Turn OFF the main entities
service: homeassistant.turn_off
target:
entity_id: !input main_entity
default:
- choose:
- alias: Check if switch is on
conditions:
- condition: state
entity_id: !input switch
state: 'on'
match: any
sequence:
- alias: Turn OFF the main entities
service: homeassistant.turn_off
target:
entity_id: !input main_entity
- alias: Turn OFF the alternating entity entities
service: homeassistant.turn_off
target:
entity_id: !input alternating_entity
Hey Blacky,
thanks for the blueprint! I have a feature request. Not sure which of your template fits best, but my request is that turning on and off should be limited to a specific number of times per hour.
I have a recirculator that should be started a couple of times per hour and I was wondering how to achieve that using your templates. I believe it’s a good use case for this one, so before I started writing something on my own, I wondered if you are interested in adding it as a feature.
Here’s the manual information that should make better sense than me:
Switch-on/off procedures via mains voltage ≤ 100/24 h.
≤ 20/h for a switching frequency of 1 minute between switching on/off via mains voltage.
This seams like a unique use case. I not really understanding what you are doing but I understand that you would like to to turn ON and OFF a couple times per hour. If this is just on a time base then you could create a schedule helper and set the times you would like it ON and OFF throughout the day. Then use that schedule helper in the Switch to turn ON / OFF what you would like.
To create a schedule helper go to settings > device & services > helpers tab at top > create helper button > schedule then set the times you would like.