FireTV Stick in Automation Issue

Hi,

I have a FireTV stick configured with ADB running on Hass.IO.
I can see it changing states:

grab 2020-02-10 alle 11.10.49

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 :wink:

Agree on this. That’s why I put the standard in quotes :stuck_out_tongue: But do we agree that at least the order of trigger, condition and action should be like I suggested?

Yep. I think the OP’s automation was generated by Automation editor and that explains its form.

so it is changing to “playing”
grab 2020-02-10 alle 14.20.30

made the changes as suggested but I can’t see why It shouldn’t work like it was.
Specially given that Kodi was triggering it correctly

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:

grab 2020-02-22 alle 18.38.25

but still no luck with the automation :frowning:
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'