New widget: Remote controller button custom widget

it shouldnt be send as a string at all.
but i think you are right and there needs to be a change in the call_service from python.
in the widgets the data should be stringified like this

JSON.stringify(arr)

and in the call_service it should be translated to dicts with

json.loads(json_string)

or something like that. but i dont know the total impact from that, so i need to take that up with andrew.
ill open a new issue to sort that out.

off course you could also do it on the HA side.
create scripts for all command combinations you like and call those scripts from the dashboard.

Hi, that’s exactly what I need. Can you please post your code and specify where the files are to be placed?

hi @cucpotn,

Sure. I’m working on a new code, which should be better than the old one. I’m about to post it. hold on :slight_smile:

Hi,

You may grab the changed rundash.py file here. And the new version of the remote widget here. Take a look on the sample “Remote.dash” file as the way to list the commands changed a bit.

1 Like

Hello,

I’m attempting to implement this widget but I seem to be having trouble. Where does the rundash.py go?

When I try to implement a test control to talk to a Harmony remote, I’m getting the following error when the dash loads:

  • test_livingroom_volume_down: Error in widget definition ‘%s’:
  • test_livingroom_volume_down: parser says
  • test_livingroom_volume_down: in “”, line 2, column 10: entity: {{entity}} ^
  • test_livingroom_volume_down: found unhashable key while constructing a mapping

This is the widget implementation:

  widget_type: remote
  title: test
  entity: remote.livingroom_harmony_hub
  command:
    - VolumeDown

I’m working on a dashboard for controlling my home theater. I’ve successfully implemented calling scripts to adjust the volume or change channels, but executing the scripts leads to a slow user experience (push button, run script, wait for button to reset so it can be pushed again). I’ve worked around this but adding repeats for the volume, but that wont work for changing channels or when I recreate a directional pad in the dashboard.

What I’ve found is that by using the Developer -> Services remote.send_command tool, I can execute a repeated command quickly with little to no delay. I was hoping to use this widget to do just that, but I’m getting that error.

the widget is old.
AD has changed since then and the get isnt updated

in the yaml file that you copied to the custom_widgets directory there are things like:

entity: {{entity}}

in newer versions from AD that should be:

entity: "{{entity}}"

Thanks Rene,

That solve my issue.

Do you know of an alternative to the widget?

why?
you got a working custom widget now.

Well it’s rendering, so I’m one step closer to a working widget :wink:

You mentioned it was outdated, I was curious if there was a newer alternative. If not, I’ll keep hacking away at this one.

i dont know.
HA has changed so much in 2 years that i cant be sure of anything.
im only supporting old topics (that i reacted on) on the forum, for everything else im available on the AD discord channel.

i didnt see any other simular widgets come by on discord, but that doesnt mean they are not there.
clyra just hacked the switch widget by changing the yaml, so the same thing was possible without a custom widget as well.

by the way, i have no clue what he tried to do with rundash.py
seems like a try to run dashboard without appdaemon.

Thanks.

I’ve been looking for a solution for a few days. This seems to come close enough, looks like I need to update the JS to include an arg for the harmony device.

i dont have HA remotes, but i believe they work the same as momentary switches.
the only thing that is different is the used service.

so you could simply use a switch widget and chose the right service and entity.

Oh? I only saw entity as an option, I assume the entity had to be a type of switch. I’m most likely missing something then :slight_smile:

So Im starting start with just a volume up button. How would I go about getting the switch widget to call:

service: remote.send_command
entity_id: remote.livingroom_harmony_hub
device: <harmony device>
command: VolumeUp

Actually, looking at the code for switch, I could use post_service_active to accomplish, right?

correct
and you can use the momentary option to reset the widget in active state.
and i think thats about all you need.

Is there a particular way to format the entity_id in order to include the service data like device and command? I gave it a shot below but I ended up turning the receiver off :wink:

test_livingroom_volume_down:
  widget_type: switch
  title: test
  entity: remote.livingroom_harmony_hub
  icon_on: mdi-volume-minus
  icon_off: mdi-volume-minus
  post_service_active:
    service: remote/send_command
    entity_id: remote.livingroom_harmony_hub
    device: 71986963
    command: VolumeUp
  momentary: 10

Ok, so I’ve got it working, thanks for the guidance :slight_smile:

livingroom_volume_down:
  widget_type: switch
  entity: remote.livingroom_harmony_hub
  icon_on: mdi-volume-minus
  icon_off: mdi-volume-minus
  post_service_inactive:
    service: remote/send_command
    entity_id: remote.livingroom_harmony_hub
    device: 71986963
    command: 'VolumeDown'
  momentary: 100
1 Like

hi

kind late, but… the remote still works, but as you figured out it need quotes in a few places. I thought i did committed the changes to my repo but now i’m sure i didnt. sorry :(. Here is the full remote.yaml after the update:

widget_type: base_remote
entity: "{{entity}}"
state_inactive: "off"
state_active: "on"
enable: 1
momentary: 400
ignore_state: 1
post_service_active:
    service: remote/send_command
    entity_id: "{{entity}}"
post_service_inactive:
    service: remote/send_command
    entity_id: "{{entity}}"
fields:
    title: "{{title}}"
    title2: "{{title2}}"
    icon: ""
    icon_style: ""
    state_text: ""
icons:
    icon_on: $script_icon_on
    icon_off: $script_icon_off
static_icons: []
css:
  icon_style_active: $script_icon_style_active
  icon_style_inactive: $script_icon_style_inactive
static_css:
  title_style: $script_title_style
  title2_style: $script_title2_style
  state_text_style: $script_state_text_style
  widget_style: $script_widget_style

I dont know where you got the run_dash.py, but it is not needed. I did a few a changes a long time ago, but they are not needed anymore. And here is a button using the remote:

ht_power:
   widget_type: remote
   title: HT Power
   entity: remote.living_room_remote
   json_args:
     device: 32756745
     command:
       - ht_power
   icon_on: mdi-power
   icon_off: mdi-power
   icon_style_inactive: "color: white"
   icon_style_active: "color: blue"

Everything under “json_args” is passed as a dict to the HA, so you can adapt the widget for other services that requires a dict too.

I will update my repo as soon as possible.

edit: ah, Now I now from where you got the run_dash.py :-), but you dont need it.

quick update. I guess i got it right on my repo, please try the widget from here:

The base_remote.js file needs a update too. Let me know if it works.