PlayStation 4 app automation triggers with Alexa

I am trying to set some custom of automatons to verbally open apps via Alexa on my PlayStation 4. I have created the automation and Alexa sees then and I can manually trigger within the HA portal, however when saying “Alexa, turn on Plex” this just turn on the automation and does not trigger. Any help would be appreciated.

- id: '1552238157512'
  alias: Plex
  trigger:
  - entity_id: media_player.playstation_4
    from: 'on'
    platform: state
  action:
  - data:
      entity_id: media_player.playstation_4
      source: Plex
    service: media_player.select_source

You need a way for Alexa to trigger the automation. What Alexa sees is the enable/disable option for the automation. You need a way for Alexa to trigger it. Something using a script maybe?

script:
  alexa_turn_on_plex:
    sequence:
      - service: automation.trigger
        data:
          entity_id: automation.1552238157512

I hope I got this right?

I’m not 100% on this and haven’t tested it myself but I’d be starting with something like this. Make sure the script is exposed to Alexa and then using a Routine, have Alexa use this script rather than the switch for the automation.

I use a virtual or dummy light bulb exposed through emulated hue and Alexa routines trigger them based the brightness of the light. ill edit in a minute and add the post that references it once I find it… (or just search for Alexa virtual or Alexa dummy)

Just make sure your Alexa routine only sets brightness level and not “on” and make sure your automation also turns off the bulb. I use a last used Alexa sensor (an older method not the new one) and have all sorts of tts routines and responses for stuff…and it only responds on the Alexa I spoke to… pretty fun stuff. Now that I have a new tv my kids can ask Alexa to turn on the PlayStation and it switches inputs on the tv and responds to them whether she turned it on, it was already on etc.

Thanks for the replies. Both great Ideas, and I think I will try cjsimmons idea first.
I did manage to create a series of automations, three in total.
1, to have Alexa turn it to an on state 2nd, to be triggered by the on state, and the 3rd, sees the on state of the first and turns it back to off. It works, but these ideas will simplify. Especially as I add more apps.

Hope it works for you. I ended up going the route I did because with the routines I can say whatever I want/ask whatever I want and not be restricted to “Alexa, turn on…” first.

Hope you get a solution that work. Let us know what ends up working for you.

I built a complete speech parser based on the dummy bulb and last alexa idea see

It allows you to pass parameters to the script and it will extract any info from any entity , manipulate it and generate text that alexa will speak

I have decided to go ahead and stick with the current 3 automation method. It just works and I could not get the script to work.

I have the script/switch setup as described by others.

Scripts.yaml:

'1551994862431':
  alias: Plex PS4
  sequence:
  - data:
      entity_id: media_player.playstation_4
      source: Plex
    service: media_player.select_source

Switch.yaml:

Platform: template
  plex:
    turn_on:
      service: script.turn_on
      entity_id: script.1551994862431
    turn_off:
    value_template: false

All exposed via emulated_hue. If you feel like giving it a go this should work.

Thank you. I will give this a shot and reply back.

I have never used switch before. Is there anything needed to be added to the configuration yaml?

You can put that in configuration.yaml under switch:, I just have the config split up.

The issue is this I have never configured switch before.
Invalid config for [switch]: required key not provided @ data[‘platform’]. Got None.

switch: 
  plex:
    turn_on:
      service: script.turn_on
      entity_id: script.1551994862431
    turn_off:
    value_template: false
Platform: template

before Plex and after switch as per docs: https://www.home-assistant.io/components/switch.template/

Invalid config for [switch.template]: required key not provided @ data[‘switches’]. Got None. (See ?, line ?). Please check the docs at Template Switch - Home Assistant

switch:
  - platform: template
    plex:
    turn_on:
      service: script.turn_on
      entity_id: script.1551994862431
    turn_off:
    value_template: false

After some muddling This was accepted

switch:
  - platform: template
    switches:
      plex:
        turn_on:
          service: script.turn_on
          entity_id: script.1551994862431
        turn_off:
        value_template: false

Restarting and testing

Success!
Thanks!

1 Like

Now I am trying to add sources for instance Hulu

  - platform: template
    switches:
      plex:
        turn_on:
          service: script.turn_on
          entity_id: script.1551994862431
        turn_off:
        value_template: false
        
  - platform: template
    switches:
      hulu:
        turn_on:
          service: script.turn_on
          entity_id: script.1552236476626
        turn_off:
        value_template: false

But HA not happy
nvalid config for [switch.template]: invalid slug Hulu (try hulu) for dictionary value @ data[‘switches’]. Got OrderedDict([(‘Hulu’, OrderedDict([(‘turn_on’, OrderedDict([(‘service’, ‘script.turn_on’), (‘entity_id’, ‘script.1552236476626’)])), (‘turn_off’, None), (‘value_template’, False)]))]). (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.template/

OK
Hulu: to hulu:
Working