Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
manonstreet opened this issue Jan 18, 2024 · 8 comments
Closed

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

manonstreet opened this issue Jan 18, 2024 · 8 comments
Assignees
Labels
Available in Beta Release An issue that is resolved or is awaiting community testing in a published beta release enhancement New feature or request

Comments

@manonstreet
Copy link

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 manonstreet added the enhancement New feature or request label Jan 18, 2024
@PRProd
Copy link
Owner

PRProd commented Jan 21, 2024

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

@PRProd
Copy link
Owner

PRProd commented Jul 8, 2024

@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 added a commit that referenced this issue Sep 6, 2024
v4.0.4b1

For Testing:
 - New Chromecast Remote colors (#480)
 - Accept var/field data in custom launcher scripts (#293, #467, #470)

Can't see these changes after updating? Visit this link:
https://github.com/PRProd/HA-Firemote/wiki/Force-a-Refresh
@PRProd
Copy link
Owner

PRProd commented Sep 6, 2024

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 PRProd added the Available in Beta Release An issue that is resolved or is awaiting community testing in a published beta release label Sep 6, 2024
@manonstreet
Copy link
Author

manonstreet commented Sep 7, 2024

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!

@PRProd
Copy link
Owner

PRProd commented Sep 7, 2024

@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 PRProd closed this as completed in 8c38254 Sep 7, 2024
@PRProd
Copy link
Owner

PRProd commented Sep 7, 2024

@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.

@manonstreet
Copy link
Author

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

@PRProd
Copy link
Owner

PRProd commented Sep 8, 2024

Yay! That's great!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Available in Beta Release An issue that is resolved or is awaiting community testing in a published beta release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants