AWESOME, the custom component is quite brilliant, and working very well for me using Hass.IO v0.60! Now my Harmony can correctly turn on “Movie Scene” and “Movie Paused Scene” on demand!
These scenes in turn work amazingly well with the Lutron Caseta Pro custom component here!, and other Z-Wave lamps!
I sure hope these two great components become part of the HomeAssistant core soon . . . they have provided the most stable automation between Harmony, theater, and lights I’ve ever been able to achieve.
It would be great however if the documentation for the Emulated_Roku on GitLab could be updated with details about how the App Launch functionality does not work with Harmony – I lost alot of time trying to understand this and, finally discovering that it doesn’t work (and now the comments above make sense).
Others may also find it useful to know that the easiest way I found to Debug this component was to create an automation that pipes the data into a Python Script. This allows you to then log to the console, or send a notification via pushover, with data details as buttons are pressed. Python Scripts support dynamic changes, so you can just edit it live and retest without reloading HomeAssistant, which was wayyy easier than working with unique automations.
Here’s my Proxy Automation:
#Proxy the Emulated Roku Data into our Python Script for Automation!
- alias: Emulated Roku Event Trigger
hide_entity: True
trigger:
platform: event
event_type: roku_command
#NOTE: FutureFiltering to separate python script automations by USN could be enabled by filtering via USN value here...
#event_data:
# roku_usn: {ROKU USN}
action:
- service: python_script.emulated_roku
#BBernard - 01/04/2018
#NOTE: Pass in key data to the Python Script where Debugging is significantly easier because Python Scripts support dynamic reloading!
data_template:
roku_usn: "{{ trigger.event.data.roku_usn }}"
type: "{{ trigger.event.data.type }}"
key: "{{ trigger.event.data.key }}"
And here’s the beginning of the Python script snippet to support debugging outputs:
#Initialize the event data passed to the Script!
#TEST NOTE: Roku buttons can be tested via RESTFul POST calls to: 192.168.1.10:8060/keypress/{key}
# For Example to test 'Back': 192.168.1.10:8060/keypress/Back
roku_usn = data.get("roku_usn", "UNDEFINED")
roku_cmd_type = data.get("type", "UNDEFINED")
roku_cmd_key = data.get("key", "UNDEFINED")
#Log the Event to the Log for Debugging (temporarily)
hass.services.call("notify", "pushover", {"message": "Roku Command Event [roku_usn={0}] [type={1}] [key={2}]".format(roku_usn, roku_cmd_type, roku_cmd_key)})
logger.error("EMULATED ROKU DEBUG - Command Event [roku_usn=%s] [type=%s] [key=%s]", roku_usn, roku_cmd_type, roku_cmd_key)
Note the use of logger.error() above, this is for temporary debugging so you don’t have to set your HASS log level to Info and restart, etc. You can comment out the line in the Script at any time and save it, and no restart of HomeAssistant is necessary.
Finally, if just debugging your automations and you don’t want to have to keep pressing the buttons on your Harmony (for me this saved me from running up and down 2 flights of stairs for every test), you can use the REST api for the Roku to trigger keypresses to test the HomeAssistant automations directly.
Testing automations via RESTFul API:
To test the automation when “Down” button is pressed you can just use PostMan to send a POST with the following url:
#TEST NOTE: Roku buttons can be tested via RESTFul POST calls to: http://{IP_ADDRESS}:8060/keypress/{key}
# For Example to test 'Back': http://{IP_ADDRESS}/keypress/Back
POST: http://{IP_ADDRESS}:8060/keypress/Down