Closed pvklink closed 5 months ago
My code:
service: var.set
data:
entity_id: var.batteries_replaced
attributes:
"{{ trigger.entity_id }}": "{{as_timestamp(now()) | timestamp_custom('%Y-%m-%d') }}"
I don't know if your code is correct or not.
This is my guess at what your code's choose:
might look like...
- choose:
- conditions:
- condition: or
conditions:
- condition: template
value_template: "{{ debug == 'scenes_unlock' }}"
- condition: and
conditions:
- condition: template
value_template: "{{ debug == 'scenes_single' }}"
- condition: template
value_template: "{{ actiontrigger == 'input_boolean.scene_opstaan' }}"
sequence:
service: var.set
data:
entity_id: var.e1
value: 2
Hi,
Yes, the sequence you reproduced is same as mine… Problem is that the declaration of a variable is not global (one value in all situations) when you give it values in or out a choose condition….
Verzonden vanuit Mail voor Windows
Van: Daniel Verzonden: zaterdag 9 december 2023 02:45 Aan: snarky-snark/home-assistant-variables CC: peter van klink; Author Onderwerp: Re: [snarky-snark/home-assistant-variables] global versus local...(Issue #104)
You can't have two different instances of the same named variable & different values.
My code: service: var.set data: entity_id: var.batteries_replaced attributes: "{{ trigger.entity_id }}": "{{as_timestamp(now()) | timestamp_custom('%Y-%m-%d') }}" I don't know if the code is correct. This is my guess at what your code's choose: might look like...
I solved the issue with another variables integration… https://github.com/enkama/hass-variables With this integration i can set variables regardless where i change them in or out a choose construction
Verzonden vanuit Mail voor Windows
Van: Daniel Verzonden: zaterdag 9 december 2023 02:45 Aan: snarky-snark/home-assistant-variables CC: peter van klink; Author Onderwerp: Re: [snarky-snark/home-assistant-variables] global versus local...(Issue #104)
You can't have two different instances of the same named variable & different values.
My code: service: var.set data: entity_id: var.batteries_replaced attributes: "{{ trigger.entity_id }}": "{{as_timestamp(now()) | timestamp_custom('%Y-%m-%d') }}" I don't know if the code is correct. This is my guess at what your code's choose: might look like...
Yes, the sequence you reproduced is same as mine… Problem is that the declaration of a variable is not global (one value in all situations) when you give it values in or out a choose condition….
That's bizarre!
I solved the issue with another variables integration… https://github.com/enkama/hass-variables With this integration i can set variables regardless where i change them in or out a choose construction
I also have just switched another variable of mine to that integration as I was trying to save & restore attributes in a variable and it just plain was not working no matter what I tried. I either couldn't alter the attribute or when I could, they would vanish on a restart.
Can variables made global, even if they are declared in a choose scenario? In the below (part of my) script i update the var e1 two times, At the start and when a condition matches... My problem is that i want to overule the first declaration within a choose construct, at the end of the script the first declaration is available...
What am i doing wrong"
I use he latest HASS beta on a docker on rpi 4b with the latest OS.
sequence: