Configuration of Infrared-Device as Media_Player

After trying several approaches over the last few days, I am asking for help:

I have a simple Set-To-Box (UKO-Box), which can only be controlled via Infrared. So I am using using Tuya and a Wifi Smart IR controller to connect the STP to the HA.
Tuya is providing me with a couple of scenes (which are workiing):
power toggle, volume_up and volume_down, and channel_up and channel_down.
How can I make these controls available in my HA frontend as a ‘media_player’?

I tried mostly with ‘Universal Media Player’ but also with Media Player Template but run into a lot of problems.

Here my config for Universal Media Player:

media_player:
  - platform: universal
    name: UKO-Box
    device_class: receiver 
    unique_id: media_player.uko_box
    attributes:
      state: media_player.lg_smart_tv_2
    commands:
      turn_on:
        action: scene.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: scene.uko_on
      turn_off:
        action: scene.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: scene.uko_on
      volume_up:
        action: scene.uko_vol_up
        metadata: {}
        data: {}
        target:
          entity_id: scene.uko_vol_up
      volume_down:
        action: scene.uko_vol_down
        metadata: {}
        data: {}
        target:
          entity_id: scene.uko_vol_down
      media_next_track:
        action: scene.uko_channel_nxt
        metadata: {}
        data: {}
        target:
          entity_id: scene.channel_nxt
      media_previous_track:
        action: scene.uko_channel_prev
        metadata: {}
        data: {}
        target:
          entity_id: scene.uko_channel_prev      

There are several issues bothering me:

  • only power_on and power_off are working
  • how can I put the state of the STB as permanentely ‘ON’? (‘on’ is not working)
  • if I linke the state with another device (TV) as shown in the config, the state of the STB changes, but no ‘power_on’ or ‘power_off’ command is sent to the STB. how can I link the ‘state’ to a command ?
  • the controls ‘media_next_track’, ‘media_previous_track’ as well as Play, Pause, Stop never show

Any help to guide me in the right direction is highly appreciated!
Thanks!

What happens?
Does the buttons not work or what?

Personally I would rather have a physical remote. The IKEA media remote is very nice

only ‘power-on’ and ‘power-off’ are working…
see end of my post for more details …

I have a phsical infrared remote, and hope to find a way to ‘integrate’ the STB to HA

Thanks!

I’m not talking about an IR remote.
I mean a ZigBee remote. That way you don’t need to aim and you don’t need to use the phone

If you set the entity to permanently report state as on, then I would expect even more problems with the turn on/off actions. Rather than using attribute: state: to mirror a different device’s state, I believe a better course of action would be to use a state_template and store the expected device state in an input_boolean.

Documentation is kind of limited (or more likely I am not looking in whatever is the correct place), but your chosen device_class: receiver may or may not expect to support those actions. Try using device_class: tv instead?

Thanks for your recommendation,
but as a newcomer I would really like to find out what I am doing wrong, and how I can make it work

Thanks for your inputs!

Changing the ‘device_class’ to ‘tv’, seems to change the icon, but the controls stay invisible.

I am going the test the ‘state_template’ tomorrow …

Currently I am facing the next issue:
when pressing the ‘on’-button, I get the message:
“Action scene.uko_on uses action media_player.turn_on which was not found.”, or If I press ‘volume_up’, I receive
“Action scene.uko_vol_up uses action media_player.volume_up which was not found.”

Kind of impossible to say anything about this without knowing what YAML is contained within those scenes… Why are they scenes in the first place? Seems a super weird way to trigger sending of IR commands.

Shouldn’t ALL of your actions be scene.turn_on? It’s possibly one of those unfortunate naming coincidences, but it feels like all of the media_player handlers you’re trying to implement rely on setting a scene.

1 Like

The scenes are non-editable and coming from the Tuya-Integration. They are generated by the Tuya-App on my phone.
Each scene is equivalent to a press on the Infrared-Remote of my STB.
E.g. ‘scene.uko_channel_nxt’ switches the STB to the next channel.

The scenes are working, so if on HA I ‘Apply scene.uko_channel_nxt’ the STB switches to the next channel.

Even if i wrap the scenes into an Automation the behaviour is the same.

Yes, I thought so as well,
but each of my scenes are equivalent to one click on the infrared-remote - like POWER, VOLUME_UP, NEXT_CHANNEL …

scene.turn_on is the generic action for setting a scene. Your on and off works because both use scene.turn_on. It’s the entity_id field where you identify the action with a specific scene.

Oh! Yes! This explains!

Thanks!

Things look much better now!

The only issues I still see:

  • the control (play/pause/next …) field does not appear at all
  • when the State is ‘on’ I don’t see the Volume-Buttons on the card, they only appear when clicking on the ‘three dots’, and ‘opening’ the card

I don’t think I have ever seen volume up/down buttons on a media player on the dashboard.

Yes, you are right!

… getting old, and mixing up things …

Thank you!

So, this is my (almost) working solution:

media_player:
  - platform: media_player_template
    media_players:
      uko_box:
        friendly_name: UKO-Box
        device_class: receiver
        unique_id: media_player.uko_box
   #     current_source_template: "{{ states('input_text.selected_source') }}"
        value_template: >
          {% if is_state("input_boolean.uko_power_state", "on") -%}
            on
          {%- else -%}
            off
          {%- endif %}
    #    value_template: "true"
        turn_off:
          action: automation.trigger
          target:
            entity_id: automation.auto_uko_off
        turn_on:
          action: automation.trigger
          target:
            entity_id: automation.auto_uko_on
        next:
          action: scene.turn_on
          target:
            entity_id: scene.uko_channel_nxt   
        previous:
          action: scene.turn_on
          target:
            entity_id: scene.uko_channel_prev               
        volume_up:
          action: scene.turn_on
          target:
            entity_id: scene.uko_vol_up
        volume_down:
          action: scene.turn_on
          target:
            entity_id: scene.uko_vol_down    

The Control field which is missing with the ‘media_player_control card’ appear if i use the ‘Mini Media Player Card’. No idea why …
I can live with this!

Thank you to all your guidance and ideas!