Can’t make this work.
I want it to stop all media and turn off TV if it is on when i turn my alarm on.
- alias: Larm på Media av
trigger:
platform: state
entity_id: alarm_control_panel.alarm_1
state: armed_away
action:
- service: media_player.media_stop
- condition:
condition: state
entity_id: media_player.sony_bravia_tv
state: 'on'
- service: media_player.turn_off
entity_id: media_player.sony_bravia_tv
Get this in the log.
17-01-30 23:35:55 homeassistant.bootstrap: Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->action->1->condition. (See /home/homeassistant/.homeassistant/automation.yaml:0). Please check the docs at https://home-assistant.io/components/automation/
01-31 00:22:37 homeassistant.util.yaml: duplicate key: "condition"
in "/home/homeassistant/.homeassistant/automation.yaml", line 499, column 0
in "/home/homeassistant/.homeassistant/automation.yaml", line 500, column 0
17-01-31 00:22:37 homeassistant.components.automation: duplicate key: "condition"
in "/home/homeassistant/.homeassistant/automation.yaml", line 499, column 0
in "/home/homeassistant/.homeassistant/automation.yaml", line 500, column 0
It seems to work with the config in my post above.
Now after some thinking i would like to do this a little smarter.
Is there a way to use one trigger, then different action depending of the conditions.
Like this.
Trigger:
If this condition is true
Perform this action
But if this condition is true.
Perform this action instead or also.
And so on…
I want to use ONE trigger in ONE automation.
Then get different actions depending of the condition
If i understand things right i can use AND or OR condition
But if that is true it will perform all actions.
The goal is to pause my Chromecast Audio if it is playing when i arm the alarm, resume it when i disarm, but only if is was playing when i armed.
Stop all movies, on two kod machines. Then turn my TV off is it is on.
- alias: Larm på Media av
trigger:
platform: state
entity_id: alarm_control_panel.alarm_1
state: armed_away
action:
- service: script.alarm_on
script:
alarm_on:
alias: Alarm ON
sequence:
- condition: state
entity_id: media_player.CCaudio #just an example
state: playing
- service media_player.media_stop
- condition: state
entity_id: media_player.sony_bravia_tv
state: 'on'
- service: media_player.turn_off
entity_id: media_player.sony_bravia_tv
or do I have to split it up?
script:
alarm_on1:
alias: Alarm ON1
sequence:
- condition: state
entity_id: media_player.CCaudio #just an example
state: playing
- service media_player.media_stop
And is there a way to make hass remember if music was playing when alarm was turned on and resume the music when disarmed. But only if it was playing when armed.
Sometimes my automation doesn’t work.
I get this in my log.
17-02-02 09:36:20 homeassistant.core: Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 1054, in execute_service
service_handler.func(service_call)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 324, in media_player_service_handler
getattr(player, method)()
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/kodi.py", line 294, in media_stop
if len(players) != 0:
TypeError: object of type 'NoneType' has no len()