I now have a macro fuction that turns on multiple devices with a boolean_switch
input_boolean:
watch_movie:
name: Mediacenter
initial: off
icon: mdi:movie
As it is initial off, it is possible that the macro was called (all devices are on) but the switch is off.
Is it possible to toogle the switch state depending on the state of the corresponding devices?
I would presume its in the automation part. Something like that?
- alias: 'Change to ON Mode'
trigger:
platform: state
entity_id: media_player.xy
# not "from 'off' to 'on'" but "is 'on'"
#where to add an if else?#
action:
service: input_boolean.turn_on
entity_id: input_boolean.watch_movie
You can specify multiple triggers. The automation will run if any of these triggers fire.
You’d then need to add a condition section that uses and with a list of conditions.
I am not 100% sure what you want to do here but the configuration you just posted should not work the condition block should be on the same level as trigger and action. Could you describe what you are trying to achieve here?
trigger:
- platform: state
entity_id: media_player.a
state: on
- platform: state
entity_id: media_player.b
state: on
condition:
- condition: and
conditions:
- condition: state
entity_id: media_player.a
state: on
- condition: state
entity_id: media_player.b
state: on
- condition: template
entity_id: media_player.a
value_template: '{{ states.media_player.a.attributes.source == "TV"}}'
action:
[...]
You probably can drop the “state: on” check for media player “a” from the conditions, because if it has a valid source (i.e. “TV”) this probably implies that it’s on.
Use the dev-tools section to check if the template returns the expected values.
Now I want to read the state of all controlled components to put the input_boolean switch in the correct state.
Sometimes if on component doesnt turn on or if I restart hass the boolean switch is in the wrong state and I cant be sure the state of the devices is the same as the switch.
17-01-27 22:24:04 homeassistant.bootstrap: Invalid config for [automation]: expected str for dictionary value @ data['trigger'][0]['state']. Got None
extra keys not allowed @ data['condition'][0]['conditions'][0]['state']. Got None
not a valid value for dictionary value @ data['condition'][0]['conditions'][0]['condition']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 85). Please check the docs at https://home-assistant.io/components/automation/
My code:
automation:
- alias: Start Makro Mediacenter
hide_entity: True
trigger:
platform: state
entity_id: input_boolean.watch_movie
from: 'off'
to: 'on'
action:
service: script.turn_on
entity_id: script.mediacenter_on
- alias: Stop Makro Mediacenter
hide_entity: True
trigger:
platform: state
entity_id: input_boolean.watch_movie
from: 'on'
to: 'off'
action:
service: script.turn_on
entity_id: script.mediacenter_off
- alias: Stop Makro Mediacenter
hide_entity: True
trigger:
- platform: state
entity_id: media_player.avr_wohnzimmer
state: on
- platform: state
entity_id: media_player.kodi
state: on
condition:
- condition: and
conditions:
- condition: state
entity_id: media_player.avr_wohnzimmer
state: on
- condition: state
entity_id: media_player.kodi
state: on
- condition: template
entity_id: media_player.avr_wohnzimmer
value_template: '{{ states.media_player.avr_wohnzimmer.attributes.source == "htpc"}}'
action:
service: input_boolean.turn_on
entity_id:
- input_boolean.watch_movie
17-01-30 12:03:55 homeassistant.bootstrap: Invalid config for [automation]: not a valid value for dictionary value @ data['condition'][0]['conditions'][2]['condition']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 98). Please check the docs at https://home-assistant.io/components/automation/
It’s really hard to help you if you keep messing up the preformatted text. Try to copy paste your config and look at the preview befor submitting so we can see what you have exactly.
First: The trigger doesnt seem to work. If I mannually trigger it the conditions work. Thanks.
But after a restart (the devices are on as for the conditions necessary) or when I change a device state nothing happens. These automations only purpose is to show the correct “state” of my scene ("are all devices in the right state -or- “has the macro act correctly”)
-> The input_boolean.watch_movie triggers an automation which execute a script turning on different devices.
To dig deeper into it.
Maybe its the wrong way I try to control my scene?
The Problem I have or what I try to do:
I have various scenes/macros I want to control:
– For instance: HTPC + AVR + AVR Souce + TV = Mediacenter aka. “whatch movies”
– or: Dreambox (Enigma2) + AVR + AVR Source + TV = TV aka. “watch TV2”
What Im trying to do now is for one thing:
Turn all components on (and switch sources) via one button or switch
– check if they are all on
otherwise:
When one scene is active and another is activated - switch and turn off unnecessary devices
– e.g.: from Mediacenter -> TV: HTPC:OFF, AVR:SOURCE:TV, Dreambox:ON (AVR and TV unchanged)
This is a bit more complex and I presume I havent the necessary phantasy to get a reliable solution