Universal media player - turn_off only when device is on

Hi: I’m new to universal media player and are trying to override turn_off command, I’d like to send off command when and only when the device is on, as the problem with harmony resend IR to some of my devices with toggle switches.
I tried to add a condition but looks like it doesn’t want to accept script element. Any suggestion how to workaround this? Many thanks in advance!

You could create a script that handles that, and call that script from the ump instead of turn_off

Scripts - Home Assistant

1 Like

Thanks, I’m wondering if possible to send command to a dummy or none entity with a template (I know entity id can be made as a template).
If it’s none, what ha will do?

You can test this all out but I do not see the value here. If the script identifies that the MP is on then it would not need to send anything.

Play around with devtools > actions and use media_player.[command] and see what it does

1 Like

Thanks will give a try! Just want to make it simple and configure everything in the media player without using other files/building blocks

As you cannot add if/then to the UMP you need ‘a’ buildingblock, how else do you want to send a turn_off ? You can of course choose to not configure any turn_off

I was thinking since action entity id can be a template, just send to the real device when the action should be fired, and a dummy device when the action shouldn’t be fired.

Where can it be a template?

Something like below:
entity_id: >
{% if condition %} remote.livingroom_mediahub {% else %} input_boolean.dummy {% endif %}

Something like that but it has to be in the script as the UMP does not allow templating…so if it is in the script then why send to another entity? Look at the scripts docu…

...
...
sequence:
      - condition: state
        entity_id: media_player.whatever
        state: "on"
      - action: media_player.turn_off
        target:
           entity_id: media_player.whatever

Not sure if my explanations are clear enough, I prefer to have people find the solution themselves instead of getting ready-cooked stuff.
Note that I never (!) used the UMP but this works`with my samsung tv

media_player:
  - platform: universal
    name: dummy_mp
    children:
        - media_player.samsung
    commands:
      turn_off:
        action: script.switch_off_mp
        data: {}
    attributes:
      state: media_player.samsung        
    browse_media_entity: media_player.samsung
    device_class: tv
    unique_id: dummy_mp

and script:

switch_off_mp:
  sequence:
    - condition: state
      entity_id: media_player.samsung
      state: "on"
    - action: media_player.turn_off
      target:
        entity_id: media_player.samsung
1 Like

It allows templating, I have template that sends to different devices but not sure it works for entity id though.

As per above, never used ump before but in that case you could try to send to another entity_id, I believe/guess it must be an existing one to avoid errors…it is a trial/error situation :slight_smile:

EDIT, and an apology for assuming templating was not permitted, I based it on an old example I tested, never used

1 Like

FYI, the Harmony database used to have separate commands for on and off stored there, even when the original remote had a single toggle button.

Depending on your devices, you might want to search their software for your model and check what buttons show up for your device.

My projector is 10 years old and I checked the command list there is no individual on/off button, which is super frustrating in such scenario. But I guess IR will be gone for all new devices, so the script trick seems to solve the issue of resending OFF command.

Check older/newer projector models from the same company. There’s a pretty good chance the discrete commands will be the same.

Thanks for the hint, I will try to add next model to Harmony and see what it exposes. Mine only has below commands:

        "Projector": {
            "commands": [
                "PowerToggle",
                "DirectionDown",
                "DirectionLeft",
                "DirectionRight",
                "DirectionUp",
                "Select",
                "Return",
                "Menu",
                "PictureMode",
                "Aspect",
                "PictureMode",
                "ColorManagement",
                "Default",
                "Freeze",
                "Function",
                "InputNext",
                "Lens",
                "MemoryLoad",
                "PictureAdjustment",
                "WaveFormMonitor"
            ],
            "id": "49730125"
        }

Edit: ok it’s hopeless, I have tried the 2 generations after my projector, only PowerToggle - well done Panasonic!

1 Like