You need: âaction: call-serviceâ after tap_action, before âservice: browser_mod.commandâ.
Not sure why your script wonât work though.
Also, tap_action shouldnât be a list.
- type: entity-button
entity: light.family_room
name: TEST
tap_action:
action: call-service
service: browser_mod.command
service_data:
command: blackout
# deviceID:
# - 871bd80d-09d34d4a
No pressure, no hassle and certainly no expectation, but can I ask if this is something you might be looking into?
I only ask so that I know whether to re-think my plans or whether to wait and see if there might be a solution.
Thanks.
It sounds to me like the problem isnât in browser_mod, but that your interface loses its websocket connection to the backend.
Maybe your device goes into some kind of sleep mode?
Maybe your wifi gets disconnected on inactivity to save power?
Iâm no expert on the FullyKiosk settings, I just set and forget it more than a year agoâŠ
Ok, thanks for the response.
I can believe it is an issue with my tablet. It was cheap oneâŠ
Can I ask what you use?
The cheapest I could find. Wouldnât recommend it.
Thank you! My sample works now. I knew I had to be missing something, I just couldnât find it.
I think my problem was I was trying to piece together a working code without a complete working example. I just submitted a proposed addition to your README that could help.
I am using a script to trigger a browser_mod popup card however when I use
deviceID:
- this
the popup doesnât show when called through the script however this does work if I just use it inside say an entity-button in lovelace. If I list the actual devices in the script the popup will show as expected. Is there a reason why the â- thisâ parameter will not work within a script?
Ultimately when using a device list the popup shows on all connected devices which would be okay if I could get it to close on all devices once itâs closed on one device but they remain open. I also tried adding a close popup step in the script but it did not close all popups once it was closed on one device. I assumed using â- thisâ would only show it on the device that called it but it doesnât seem to be working that way, at least in a script. Is there any work around for what I am trying without duplicating the script for each device?
The script is run in the backend, and canât know from where it was called.
However, there is indeed a workaround for this. Since the latest version browser_mod will replace this
with the current deviceID in any service call which has deviceID
in its data.
So if you change your script to have
deviceID: {{deviceID}}
and call it from the frontend using
tap_action:
action: call-service
service: script.my_script
service_data:
deviceID: [this]
it should work.
Is this the correct syntax for the script? Or is that suppose to be a list of the various device_idâs
- service: browser_mod.command
data:
command: popup
deviceID: {{deviceID}}
I am receiving this message:
Error loading /config/configuration.yaml: invalid key: âOrderedDict([(âdeviceIDâ, None)])â
in â/config/script/script.yamlâ,
Ah yes, sorry. You need to replace data
with data_template
for that to work, I believe.
hmmm, same error message
*edit - I got past the error message by adding single quotes deviceID: â{{deviceID}}â
Unfortunately it didnât make a difference. The popup still appears on all devices.
Ah. Qoutes!
deviceID: "{{ deviceID }}"
Does this need quotes too? - > deviceID: [this]
Actually, this isnât working the way I expected. Let me get back to youâŠ
Ok. Now Iâve thought it through.
What you need in your script is
data_template:
command: popup
deviceID: ["{{ ','.join(deviceID) }}"]
title: ...etc...
Unfortunately now the popup is not appearing.
- Edit - just to add some clarification. The first part of the script runs because the prior popup closes but the new popup doesnât show.
set_alarm_time_popup:
alias: Set Alarm Time Popup
sequence:
- service: browser_mod.command
data:
command: close-popup
- service: browser_mod.command
data_template:
command: popup
deviceID: ["{{ ','.join(deviceID) }}"]
Tested and working: https://github.com/thomasloven/hass-browser_mod/wiki/Cookbook#displaying-a-popup-via-a-script
It seems the script is not executing this time because the prior popup is not closing now. Is version 11 the latest of the browser_mod? Not sure what is different and why itâs not working.
(*Edit - after thinking about it the script maybe is called but the deviceID isnât being passed?? so the script doesnât execute?? Not sure how to determine if the deviceID is being passed to the script.)
Script:
set_alarm_time_popup:
alias: Set Alarm Time Popup
sequence:
- service: browser_mod.command
data_template:
command: close-popup
deviceID: ["{{ ','.join(deviceID) }}"]
- service: browser_mod.command
data_template:
command: popup
deviceID: ["{{ ','.join(deviceID) }}"]
Calling Script
- type: entity-button
entity: script.set_alarm_time_popup
name: Change Alarm Time
icon: mdi:sleep
tap_action:
action: call-service
service: script.set_alarm_time_popup
service_data:
deviceID:
- this
I tried removing the brackets and the script ran but I was back to having the popup show on all devices. Thoroughly stumped why itâs not working and it seems to match your example.