#HA is automatically removing quotes
1 messages · Page 1 of 1 (latest)
That doesn’t make any sense that it would break your automation. What’s the error message?
It just doesn't trigger anymore. But my other automation that has command: "on" triggers correctly
If you edit it in YAML, try wrapping it single quotes and see if that helps.
Hmmm, are you sure that event is still being passed?
Like, if you listen to the event in dev tools > events, do you see that actual event?
I just tested, it even passed with command: on. I think I have to take another look at the move_with_on_off event...
No wait never mind
When I change "on" to on, HA automatically puts it back to "on" after I click on save
What in the lord
lol that’s how the formatter works in the backend when you save an automation in the UI. It gets… interesting.
Where can I edit it in the backend?
Because this is really annoying, it changes my script without me wanting it to
If it’s an automation, edit automations.yaml. If it’s a script, it’ll be scripts.yaml.
Hard core mode enabled. lol Just note that if you open it in the UI, it’ll reformat again.
- id: '1730497282918'
description: ''
triggers:
- event_type: zha_event
event_data:
command: "move_with_on_off"
trigger: event
This is my script in the file browser addon
event_type: zha_event
data:
device_ieee: 60:a4:23:ff:fe:65:a1:38
unique_id: 60:a4:23:ff:fe:65:a1:38:1:0x0008
device_id: e6ee87cbd9fdf50f2d238ab03461a25d
endpoint_id: 1
cluster_id: 8
command: move_with_on_off
args:
- 0
- 50
params:
move_mode: 0
rate: 50
origin: LOCAL
time_fired: "2024-11-01T22:11:44.815880+00:00"
context:
id: 01JBMWHM1FXXENTB8XQX8QX0FF
parent_id: null
user_id: null
And this is the event
But it's just not triggering
With or without quotes
Why do you think it matters if it has quotes or not?
It shouldn't matter AFAIK.
"on" is wrapped in quotes because it has special meaning in yaml syntax (it's interpreted as a boolean)
Because the automation that has "on" works correctly but this one that can't have quotes doesn't work
Even though the trigger matches the event
I still wonder if the event data is really what it should be. Like I said, watch the event in dev tools and make sure it’s actually passing that data.
on is special. That doesn't apply to move_with_on_off
I'm subscribed to the zha_event in the dev tools and the last piece of code is the event that was fired from the switch
These are identical in yaml:
command: move_with_on_off
command: "move_with_on_off"
Thanks for the explanation, that's so odd that the automation isn't working then
The trigger event is matching the event fired by zha_event
FYI I just tried this (I have an ikea button that also fires move_with_on_off)
Seems to trigger fine
trigger: event
event_type: zha_event
event_data:
command: move_with_on_off
Yeah so my problem was that the unique_id changes at the end from 0x0006 to 0x0008
And therefore it didn't find the matching data and it errored out on the conditional statement
But thanks for your help!
If I have another question, do I post it here or do I make a new thread?
So I have this list in every automation related to my Zigbee switches:
bc:33:ac:ff:fe:6d:ff:39:1:0x0006: light.silicon_labs_ezsp_gameroom bc:33:ac:ff:fe:6d:ff:39:1:0x0008: light.silicon_labs_ezsp_gameroom
There's a lot more but I only show the first two to give an easy example. Can I somehow convert this into a global list that the automations can pull data out of or do I have to input this list in every automation?
Because adding a new light would mean I'd have to add the light to every list in every automation that has the list
You could create a template sensor with an attribute for that. You’d still have to template it in your automations and cast it to a list, but that’s how I’d do it.
Can the template sensor be made in the GUI or do I have to go back into the config files for that?
Trying to set it up right now but it's not going too well 😂
For an attributes sensor, it’d have to be in YAML. Sensor states only support 255 characters. But, it’s pretty easy to do.
Hold on and I can give you something.
ChatGPT gave me this, but it doesn't work (though it gives me some information on what is the right direction)
template:
- sensor:
- name: "Light Mappings"
state: >
{
"bc:33:ac:ff:fe:6d:ff:39:1:0x0006": "light.silicon_labs_ezsp_gameroom",
"bc:33:ac:ff:fe:6d:ff:39:1:0x0008": "light.silicon_labs_ezsp_gameroom"
}
And then in my automation:
description: ""
triggers:
- event_type: zha_event
event_data:
command: "on"
trigger: event
conditions:
- condition: template
value_template: "{{ target is not none }}"
actions:
- target:
entity_id: "{{ target }}"
action: light.turn_on
variables:
unique_id: "{{ trigger.event.data.unique_id | default }}"
mappings: "{{ states('sensor.light_mappings') | from_json }}"
target: "{{ mappings.get(unique_id) }}"
Though unfortunately this doesn't work
- template:
sensor:
- name: Lights List
unique_is: lights_list
attributes: >-
list: [
{ "bc:33:ac:ff:fe:6d:ff:39:1:0x0006": "light.silicon_labs_ezsp_gameroom" },
{ "bc:33:ac:ff:fe:6d:ff:39:1:0x0008": "light.silicon_labs_ezsp_gameroom" }
]
Ugh... Don't use AI... it halluncinates and doesn't know recent HA things.
BUt, it was close.
But, what do you need to use a mapping like that for in the first place? zha_event shouldn't really be needed unless you are doing something kind of out of the ordinary.
Thanks, let me try this
Well, I used to have my Zigbee switches connected to my lights with Touchlink, but I also want to use adaptive lighting so every time I turned on a light, it would first go to whatever state it was what it was turned off and then adjust accordingly
Which was very annoying
So now I can make my Zigbee switches go through HA completely and have them adjust to adaptive lighting before the lights come on
Ahhhh... Adaptive lighting strikes again... lol
Hahahah
Will this last piece of code work with your list in my automation?
variables:
unique_id: "{{ trigger.event.data.unique_id | default }}"
mappings: "{{ states('sensor.light_mappings') | from_json }}"
target: "{{ mappings.get(unique_id) }}"```
Gotta change the name of the list of course
No. The from_json is wrong. You want to use {{ (state_attr('sensor.light_mappings', 'list') | list)[trigger.event.data.unique_id'] }} (I think).
This errors out:
variables:
unique_id: "{{ trigger.event.data.unique_id | default }}"
mappings: "{{ (state_attr('sensor.light_mappings', 'list') | list)[trigger.event.data.unique_id'] }}"
target: "{{ mappings.get(unique_id) }}"
Message malformed: invalid template (TemplateSyntaxError: unexpected char "'" at 84) for dictionary value @ data['variables']['mappings']
Remove the single quote after trigger.event.data.unique_id