I am running Hassio on a Rasberry Pi, integrated with Alexa (an Echo Dot) via Haaska.
I have several input numbers in my config.yaml that I use to change the parameters of some of my scripts. I would like the ability to change an input number by telling Alexa to do so (rather than via Lovelace).
I found these two posts that seem to say that this can be done with a simple script (one them uses “input_slider”, which I believe is now the “input_number” component):
Based on these examples, I have the following in my config.yaml:
Did you get anywhere with this? I also have a use case (allowing my son to delete a variable number of chapters from an audiobook playlist so he doesn’t have to spend 10 minutes telling Alexa to skip forward one chapter at a time…)
I found a workaround using a light. Lights have 2 different attributes for brightness. There is “brightness” which is a value from 1 to 255 and “brightness_pct” which is the same value expressed as a percentage. That is, brightness_pct = brightness / 2.55 (e.g., brightness of 26 = brightness_pct of 10). When you tell Alexa to “set [light name] to X” it sets the light to X% brightness. Thus, you can give your light whatever name you want, and then have an automation that sets the value of an input number based on the brightness (or brightness_pct) of the light.
Three things to note. First, at the end of the automation, set brightness (not brightness_pct) equal to 1. This last step is necessary if you want to specify the same value two times in a row. I.e., without the last step, if you told Alexa to “Set [light name] to 4” two times in a row, it would work the first time, but the second time would not create a change in the state of the light (because it is already at 4%).
So the automation would not trigger.
Second, the condition at the beginning that brightness be > 1 is necessary to prevent the above-described last step from triggering the automation all over again.
Finally, this code will not work if you want to set the input number to zero. A brightness_pct of zero means the light is off, and if the light is off then HA thinks that the light has no brightness (or brightness_pct) attribute. So if you want to be able to set a number to zero, you would need some additional code.