I have a FireTV stick configured with ADB running on Hass.IO.
I can see it changing states:
but I can’t make it work with this automation:
- action:
- service: light.lifx_set_state
data:
entity_id: light.led_camino
brightness: 0
transition: 3
alias: Media player play
initial_state: true
id: '2018030817130'
trigger:
- platform: state
entity_id: media_player.kodi
to: playing
- platform: state
entity_id: media_player.fire_tv_salotto
to: playing
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: state
entity_id: binary_sensor.michele_at_home
state: 'on'
type or paste code here
the interesting thing is it works with KODI but not with Fire Stick.
Can anyone help?
First, conditions are AND by default, so you can remove the two lines:
condition: and
conditions:
Second I recommend bringing your automation in the “standard” format, meaning first the id, alias and initial state, then the trigger part, then the condition part and finally the action part. This is more logical and easier to read and understand for other people.
Does you Fire TV change state to ‘playing’ or to 'on, when it is playing something?
May I just add that unfortunately, there is no such thing as ‘standard’ format for automations just yet (devs say it’s work in progress).
From the code/experience id is optional and initial_state: true should be only used if one understands what they’re doing
Agree on this. That’s why I put the standard in quotes But do we agree that at least the order of trigger, condition and action should be like I suggested?
The changes I suggested were not mean’t to make your code working, it was just a rearraning of the elements for better readability and more logical arrangment.
Can you please try the below code:
alias: Media player test
id: ‘1234567890123’
trigger:
platform: state
entity_id: media_player.fire_tv_salotto
action:
service: persistent_notification.create
data_template:
message: “{{ trigger.to_state.state }}”
This should create a notification every time the fire tv changes state. Please post these notifications here.
ok so done as suggested and I have notification of state changing:
but still no luck with the automation
I can’t understand what is going wrong with it: “condition” should not be an issue as it works fine if triggered by Kodi
I am sure it is something stupid I am missing but can’t understand what!
I just did a quick test for you, since I have a Fire TV stick.
This code turns on my lamp if the Fire TV stick changes to Playing, so I think your trigger is fine. Have you tried doing a simple automation with just the Fire TV stick?
- id: '1582474180407'
alias: Fire TV Test
description: ''
trigger:
- entity_id: media_player.master_bedroom_fire_tv_4k
platform: state
to: playing
condition: []
action:
- entity_id: light.johns_lamp
service: light.turn_on
I also took your code and made some slight modifications to reflect my setup, and it worked fine:
- action:
- service: light.turn_on #turned on lamp as test
data:
entity_id: light.johns_lamp
alias: Michele Media player play
initial_state: true
id: 'TEST2018030817130'
trigger:
- platform: state
entity_id: media_player.great_room_fire_tv_4k #my fire tv's
to: playing
- platform: state
entity_id: media_player.master_bedroom_fire_tv_4k #my fire tv's
to: playing
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'above_horizon' #set to above horizon for test
- condition: state
entity_id: person.john #changed to person home
state: 'home'