unfoldedcircle / integration-home-assistant

Home-Assistant Integration for Remote Two
Mozilla Public License 2.0
28 stars 5 forks source link

Allow to use HA Scripts as Button Entity #20

Closed splattner closed 1 year ago

splattner commented 1 year ago

Thank you for your contribution! The script support is working fine 👍 Please fix the cosmetic formatting issues reported by cargo fmt, then I will merge this PR. You can ignore the reported issue by Clippy, I've fixed that on the main branch.

The only thing we could discuss is to use a switch instead of a button for HA scripts. This would allow to:

  • stop a running script (at least according to the HA docs. I don't know if the script will be killed, or if it needs specific support to be stoppable).
  • see when a (long running) script is active on the remote.

For me personally it doesn't really matter right now. I still have to migrate everything to HA and I'm not using scripts yet (just a matter of time...).

thanks for reviewing it. Fmt errors are fixed, still new to Rust, that was my first code in rust ever ;)

I actually never had the need to stop a running scripts, mine are quite short. So for me, a button is enough. Yes, HA allows to stop a running script, there is a turn_on & turn_off and also a toggle service. And what I did here, is just calling it by name, which is what I did so far in HA. My personal opinion, I think its confusing to have this as a Switch, therefore I'd rather leave it as a Button. with only the the call by name.

uvjim commented 1 year ago

A quick question on this one now that it has been released... How do I pass parameters to the script that needs to be called? I can't seem to find that in the Web Configurator.

zehnm commented 1 year ago

How do I pass parameters to the script that needs to be called?

That is currently not possible. For now, HA scripts can only be triggered. Supporting parameters will require more work, most likely with a new entity type, which supports dynamic parameters.

Since this PR is merged, let's continue in #20