#Use automation with variable from device
1 messages ยท Page 1 of 1 (latest)
alias: DZ_to_HA_Lamellen
description:
Wanneer Woonkamer_lamellen_domoticz device update. voer dit uit om
Encoder device
trigger:
- platform: state
entity_id: cover.lamellen_woonkamer_domoticz
attribute: current_position
condition: []
action:
- device_id: de795fe62b675208ec96755b4f630652
domain: cover
entity_id: cover.woonkamer_lamellen
type: set_position
position: 5
mode: single
this is what i have now. but the Position line at the bottom that says 5. should be the position that cover.lamellen_woonkamer_domoticz is set to
i tried replacing the 5 by trigger.attribute or cover.lamellen_woonkamer_domoticz.current but then the automation goes into error after reloading
You can use a template there to retrieve the value from the entity that triggered it. You have the right idea, just the wrong syntax.
{{ trigger.to_state.attributes.current_position }}
Something like that should do it.
The trigger object has (amongst other things), an object for the new state and the previous state of the triggering entity.
so every time you want to use a variable you need to put it into {{ }} (this is jinja2 notiation right?)
Yes, that's Jinja. More on that over in #templates-archived. But the trigger object is unique to automations, and that page I linked gives you more help.
i tried a few things but it keeps saying configuration invalid
in "/config/automations.yaml", line 16, column 0```
Share your automation again with the new template.
i forgot the double quotes ๐
I thought so ๐
JSON is valid inside YAML, so it thought you were just giving it another object.
how can i debug what the automation is doing? is there a way to see the full content of the trigger object when it ran?
alias: DZ_to_HA_Lamellen
description:
Wanneer Woonkamer_lamellen_domoticz device update. voer dit uit om
Encoder device
trigger:
- platform: state
entity_id: cover.lamellen_woonkamer_domoticz
attribute: current_position
condition: []
action:
- device_id: de795fe62b675208ec96755b4f630652
domain: cover
entity_id: cover.woonkamer_lamellen
type: set_position
position: "{{ trigger.attributes.current_position }}"
mode: single
is what i currently have. but when i reload automations and go to automations the automation is disabled and i cant enable it
You've given it an ID, which means you can use the trace tool to see the trigger object and anything else your automation references. But first, you have to get it enabled and run it at least once ๐
What does the command line config check say? Don't trust the UI one.
there is a command line config check ? ๐
I can't do the bot commands here, take a look in the main channel
on the link given by the bot i can not find a command to run on the cli
https://www.home-assistant.io/docs/configuration/troubleshooting/#problems-with-the-configuration
on the webui though if i go to logs it says
value must be one of ['close', 'close_tilt', 'open', 'open_tilt', 'stop'] for dictionary value @ data['type']. Got None. (See /config/configuration.yaml, line 8).
but it seems to me like this is not the real issue. since if i replace my variable by the number 5 it works as expected. so the set_position type should be valid
If might be a false positive. If there's no real trigger, the template won't give a value.
How did you install HA?
loaded the qcow2 file into a proxmox vm
oh no. i tried that but in the end i found a script on github that downloaded HA and created a new VM in proxmox
HA OS then. From the command line (I have no idea how you get there), run ha core check
okay so i ran the automation once while i set the variable back to the static 5
then looked at the debug.
so the object would be trigger.to_state.attributes.current_position
but it seems like as soon as i add a template to the automation the automation wont load with the error i gave above
Ah... you're using device actions ๐
The best advice we can give you about that is: don't.
Get used to using the services exposed by the individual integrations. It'll be something like cover.set_position for covers.
dont expect me to know what im doing. only installed HA today ! ๐
You're doing fine already.
The UI prefers to generate device triggers and device actions. They're not intuitive and there's little to no documentation on them.
You can get way more clever once you have more stuff added to your HA instance but you've nailed the basics. Templates and service calls are the core of almost anything you'll do.