Hi,
I’m new to the HA, only poked around for like for 2 weeks. I’m configuring one Intent to be used from Alexa. I’m missing something that seems trivial.
To simplify I’ll only use one light.
I first tried this code:
TurnGoLightIntent: action: service_template: > light.turn_{{ OnOff }} data_template: entity_id: light.go brightness: > {% if Brightness is defined %} {{Brightness}} {% else %} 255 {% endif %}
This will work when {{OnOff} is On but if I try to turn off the light it will say “Invalid slot information received for this intent.”. From my research, I’m getting that because of the light.turn_off service doesn’t have the brightness data.
So I split the service template with scripts, something like this:
TurnGoLightIntent: action: service_template: > {% if OnOff == "On" %} script.light_go_on {% else %} script.light_go_off {% endif %}
Now I can turn off the light but when I try to turn on it goes always to the “default” value (the else part). The {{Brightness}} variable isn’t set in the script:
light_go_on: sequence: - service: light.turn_on data_template: entity_id: light.innr brightness: > {% if Brightness is defined %} {{Brightness}} {% else %} 255 {% endif %}
Does anyone have a solution to this?
- A solution without using scripts making a conditional around the data that doesn’t work with some service. In this case, the brightness of the service light.turn_off.
- A solution that passes the Alexa intents variables values to the scripts. In this case, {{Brightness}}
I have also another issue, if I don’t put the default value 255 it will also give the error when the command doesn’t go with a brightness value. I would like to when I don’t specify a brightness it turns the light with the previous brightness (without the brightness data it works like that). I’ve tried using something like this: states.light.go.attributes.brightness, but doesn’t work.
Thanks,