mariva
June 24, 2025, 2:25pm
1
Hi,
i tried to set global config/vars that i can use within automations or scripts.
currently i tried
- sensor:
- name: "storen_data"
state: "active"
attributes:
data: >
{{ {
"bath": {
"entity_id": "cover.storen_1_aebt_storen_1_gaestebad",
"azimuth_min": 135,
"azimuth_max": 225,
"position_default": 100,
"tilt_default": 100,
"position_vor_abends": 0,
"tilt_vor_abends": 30,
"position_abends": 0,
"tilt_abends": 0,
"position_nacht": 0,
"tilt_nacht": 0,
"position_sonnenschutz": 0,
"tilt_sonnenschutz": 40,
"window_sensor": "sensor.custom_fenster_status_gaestebad",
"automation_active_sensor": "input_boolean.storen_automatic_gaestebad_fenster"
},
Autocomplete for this sensor works, and some test sensors function as well.
I’m trying to save the configuration as JSON, or I wish I could set the configuration in a YAML file.
i try to geht the data with :
{{ (state_attr(‘sensor.storen_data’, ‘data’)) }}
Hello mariva ,
The easiest is to use helpers
Input number - Home Assistant .
Input text - Home Assistant .
Input boolean - Home Assistant .
Otherwise there is this:
This was posted earlier here . I’ve added some improvements, mostly to avoid errors, and also added some additional stuff suggested by @erkr in this post
It can happen you want to store some data to use it in another automation, or make sure it’s still available after a restart of HA. You can use helpers for that (eg and input_text entity) but these are limited in which types you can store, and they can be easily edited in the GUI.
The configuration below creates a trigger based templates senso…
You can use the custom_templates for that.
They can be actual templates, or just plain strings disguised as templates
mariva
June 24, 2025, 2:43pm
4
hi, thank you.
is it not possible to set “custom” yaml files for example?
i think its a bit messy to use helpers esp. if i have to use it for each window
mariva
June 24, 2025, 2:46pm
5
i tried this.
in my configuration.yaml
template: !include_dir_merge_list custom_templates
then i used. the “template sensor” as shown above.
but my “data attribute is empty.”
wish i could store the config in yaml. i thought thats the purpose of yaml.
storen:
gaestebad:
entity_id: cover.storen_1_cec9_storen_1_gaestebad
azimuth_min: 135
azimuth_max: 225
position_default: 100
tilt_default: 100
position_vor_abends: 0
tilt_vor_abends: 30
position_abends: 0
tilt_abends: 0
position_nacht: 0
tilt_nacht: 0
position_sonnenschutz: 0
tilt_sonnenschutz: 40
window_sensor: sensor.custom_fenster_status_gaestebad
automation_active_sensor: input_boolean.storen_automatic_gaestebad_fenster
after i tried {{ storen.xyz.azimuth_min }}
Your template isn’t closed…
mariva
June 24, 2025, 2:50pm
7
yes, because its only a crop the actual json/config is very long
Well if you cut off half of the coding, then how can
mariva
June 24, 2025, 2:52pm
9
data: >
{{ {
"gaestebad": {
"entity_id": "cover.storen_1_cec9_storen_1_gaestebad",
"azimuth_min": 135,
"azimuth_max": 225,
"position_default": 100,
"tilt_default": 100,
"position_vor_abends": 0,
"tilt_vor_abends": 30,
"position_abends": 0,
"tilt_abends": 0,
"position_nacht": 0,
"tilt_nacht": 0,
"position_sonnenschutz": 0,
"tilt_sonnenschutz": 40,
"window_sensor": "sensor.custom_fenster_status_gaestebad",
"automation_active_sensor": "input_boolean.storen_automatic_gaestebad_fenster"
}
} | tojson }}
You should be able to use YAML:
yaml</s> <s>#custom_templates.yaml</s> <s>- sensor:</s> <s> - name: "storen_data"</s> <s> state: "active"</s> <s> attributes:</s> <s> data: </s> <s> gaestebad:</s> <s> entity_id: cover.storen_1_cec9_storen_1_gaestebad</s> <s> azimuth_min: 135</s> <s> azimuth_max: 225</s> <s> position_default: 100</s> <s> tilt_default: 100</s> <s> position_vor_abends: 0</s> <s> tilt_vor_abends: 30</s> <s> position_abends: 0</s> <s> tilt_abends: 0</s> <s> position_nacht: 0 </s> <s> tilt_nacht: 0</s> <s> position_sonnenschutz: 0</s> <s> tilt_sonnenschutz: 40</s> <s> window_sensor: sensor.custom_fenster_status_gaestebad</s> <s> automation_active_sensor: input_boolean.storen_automatic_gaestebad_fenster</s> <s>
123
(Taras)
June 24, 2025, 2:57pm
11
Store the desired data as a dictionary using YAML.
EDIT : Ninja’d by Didgeridrew
EDIT2: This doesn’t work; see post below .
Example
- sensor:
- name: storen_data
state: active
attributes:
data:
bath:
entity_id: cover.storen_1_aebt_storen_1_gaestebad
azimuth_min: 135
azimuth_max: 225
position_default: 100
tilt_default: 100
position_vor_abends: 0
tilt_vor_abends: 30
position_abends: 0
tilt_abends: 0
position_nacht: 0
tilt_nacht: 0
position_sonnenschutz: 0
tilt_sonnenschutz: 40
window_sensor: sensor.custom_fenster_status_gaestebad
automation_active_sensor: input_boolean.storen_automatic_gaestebad_fenster
mariva
June 24, 2025, 2:58pm
12
i tried, but my studio-code editor said:
Incorrect type. Expected "string".yaml-schema: http://schemas.home-assistant.io/integration-template
View Problem (Alt+F8)
You can’t always believe those warnings… save the file, reload the config or restart HA then check it in the template editor tool.
mariva
June 24, 2025, 3:07pm
15
i tried , doesnt work.
{{ (state_attr(‘sensor.storen_data’, ‘data’)) }}
123
(Taras)
June 24, 2025, 3:08pm
16
I don’t get those errors in VS Code.
Go to Developer Tools → YAML and select Check Configuration. If you get no errors, proceed to execute Reload Template Entities. Then check Logs for errors.
mariva
June 24, 2025, 3:10pm
17
yep, this is what i always do , just to be sure
still there is no config data available. i tried Developer Tools → Template
Edwin_D
(Edwin D.)
June 24, 2025, 3:12pm
18
If you tried it and it doesn’t work, there are errors in the log or the yaml file isn’t loaded to begin with. Any errors?
mariva
June 24, 2025, 3:15pm
19
looks like the value has to be a string …
This is working for me:
- sensor:
- name: "storen_data"
state: "active"
attributes:
data: |
{{ {"gaestebad": {
"entity_id": "cover.storen_1_cec9_storen_1_gaestebad",
"azimuth_min": 135,
"azimuth_max": 225,
"position_default": 100,
"tilt_default": 100,
"position_vor_abends": 0,
"tilt_vor_abends": 30,
"position_abends": 0,
"tilt_abends": 0,
"position_nacht": 0,
"tilt_nacht": 0,
"position_sonnenschutz": 0,
"tilt_sonnenschutz": 40,
"window_sensor": "sensor.custom_fenster_status_gaestebad",
"automation_active_sensor": "input_boolean.storen_automatic_gaestebad_fenster"} } }}
Then:
{{state_attr('sensor.storen_data', 'data').gaestebad.azimuth_min}}