INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Logitech Harmony and MCWS  (Read 871 times)

hoyt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 867
Logitech Harmony and MCWS
« on: February 17, 2019, 03:07:06 pm »

I wasn't quite sure where to post this on the forums, but I've been playing with Home Assistant as a wrapper around Engen for about 6 weeks or so.  I like it quite a bit.  I have a Raspberry Pi running Home Assistant, separate from my IdPi.  One of the things that I tripped across was making a "fake roku" appear on my home network.  At first, I thought, this is cool, I can set it up with Engen so that when I start watching TV, I can hit a button on my remote to turn the lights on or off.  It took a bit of manipulating/ learning, but I got it to work with the Engen API.  That was basically all I was using my IdPi for (Engen).

Then I moved my IdPi to my receiver so I could plug in the HDMI and play it through my living room stereo.  I setup a second fake roku, which was tied to the MCWS port of the IdPi.  I now have bound the play button on my harmony remote to play a smartlist I created, as well as basic stuff like pause, next and previous.

I can try to write up a how-to, but for now these are the resources that I used:

https://gitlab.com/mindig.marton/ha-emulated_roku
https://sdkdocs.roku.com/display/sdkdoc/External+Control+API#ExternalControlAPI-KeypressKeyValues

Excerpts from the various files I have are:

configurations.yaml:
Code: [Select]
rest_command:
  engen_api:
    url:  http://<internal_ip_of_IdPi>:52125/api/v1/nodes/{{ node }}/{{ path }}
    method: POST
    headers:
      content-type: application/json; charset=UTF-8
    payload: '{{ value }}'
  mcws_api:
    url: http:///<internal_ip_of_IdPi>:52199/MCWS/v1/{{ category }}/{{ command }}?{{ value }}
    method: GET
emulated_roku:
  host_ip: <internal_ip_of_home_assistant>
  listen_ports:
    - 8124
    - 8125
#8124 is the engen port for the roku, and 8125 is the MCWS port.  You can setup as many as you want and may need to because the list of buttons available is short.

automations.yaml
Code: [Select]
- id: engen_fwd
  alias: Engen - Fwd - Left
  trigger:
  - event_data:
      key: Fwd
      roku_usn: <from host_ip:8124>
      type: keypress
    event_type: roku_command
    platform: event
  action:
  - service: rest_command.engen_api
    data_template:
      node: 14
      path: switch_binary/value
      value: >
        {% if is_state('sensor.living_room_left_status','False') %}
          1
        {% else %}
          0
        {% endif %}
.......
# Roku for MCWS
- id: mcws_play
  alias: MCWS - Play
  trigger:
  - event_data:
      key: Play
      roku_usn: <from host_ip:8125>
      type: keypress
    event_type: roku_command
    platform: event
  action:
  - service: rest_command.mcws_api
    data_template:
      category: Playback
      command: PlayPlaylist
      value: Zone=0&ZoneType=ID&Playlist=534914664&PlaylistType=ID
- id: mcws_play_pause
  alias: MCWS - PlayPause
  trigger:
  - event_data:
      key: InstantReplay
      roku_usn: <from host_ip:8125>
      type: keypress
    event_type: roku_command
    platform: event
  action:
  - service: rest_command.mcws_api
    data_template:
      category: Playback
      command: PlayPause
      value: Zone=0&ZoneType=ID
- id: mcws_next
  alias: MCWS - Next
  trigger:
  - event_data:
      key: Fwd
      roku_usn: <from host_ip:8125>
      type: keypress
    event_type: roku_command
    platform: event
  action:
  - service: rest_command.mcws_api
    data_template:
      category: Playback
      command: Next
      value: Zone=0&ZoneType=ID
- id: mcws_previous
  alias: MCWS - Previous
  trigger:
  - event_data:
      key: Rev
      roku_usn: <from host_ip:8125>
      type: keypress
    event_type: roku_command
    platform: event
  action:
  - service: rest_command.mcws_api
    data_template:
      category: Playback
      command: Previous
      value: Zone=0&ZoneType=ID

A few short notes, some of the Roku commands didn't work for me that I saw listed in the Harmony app, but all of the ones listed on that page worked.  For example, there's a Pause setting in the Harmony app.  When I set up "Pause" in the automations.yaml I could test it with curl -d '' http://<raspberry pi hosting Home Assistant>:8125/keypress/Pause, but when I put it into the app, it acted like I was hitting Play.

I'm using a GET on the MCWS because it was quick and dirty.  I assume a POST would work if I figured out all of the info I need to format, like I did with the Engen POST.

Once you've done that, you go to the Harmony app, find a device on your wifi, and it'll find a "Roku 4" for each port you've listed in configurations.yaml.  I renamed them Engen and MCWS to keep them straight.  You then customize the buttons in the Harmony app and map each physical key to one of these items.
Logged
Pages: [1]   Go Up