HA-Firemote icon indicating copy to clipboard operation
HA-Firemote copied to clipboard

[Feature Request]: data support for scripts in custom launchers

Open manonstreet opened this issue 2 years ago • 2 comments

Is your feature request related to a problem?

No response

Feature Request

When working with a custom launcher, the yaml config supports both script and service. When calling service, the data key is passed to the service; however when using script, data is ignored. Scripts support variables in 2 different ways. One way is via service: script.turn_on, which works fine since data is passed in this case. The other option is via calling the script as a service, which I assume is what the script key is doing for firemote. In the latter case, variables are passed as arbitrary KV pairs via data. This currently does not work since data is not passed.

TLDR: Pass data key for both service and script calls.

Additional Comments (optional)

No response

manonstreet avatar Jan 18 '24 14:01 manonstreet

@manonstreet ~ Thanks for granting my request and repeating yourself by posting over here too. :smile:

PRProd avatar Jan 21 '24 18:01 PRProd

@manonstreet ~

Sorry for the lack of communication on my part. I haven't forgotten about this, just been busy with other things. I still want to implement your ideas. Thanks for your patience and understanding.

-Doug

PRProd avatar Jul 08 '24 16:07 PRProd

Good news @manonstreet!
CC: @ronfarbernewman

I just published a beta version v4.0.4b1 that I'd like for you to download and test. I'm 95% sure I did it right. 😄 This is how I tested:

Firemote YAML snippet

custom_launchers:
  - friendly_name: flash the light
    label: FLASH
    image_path: >-
      https://upload.wikimedia.org/wikipedia/commons/2/28/Flash-outlined-thin-circular-button.svg
    color: red
    background: white
    script: flashthelablight_with_vars
    data:
      color: green
app_launch_1: customlauncher flash the light

script flashthelablight_with_vars

flashthelablight_with_vars:
  fields:
    color:
      selector:
        text: {}
      default: white
      required: true
  alias: FlashTheLabLight With Vars
  sequence:
  - target:
      entity_id: light.ambient_light
    action: light.toggle
    data:
      color_name: '{{ color }}'
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - data: {}
    target:
      entity_id: light.ambient_light
    action: light.toggle
  mode: single
  icon: mdi:flash
  description: ''

This worked for me! I saw a flash of green, not white! Then I went crazy typing in various color names because I was happy it was working 😆

That being said, it's really only the 2nd day I've tried to use fields in a script (where have I been!?!) so I'm hoping that if it breaks in a more complex example, one of you will tell me about it? Please?

Hope to hear back from you soon! Thanks for your patience!

-Doug

PRProd avatar Sep 06 '24 22:09 PRProd

I did some quick testing, and the feature appears to work for custom_launchers actions; however it does not seem to work for button_override functions.

FYI - I am sending multiple variables to my script in my customer_launcher usage, it's working as expected.

Appreciate your efforts on this @PRProd!

manonstreet avatar Sep 07 '24 21:09 manonstreet

@manonstreet ~

Thanks for testing! So... technically, I did exactly what you asked for, but maybe not what you wanted, right? 😄 Have you ever heard the saying "Computers are dumb. They only do exactly what you tell them to do." Well, sometimes programmers are like that too, I had the dumb.

I'll make that update and publish another beta... or I'll just send it. Either way, thank you for your quick communication, and for your testing! I'll let you know!

-Doug

PRProd avatar Sep 07 '24 22:09 PRProd

@manonstreet & @ronfarbernewman ~

All done! I have just published Firemote version v4.0.4 which contains this enhancement request. Enjoy!

-Doug


After updating to the newest version, if you are unable to see the new updates on your Firemote card, visit this link for help.

PRProd avatar Sep 07 '24 23:09 PRProd

Updated 4.0.4 and confirmed working for both custom launchers and button overrides. Thanks so much 🙏.

manonstreet avatar Sep 07 '24 23:09 manonstreet

Yay! That's great!

I'm happy to help! Sorry it took so long

PRProd avatar Sep 08 '24 00:09 PRProd