dgaust
(dgaust)
January 25, 2020, 11:20pm
1
Hi,
I’m going through building a UI for a basic remote based on the logitech harmony. I’m wondering if there is an easy way to send command based on the current activity rather than send the command to a selected device.
For example, if the activity is Play Xbox the commands for up, down, left and right need to be sent to the xbox device. However, if the activity is Watch Fetch, those commands need to be sent to the Fetch TV box. The physical remote is setup to do this, but I cannot find a service option to send command to an activity (so the hub can decide the code) rather than device.
At the moment I’ve simulated this by using scripts like this
'1579329073616':
alias: HarmonyButtonEnter
sequence:
- service: remote.send_command
data_template:
entity_id: remote.lounge
command: >
{% if is_state("sensor.currentactivity", "Watch TV") %}
OK
{% elif is_state("sensor.currentactivity", "Watch Fetch") %}
Select
{% elif is_state("sensor.currentactivity", "Play Xbox") %}
Ok
{% else %}
Ok
{% endif %}
device: >
{% if is_state("sensor.currentactivity", "Watch TV") %}
38539290
{% elif is_state("sensor.currentactivity", "Watch Fetch") %}
38539289
{% elif is_state("sensor.currentactivity", "Play Xbox") %}
46058342
{% else %}
38539290
{% endif %}
But that means creating a script for every option, and then calling that script from a button in the UI.
Am I overcomplicating it, or is this the only approach?
1 Like
SteWi
(Stefan)
March 28, 2020, 10:27am
2
Hey @dgaust ,
did you ever find a simplified version? I want to do the exact same thing.
petro
(Petro)
March 28, 2020, 10:33am
3
I made an appdaemon app that does that. Let me tell you, it’s complicated. After creating it, I can tell you that there is no easy way do accomplish your request.
Here’s the appdeamon app, I haven’t added it to hacs yet, but it’s set up pretty much. Just no documentation yet.
and here’s my configuration for it at the moment for appdaemon:
anchors:
roku: &roku
activity: Roku
device: Roku Ultra
xbox: &xbox
activity: Xbox One
device: Microsoft Xbox One
ps4: &ps4
activity: PS4
device: Sony PS4
hac_living_room:
module: harmony_activity_controls
class: ActivityControls
remote: remote.living_room
activities:
- <<: *roku
- <<: *xbox
- <<: *ps4
commands:
- Rewind
- Play
- Pause
- command: FastForward
name: Forward
- DirectionUp
- DirectionLeft
- command: OK
name: Confirm
- DirectionRight
- DirectionDown
- Back
custom_events:
- event: HomeButton
icon: mdi:home
name: Home
activities:
- <<: *roku
command: Home
- <<: *xbox
command: Xbox
- <<: *ps4
command: PS
- event: MenuButton
icon: mdi:menu
name: Menu
activities:
- <<: *roku
command: 'Options*'
- <<: *xbox
command: Menu
icon: mdi:xbox-controller-menu
- <<: *ps4
command: Options
- event: LowerLeft
activities:
- <<: *roku
name: Search
command: Search
- <<: *xbox
name: View
command: View
icon: mdi:xbox-controller-view
- <<: *ps4
name: Info
command: Info
- event: LowerRight
activities:
- <<: *roku
name: Exit
command: Exit
- <<: *xbox
command: OneGuide
name: One Guide
icon: mdi:xbox
- <<: *ps4
name: Share
command: Share
- event: BottomButton
name: Confirm
activities:
- <<: *xbox
entity_picture: /local/images/xbox_a_transparent_2.png
color: rgba(100, 189, 54)
command: A
- <<: *ps4
entity_picture: /local/images/playstation_x.png
color: rgba(107, 139, 200)
command: Cross
- event: RightButton
name: Back
activities:
- <<: *xbox
entity_picture: /local/images/xbox_b_transparent_2.png
color: rgba(255, 24, 43)
command: B
- <<: *ps4
entity_picture: /local/images/playstation_circle.png
color: rgba(246, 69, 75)
command: Circle
- event: TopButton
name: Search
activities:
- <<: *xbox
entity_picture: /local/images/xbox_y_transparent_2.png
color: rgba(255, 185, 49)
command: 'Y'
- <<: *ps4
entity_picture: /local/images/playstation_triangle.png
color: rgba(43, 220, 150)
command: Triangle
- event: LeftButton
name: Backspace
activities:
- <<: *xbox
entity_picture: /local/images/xbox_x_transparent_2.png
color: rgba(0, 61, 142)
command: X
- <<: *ps4
entity_picture: /local/images/playstation_square.png
color: rgba(219, 142, 196)
command: Square
log_level: INFO
make_scripts: True
It creates a script file for you for each command…
remote_living_room_rewind:
sequence:
- event: remote_living_room
event_data: {'command': 'Rewind'}
remote_living_room_play:
sequence:
- event: remote_living_room
event_data: {'command': 'Play'}
remote_living_room_pause:
sequence:
- event: remote_living_room
event_data: {'command': 'Pause'}
remote_living_room_fastforward:
sequence:
- event: remote_living_room
event_data: {'command': 'FastForward'}
remote_living_room_directionup:
sequence:
- event: remote_living_room
event_data: {'command': 'DirectionUp'}
remote_living_room_directionleft:
sequence:
- event: remote_living_room
event_data: {'command': 'DirectionLeft'}
remote_living_room_ok:
sequence:
- event: remote_living_room
event_data: {'command': 'OK'}
remote_living_room_directionright:
sequence:
- event: remote_living_room
event_data: {'command': 'DirectionRight'}
remote_living_room_directiondown:
sequence:
- event: remote_living_room
event_data: {'command': 'DirectionDown'}
remote_living_room_back:
sequence:
- event: remote_living_room
event_data: {'command': 'Back'}
remote_living_room_homebutton:
sequence:
- event: remote_living_room
event_data: {'command': 'HomeButton'}
remote_living_room_menubutton:
sequence:
- event: remote_living_room
event_data: {'command': 'MenuButton'}
remote_living_room_lowerleft:
sequence:
- event: remote_living_room
event_data: {'command': 'LowerLeft'}
remote_living_room_lowerright:
sequence:
- event: remote_living_room
event_data: {'command': 'LowerRight'}
remote_living_room_bottombutton:
sequence:
- event: remote_living_room
event_data: {'command': 'BottomButton'}
remote_living_room_rightbutton:
sequence:
- event: remote_living_room
event_data: {'command': 'RightButton'}
remote_living_room_topbutton:
sequence:
- event: remote_living_room
event_data: {'command': 'TopButton'}
remote_living_room_leftbutton:
sequence:
- event: remote_living_room
event_data: {'command': 'LeftButton'}
1 Like
dgaust
(dgaust)
March 29, 2020, 10:51pm
4
Unfortunately not… still using the approach in the first post.
cloak
January 24, 2021, 12:40pm
5
Hi @petro
I’m relatively new to HA and I’m curious about your App. Regarding
and here’s my configuration for it at the moment for appdaemon:
A few questions:
where does that code end up?
what do you add apps.yaml?
Are the devices and activities manually added?
From the last question, I’m interested in parsing the harmony…conf file to get the activies and IDs, and devices and IDs. I can pull use the activities without the IDs with the python script below (and the devices with a variation of it), but I have no idea how to do that with .conf file. Do you have any ideas for directions to head to pull IDs and the associated devices/activities from the .conf file?
harmony_activities = hass.states.get(
'remote.harmonyhub').attributes['activity_list']
all_activities = []
for activities in harmony_activities:
all_activities.append(activities)
service_data = {'entity_id': 'input_select.harmony_hub_activity',
'options': all_activities}
hass.services.call('input_select', 'set_options', service_data)