Hello everyone,
I am pretty new to home assisstant but already love the possibilities it gives me with my smart home setup (Philips Hue, Sonos Speakers, Logitech Harmony, Flic Hub, Shelly Covers etc.).
I am currently trying to create an automation for my Hue lights. The plan is as follows:
I have ~50 lights in my appartment in differenz zones (rooms)
there are multiple motion sensors, each one in every room
now I would like to create an automation which gets feeback from the motion sensors, hands over the specific room to a script which will then be called in order to get the details about the light setup (brightness, color, duration etc.)
so I have to setup a automation for each motion sensor, but they all can call the scripts which I then define for each time framte of the day I want the lights to be
Can someone maybe help me to understand why I get an error message with the following setup:
Script: Light_Day:
sequence:
- service: light.turn_on
metadata: {}
data:
color_temp: 360
brightness_pct: 100
target:
entity_id:
- script-var-zone
mode: single
fields:
script_var_zone:
selector:
entity:
multiple: false
name: script-var-zone
description: Übergabe der anzusteuernden Zone aus der Automation an das Script
required: true
Automation: Motion Sensor which shall call the script:
alias: "Auto: Light_Day - Motionsensor - Wohn- und Esszimmer"
description: >-
Die die Bewegung des Motionsensors greift auf die Automation zurück, welche
das das Script "Day" für die Tageslichthelligkeit aufruft und damit die
Zielentity ansteuert
trigger:
- type: motion
platform: device
device_id: 87c73bfc24d541d9f934d3a103799992
entity_id: 9a9cb0415dec0c274de38175d27c0ef1
domain: binary_sensor
condition: []
action:
- service: script.light_day
data:
script_var_zone: light.wohn_esszimmer_hue_zone
mode: single
When I run the script I get the following error message:
So I guess I did something wrong with the variable… but don’t know how to resolve it.
I run HASS 12.4 with the 2024.6.3 core. The hue lights are bined together through a Zigbee Group (Zone) within the Hue App itself, since I use the Hue Hub.
You are using a light turn on to call a script.
Light turn-on needs to turn on lights.
Scripts are a service calls and you can add the data to the end of them.
when you try to use an inbound argument (field), first, you need to use the variable name, not hte firnedly name (script_var_zone) then also you need to evaluate it in a template so that the system knows you mean the variable script_var_zone and not the string “script_var_zone”
i presume {{script_var_zone}} will always evaluate to a light entity. otherwise you’ll hit the issue that isn’t not going to be goodenough, sir. (@Sir_Goodenough )
sequence:sequence:
- service: light.turn_on
metadata: {}
data:
color_temp: 360
brightness_pct: 100
target:
entity_id: |
{{ script_var_zone }}
mode: single
fields:
script_var_zone:
selector:
entity:
multiple: false
name: script-var-zone
description: Übergabe der anzusteuernden Zone aus der Automation an das Script
required: true
What do you mean with: need to evaluate it in a template"? What template?
Yes, your assumption is correct: I want to always evaluate to a light entity.
Since I am a really new beginner, is it maybe advisable that I smart with less complex automations? E.g. automate each sensor with one automation which triggers all needed szenarios throught this one automation and will be configured via the GUI by me?
And thanks for the tip in regards of the entitiy_IDs
each person learns their own way, but if you’re a total beginner, i do think there’s a lot you can learn by doing automations that are most or all done via the gui, then go look at the resulting yaml and learn from that.