'm not really getting why it says state
unknown
Would any of you be so kind to explain what I’m missing here? I’m not really sure how to send the state on the passed variable containing an input boolean through to tts.
This is my code:
# make sure you have created an entity called input_boolean.living_room_auto_lighting (or other name) as a helper.
# you can call this script in an automation or as a service call.
# pass the given variables as data so that the script knows what speaker and switchs to use
#
# service: script.auto_lighting_switch (or other name)
# data:
# entity_id: media_player.living_room_speaker
# switch: input_boolean.living_room_auto_lighting
alias: Auto Lighting - General Switch
sequence:
- service: media_player.turn_on
data: {}
target:
entity_id: '{{ entity_id }}'
- service: input_boolean.toggle
data: {}
target:
entity_id: '{{ switch }}'
- service: tts.cloud_say
data:
entity_id: '{{ entity_id }}'
message: Auto lighting is turned {{ states('{{ switch }}') }}
description: A script to set the auto lighting switch to on/of and TTS to a speaker.
fields:
entity_id:
description: Speaker
example: media_player.living_room_speaker
required: true
switch:
description: Switch
example: input_boolean.living_room_auto_lighting
required: true
mode: single
I’m getting this as a response:
Executed: March 15, 2022, 8:48:42 PM
Result:
params:
domain: tts
service: cloud_say
service_data:
entity_id: media_player.living_room_speaker
message: Auto lighting is turned unknown
target: {}
running_script: false
limit: 10