home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.26k stars 28.47k forks source link

media_player.select_source does not work in automation #109409

Closed bonehead50 closed 1 week ago

bonehead50 commented 4 months ago

The problem

In an automation to automatically change the source of a Vizio TV depending on whether I change a Roku stick from home to any other app or from other apps to home, but automation runs successfully but the source is not changed. I tried to look at this and the only thing I have figured out is the issue started after the first release of 2024. I restored my testing environment to the 2023.12.4 and the automation works just fine.

What version of Home Assistant Core has the issue?

2024.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

2023.12.4

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

Here is my automation yaml...

alias: Family Room TV Source Selection - Roku state
description: Set source of Family Room TV depending on whether roku is playing or not
trigger:
  - platform: state
    entity_id:
      - sensor.roku_5_active_app_id
    id: Roku_5_Play
    from: "562859"
  - platform: state
    entity_id:
      - sensor.roku_5_active_app_id
    id: Roku_5_Stop
    to: "562859"
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition:
  - condition: template
    value_template: |
      {{ trigger.from_state.state not in ['unknown', 'unavailable'] }}
    enabled: true
  - condition: template
    value_template: |
      {{ trigger.to_state.state not in ['unknown', 'unavailable'] }}
    enabled: true
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Roku_5_Play
        sequence:
          - data:
              source: HDMI-4
            service: media_player.select_source
            target:
              entity_id:
                - media_player.family_room_tv
      - conditions:
          - condition: trigger
            id: Roku_5_Stop
        sequence:
          - service: media_player.select_source
            data:
              source: HDMI-1
            target:
              entity_id:
                - media_player.family_room_tv
mode: single

Anything in the logs that might be useful for us?

No error messages

Additional information

trace automation.hdmi1_to_hdmi4_roku_is_playing 2024-02-02T02_24_09.087408+00_00.json

bonehead50 commented 4 months ago

I made a mistake and put the 'What was the last working version of Home Assistant Core?' in the 'Integration causing the issue'section...

npike commented 3 months ago

Having the same problem, but have been unable to root cause it. The logs for the Vizio or Cast integration don't seem to indicate anything, and running the action directly from the automation editor works fine.... just when it runs as part of the automation nothing happens.

I am on HA Core 2024.1.2

trace automation.vizio_soundbar_source_changed_away_from_hdmi_arc 2024-02-09T03_21_39.933374+00_00.json

npike commented 3 months ago

I wonder if this is related? https://github.com/home-assistant/core/issues/109649

jtaseff commented 3 months ago

Had the same thing happen recently - seems like the TV updated itself as I didn't touch my HA version when it got broken. Running both 2023.12 and 2024.2 have the same behavior. Existing automation just stopped working, and can't get it to work. Triggering the action manually in the automation editor works, but triggering the automation itself doesn't.

Edit - just tested again today 2/18 on HA 2024.2.2 and it is back working, not sure if the TV updated again.

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.