I am in the middle of setting up the automations in my home after finally getting almost all of my devices connected. I have an idea of how I want to handle some of the main automations, but not quite sure the best way to implement it.
I have a 3 bedroom home with with GE Z-Wave Dimmers setup in each bedroom.
Each bedroom along with the Livingroom have a mode override setup by way of input_select.
Modes are as follows:
Morning
Evening
Night
Movie
Party
Sleep
Away
Vacation
The house itself also has a mode override input_select as well.
It has one addtional value of āManualā
The idea here is that I can move every room in the house into a specific mode by changing the House Override. Likewise if the house is in one mode, an individual room can move itself into another mode by way of automation or user input.
What I am looking to do is trigger an automation based on state of 3 rooms (3 input_select values) at the same time.
I am planning on setting up the double tap feature in the GE-Dimmers for each of the bedrooms.
The double tap will put the bedroom into sleep mode.
I want to create an automation that if all 3 bedrooms move to sleep mode, the house mode moves to sleep as well.
This will trigger when the third of the three bedrooms is put into sleepā¦
automation:
trigger:
platform: state
entity_id:
- input_select.bedroom_one
- input_select.bedroom_two
- input_select.bedroom_three
to: 'Sleep'
condition:
- condition: state
entity_id: input_select.bedroom_one
state: 'Sleep'
- condition: state
entity_id: input_select.bedroom_two
state: 'Sleep'
- condition: state
entity_id: input_select.bedroom_three
state: 'Sleep'
action:
[YOUR ACTIONS]
Although, presuming you will want an automation that runs when one or more come out of āsleepā a template binary sensor that registers true if all 3 are āsleepā and false in all other cases might be more effective.
Wondering if you could point me in the right direction of making this automation a bit more complex.
Its still basically the same concept, but Id like to make the conditions dynamic. At least I think that would be the easiest way.
I want to take into account a few extra things that will change the required number of bedroom input_selects moving to the sleep state, to run the action of moving the house into sleep state.
One of the bedrooms is a guest room, so I only need this input select to be in sleep state if the guest mode is on (input_boolean.guest_mode).
Additionally Id like to track myself (device_tracker.bill) and my roommateās (device_tracker.stacey) location. IE if we are home.
So basically I am looking to build an automation that if guest mode is off, and my roommate is away it will only need my bedroom input_select moving to sleep, to change the house to sleep.
Likewise, if we are both home, but guest is off, it would require both our rooms going into sleep, but not the guest room. There are obviously a few other variations as well, but I think you get it.
I can figure out how to do this with a seperate automation for each of the variations, but I was hoping to get some help with creating a single automation to take care of this.
The logic looks sound, but I donāt know if you can add a template like that to conditions, so you might need to do it as a template condition that resolves to true or false.
Try it like that, and if it doesnāt validate let me know and Iāll try and help you get the logic rewritten in to template conditions if you need me to.
Failed config
automation:
- Invalid config for [automation]: extra keys not allowed @ data[āconditionā][0][ādata_templateā]. Got None
not a valid value for dictionary value @ data[āconditionā][0][āconditionā]. Got None. (See /config/configuration.yaml, line 103).
Not sure what you were suggesting with the template condition.
condition:
- condition: template
value_template: >
{% if is_state('device_tracker.bill', 'home') and ('input_select.master_bedroom_override', 'Sleep') %}true
{% elif is_state('device_tracker.bill', 'not_home') and ('input_select.master_bedroom_override', 'Automatic') %}true
{% else %} false {% endif %}
Question, is the ānot_homeā a real value? When not in the home state it shows as Away, but there is also a change the user could be in another of my setup zones. So does not_home mean any zone but home?
Ok figured it out. Re-wrote all three scripts then when I went to delete the old ones, I accidently left one old and deleted one new. I think I need another cup of coffee.
Ok so the checker goes through correctly now. Thanks for your help.
I have been looking for a way to do ādoes not equalā to cut down on the number of things I need to track in conditions. Does the ānot_Xā work with anything? Im not too bad at working out logic, but considering I failed spanish class 2 times back in the day, Im guessing it takes me a while to pick up on syntax.
Here is the full working automation in case someone else comes along looking to do something similar.
alias: Put The House To Sleep
trigger:
platform: state
entity_id:
- input_select.master_bedroom_override
- input_select.front_bedroom_override
- input_select.rear_bedroom_override
to: 'Sleep'
condition:
- condition: template
value_template: >
{% if is_state('device_tracker.bill', 'home') and ('input_select.master_bedroom_override', 'Sleep') %}true
{% elif is_state('device_tracker.bill', 'not_home') and ('input_select.master_bedroom_override', 'Automatic') %}true
{% else %} false {% endif %}
- condition: template
value_template: >
{% if is_state('input_boolean.guest_mode', 'on') and ('input_select.front_bedroom_override', 'Sleep') %}true
{% elif is_state('input_boolean.guest_mode', 'off') and ('input_select.front_bedroom_override', 'Automatic') %}true
{% else %} false {% endif %}
- condition: template
value_template: >
{% if is_state('device_tracker.stacey', 'home') and ('input_select.rear_bedroom_override', 'Sleep') %}true
{% elif is_state('device_tracker.stacey', 'not_home') and ('input_select.rear_bedroom_override', 'Automatic') %}true
{% else %} false {% endif %}
action:
- service: input_select.set_options
data:
entity_id: input_select.house_override
options: 'Sleep'
Hey again @anon43302295
Not sure what is going on, but my roommate is finally back home so this automation can be tested correctly, but its not working as expected.
Its moving the input_select.house_override to Sleep no matter the conditions.
I tried adding the ācondition: andā entry as shown below, but still not dice.
No matter how I change or what conditions are true/false it always fires the action and puts the house to sleep if I move any of the bedrooms into sleep mode.
alias: Put The House To Sleep
trigger:
platform: state
entity_id:
- input_select.master_bedroom_override
- input_select.front_bedroom_override
- input_select.rear_bedroom_override
to: 'Sleep'
condition:
condition: and
conditions:
- condition: template
value_template: >
{% if is_state('device_tracker.bill', 'home') and ('input_select.master_bedroom_override', 'Sleep') %}
true
{% elif is_state('device_tracker.bill', 'not_home') and ('input_select.master_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
- condition: template
value_template: >
{% if is_state('input_boolean.guest_mode', 'on') and ('input_select.front_bedroom_override', 'Sleep') %}
true
{% elif is_state('input_boolean.guest_mode', 'off') and ('input_select.front_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
- condition: template
value_template: >
{% if is_state('device_tracker.stacey', 'home') and ('input_select.rear_bedroom_override', 'Sleep') %}
true
{% elif is_state('device_tracker.stacey', 'not_home') and ('input_select.rear_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
action:
- service: input_select.select_option
data:
entity_id: input_select.house_override
option: 'Sleep'
Ha, didnāt even know that templating tool was there. That thing is handy.
So I figured it out, we need to add an additional āis_stateā for the āandā portions of the template.
So the full working version is as follows.
alias: Put The House To Sleep
trigger:
platform: state
entity_id:
- input_select.master_bedroom_override
- input_select.front_bedroom_override
- input_select.rear_bedroom_override
to: 'Sleep'
condition:
condition: and
conditions:
- condition: template
value_template: >
{% if is_state('device_tracker.bill', 'home') and is_state('input_select.master_bedroom_override', 'Sleep') %}
true
{% elif is_state('device_tracker.bill', 'not_home') and is_state('input_select.master_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
- condition: template
value_template: >
{% if is_state('input_boolean.guest_mode', 'on') and is_state('input_select.front_bedroom_override', 'Sleep') %}
true
{% elif is_state('input_boolean.guest_mode', 'off') and is_state('input_select.front_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
- condition: template
value_template: >
{% if is_state('device_tracker.stacey', 'home') and is_state('input_select.rear_bedroom_override', 'Sleep') %}
true
{% elif is_state('device_tracker.stacey', 'not_home') and is_state('input_select.rear_bedroom_override', 'Automatic') %}
true
{% else %}
false
{% endif %}
action:
- service: input_select.select_option
data:
entity_id: input_select.house_override
option: 'Sleep'