I’m having trouble getting an intent script to work with both Lights and Switches because of the extra data fields that my lights have. I’m using Snips to run an intent script to turn on my lights; some of which are z-wave switches and some of which are z-wave lights and LIFX lights. The switches are just on/off devices, but the lights have brightness as an available parameter. Currently, my script looks like this:
ActivateLightColor:
speech:
text: Turning {{ objectLocation | replace(" ", "_") }} on
card:
type: simple
title: Turn object off
content: Ask Home Assistant to turn {{ objectLocation | replace(" ", "_") }} on
action:
service_template: >
{%- if objectLocation.lower() in ['testing', 'main'] -%}
light.turn_on
{%- else -%}
homeassistant.turn_on
{%- endif -%}
data_template:
entity_id: >
{%- if objectLocation.lower() in ['kitchen', 'main', 'testing'] -%}
light.
{%- elif objectLocation.lower() in ['living room'] -%}
group.
{%- elif objectLocation.lower() in ['entry', 'porch'] -%}
switch.
{%- endif -%}
{%- if objectLocation.lower() in ['kitchen'] -%}
kitchen_lights
{%- elif objectLocation.lower() in ['entry'] -%}
entry_way_switch
{%- elif objectLocation.lower() in ['testing'] -%}
lifx_1
{%- elif objectLocation.lower() in ['main'] -%}
ge_14294_inwall_smart_dimmer_level
{%- endif -%}
color_name: {{ objectColor }}
The service template is working correctly and is letting me use the two services, but I can’t pass the color_name parameter to a switch. I’m not sure what the best way to tackle this is. I’d rather not have to set up different intents because all of the entities are (in reality) lights, so requiring the word switch to differentiate them will be troublesome for guests who don’t know which are which. So I’m looking for a way to structure an intent_script such that it checks the objectLocation against a list, if it’s not in the list, call homeassistant.turn_on with objectLocation as the entity_id; if it is in the list, call light.turn_on with the entity_id as well as the color_name and brightness parameters.
Does anyone know if this is possible?