Automation based on Onkyo receiver state

I’m trying to setup a very simple automation (turn on/off a zigbee power plug) based on the power state of one of my Onkyo receivers but can’t get it to trigger.
I have two receivers from Onkyo, both are added using yaml as described here: Onkyo - Home Assistant
I can see both of them under “History” and state reporting there is very accurate. If i turn one of them on for 10 seconds and then turn it off, i can see that under history so HA is seeing their state.

When i try to create an automation (using GUI) is where i run into trouble. If i select “Trigger type” “Device”, i can only find one of them (the one i want to use). If i select that, “Trigger” is greyed out.
If i instead select “Trigger type” “State”, i can find both entities but i can’t find “On” or “Off” as attributes. Trying to set it manually to “On” or “Off” doesn’t trigger either.

Does anyone know what i should use to trigger my automation and why one of my receivers are missing under “Device”? Checking core.config_entries and core.device_registry there’s not a trace of the missing one but it’s there in the GUI.

Why not use a State Trigger to monitor the entity representing your receiver?

State is what i want to use but i can’t get it to work with “on” or “off” as attributes. If receiver is on i want the power plug to be on and when off, the power plug should be turned off.
If I make an automation based on state without attribute, from or to, the automation is actually triggered when i turn on the receiver but then i can’t base it on which state it’s in so when i turn it off, power plug stays on. If i set the automation to toggle the switch i fear i might run into a situation where it gets in reverse (power plug turns off when receiver turns on and vice versa).

Edit:
Managed to solve it. Seems all examples i could find in other threads does not work. Most threads suggests something this:
trigger:
platform: state
entity_id: blabla.blabla
state: ‘off’

The above doesn’t work AND the trick is to leave the from state empty. If is set the trigger to from: off and to: on it’s not triggered when receiver is turned on but settings only to: on works:

- id: '1651178531357'
  alias: Turn on subwoofer
  description: ''
  trigger:
  - platform: state
    entity_id: media_player.tx_nr656_2
    to: 'on'
  condition: []
  action:
  - type: turn_on
    device_id: aef056245616d1bb1d1392ae74a8208b
    entity_id: switch.subben
    domain: switch

Please have a read of this then edit your post and format your pasted config correctly.

The term ‘attributes’ has special meaning in Home Assistant and isn’t used to refer to the possible values of an entity’s state property.


Much of your description, regarding the difficulties you encountered with configuring the State Trigger, suggests you are unfamiliar with the possible values of a media_player’s state property. Unlike a switch entity (or input_boolean or binary_sensor) which has onand off values, a media_player can have several.

The underlying integration determines which values a given media_player supports as well as which state-changes may occur (for example, some change from off to playing or to idle or to on). If the Onkyo integration doesn’t report an off to on state-change then a State Trigger cannot detect that transition when explicitly configured to detect it (using from and to options)

If you exclude from and to options, a State Trigger will trigger on any change of value of the entity’s state property and its attributes (not to be confused with the way you used the word “attributes” in your first sentence). An entity’s attributes are additional properties and if their value changes, it will cause a State Trigger to trigger (there’s a way to suppress that behavior and its described in the documentation).

Thanks for clarifying.
Indeed, this is the first time i’ve tried to use a media_player as trigger. Reading your post, i suspect that the reason i couldn’t get it to work at first was that there might be a state that i’m not aware of between the on and. After that i tried using attribute in the wrong way. But it works great now.