Logitech Harmony universal remote to MQTT Camera

Install Fakeroku on Home Assistant

I want install an emulated Roku device in Home Assistant that will allow us to set up an interface with the Logitech Harmony Hub. I want to be able to control my INSTAR camera through it’s MQTT interface.

Open the Integration tab inside the Configuration menu and set up the EmulatedRoku extension.

Then switch to your Harmony Smartphone app and search for new devices on your network - the virtual Roku device will show up as Roku 3. Save it and add an Activity for it.

Set up Home Assistant to Update MQTT Topics

The Fakeroku virtual device will now give you access to the following buttons on your Harmony Remote:

For example Button 1 will send the payload string Rev to Home Assistant when you press it.

  1. Rev - Unused
  2. Play - Start a x Second Video Recording
  3. Fwd - Unused
  4. Home - Deactivate the Alarm
  5. Up - Move Camera Up by one Step
  6. Right - Move Camera Right by one Step
  7. Down - Move Camera Down by one Step
  8. Left - Move Camera Left by one Step
  9. Select - Stop Camera Movement
  10. Back - Activate the Alarm
  11. Info - Trigger enabled Alarm Actions

We now need to add automations that allows us to update MQTT topics on our INSTAR MQTT camera when we receive a message from our Harmony Remote. To do this open the configuration menu and add a new automation.

Pan & Tilt your Camera

This automation listens to the Up, Right, Down and Left button and updates the according “One-Step” MQTT Topics on your camera.

platform: event
event_type: roku_command
event_data:
  source_name: Home Assistant
  type: keypress
  key: Up

service: script.send_mqtt_command
data:
  message: '{"val":"up"}'
  target: instar/local/features/ptz/movestep

Arm your Alarm before your leave your Home

This automation defines an armed and disarmed state for your camera. When armed your camera will keep an eye on your living room. When disarmed your camera will turn away and deactivates all motion detection areas. Note that if you are using the camera’s internal PIR motion sensor in combination with those detection areas, you will have to deactivate the sensor as well for this to work:

Triggers

event_data:
  key: Back
  source_name: Home Assistant
  type: keypress
event_type: roku_command
platform: event

Actions

data:
  message: '{"val":"1"}'
  target: instar/local/features/ptz/preset
service: script.send_mqtt_command
data:
  message: '{"val":"1"}'
  target: instar/local/alarm/area1/enable
service: script.send_mqtt_command
data:
  message: '{"val":"1"}'
  target: instar/local/alarm/area2/enable
service: script.send_mqtt_command
data:
  message: '{"val":"1"}'
  target: instar/local/alarm/area3/enable
service: script.send_mqtt_command
data:
  message: '{"val":"1"}'
  target: instar/local/alarm/area4/enable
service: script.send_mqtt_command

And vice-versa {"val":"0"} to deactivate everything.

Start a Manual Video Recording

This automation enables you to start a manual video recording when pressing the Play button on your remote. Note that the delay is currently set to 30s - you can adjust the length of your according by changing this value:

Triggers

event_data:
  key: Play
  source_name: Home Assistant
  type: keypress
event_type: roku_command
platform: event

Actions

data:
  message: '{"val":"60"}'
  target: instar/local/features/manualrec/start
service: script.send_mqtt_command
delay: '00:00:30'
data:
  message: '{"val":"off"}'
  target: instar/local/features/manualrec/stop
service: script.send_mqtt_command

Trigger an Alarm

And now to the simplest automation Pressing the Info button will trigger an alarm on your camera. This event will trigger all active alarm actions on your camera - like vide recordings, email notifications, FTP uploads, etc.:

Triggers

event_data:
  key: Info
  source_name: Home Assistant
  type: keypress
event_type: roku_command
platform: event

Actions

data:
  message: '{"val":"1"}'
  target: instar/local/alarm/pushalarm
service: script.send_mqtt_command
1 Like

automations.yaml export

- id: '1583746741522'
  alias: Harmony PT Up
  description: 'Tilt camera up when Up is pressed on my Harmony remote '
  trigger:
  - event_data:
      key: Up
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"up"}'
      target: instar/local/features/ptz/movestep
    service: script.send_mqtt_command
- id: '1583747187870'
  alias: Harmony PT Down
  description: ' '
  trigger:
  - event_data:
      key: Down
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      data:
        message: '{"val":"down"}'
        target: instar/local/features/ptz/movestep
    service: script.send_mqtt_command
- id: '1583747246045'
  alias: Harmony PT Left
  description: ''
  trigger:
  - event_data:
      key: Left
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"left"}'
      target: instar/local/features/ptz/movestep
    service: script.send_mqtt_command
- id: '1583747337674'
  alias: Harmony PT Right
  description: ''
  trigger:
  - event_data:
      key: Right
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"right"}'
      target: instar/local/features/ptz/movestep
    service: script.send_mqtt_command
- id: '1583748047823'
  alias: Harmony I am Home
  description: Deactivate alarm areas and turn around
  trigger:
  - event_data:
      key: Home
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"0"}'
      target: instar/local/alarm/area1/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"0"}'
      target: instar/local/alarm/area2/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"0"}'
      target: instar/local/alarm/area3/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"0"}'
      target: instar/local/alarm/area4/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"0"}'
      target: instar/local/features/ptz/preset
    service: script.send_mqtt_command
- id: '1583748225541'
  alias: Harmony I am Leaving
  description: Activate all alarm areas and keep an eye on my living room
  trigger:
  - event_data:
      key: Back
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"1"}'
      target: instar/local/features/ptz/preset
    service: script.send_mqtt_command
  - data:
      message: '{"val":"1"}'
      target: instar/local/alarm/area1/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"1"}'
      target: instar/local/alarm/area2/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"1"}'
      target: instar/local/alarm/area3/enable
    service: script.send_mqtt_command
  - data:
      message: '{"val":"1"}'
      target: instar/local/alarm/area4/enable
    service: script.send_mqtt_command
- id: '1583748469538'
  alias: Harmony trigger an alarm
  description: ''
  trigger:
  - event_data:
      key: Info
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"1"}'
      target: instar/local/alarm/pushalarm
    service: script.send_mqtt_command
- id: '1583749140147'
  alias: Harmony record a video
  description: ''
  trigger:
  - event_data:
      key: Play
      source_name: Home Assistant
      type: keypress
    event_type: roku_command
    platform: event
  condition: []
  action:
  - data:
      message: '{"val":"60"}'
      target: instar/local/features/manualrec/start
    service: script.send_mqtt_command
  - delay: 00:00:30
  - data:
      message: '{"val":"off"}'
      target: instar/local/features/manualrec/stop
    service: script.send_mqtt_command

that’s brilliant

Thank you! :smiley: