Thanks, but that is not what I am trying to do. I want to use an !include directive with the variables itself, not the packages
You might review the different alternative include
mechanisms here https://www.home-assistant.io/docs/configuration/splitting_configuration#advanced-usage if youāve not seen it.
The include mechanisms are generic in the YAML parsing, not specific to any component.
So maybe you could use incude_dir_merge_named ../variables
with the way you have each individual file constructed per your example?
Thatās what I thought, and I am familiar with the directives but I must have been looking at it for too long that I did not see the wrong include I tried (copy/paste from another file in my config). Thanks for pointing it out and making my look twice (more actually)
Has anyone gotten this working with 0.89.1?
Iām getting the following error:
Traceback (most recent call last):
File ā/usr/src/app/homeassistant/setup.pyā, line 154, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
AttributeError: module ācustom_components.variableā has no attribute āsetupā
Iāve moved the variable.py into custom_components/variable/variable.py and also created an empty init.py
Works for me in custom_components/variable.py.
No need for this, because this is no modified core component.
Ah, thanks for this. I must have misunderstood, and thought this was ultimately going to be required for all custom components.
since ha 92.0 I get this error
Unable to find services.yaml for the variable integration
I think is related to this https://github.com/home-assistant/home-assistant/issues/23197
Itās just a warning.
Create an empty services.yaml
in your custom_components folder and itās gone.
donāt we need a manifest.json, and/or init.py from HA 92.2 upwards? Asking because being at the verge of upgrading my systemHub instanceā¦
No, this cc works without it.
Only the services warning on HA start.
Setting attributes seems broken since a few versions.
Looks like @rogro82 stopped working on it.
?? really? thatās the crux of this component isnāt it?
you mean this isnt available any longer:
action:
service: variable.set_variable
data:
variable: last_motion
attributes_template: >
{
"history_1": "{{ variable.state }}",
"history_2": "{{ variable.attributes.history_1 }}",
"history_3": "{{ variable.attributes.history_2 }}",
"history_4": "{{ variable.attributes.history_3 }}",
"history_5": "{{ variable.attributes.history_4 }}"
}
data_template:
value: >
{{ trigger.to_state.attributes.friendly_name }}
still going strong on 91.2ā¦
Sorry, attributes work.
Need some more coffee!
no worries, thanks for confirming this component is still doing its job! waiting for 92.2 to kick in any time soon now.
just merged https://github.com/rogro82/hass-variables/pull/21
can anyone please confirm this is working as expected? I still need to upgrade HA myself
HI
since this is in the CC folder itself and not in a custom_components/variable subfolder, wonāt the init.py and manifest.json files interfere with other components that reside there?
Or should we move your CC to a dedicated sub folder after all now? I have the custom_updater reside there alsoā¦
@Mariusthvdb, create the variable folder in custom_components and copy the three files in it.
(ha) homeassi:~$ ll .homeassistant/custom_components/variable/
insgesamt 20
-rw-rw-r-- 1 homeassi homeassi 6890 Mai 2 16:28 __init__.py
-rw-rw-r-- 1 homeassi homeassi 212 Mai 2 16:28 manifest.json
drwxrwxr-x 2 homeassi homeassi 4096 Mai 2 16:29 __pycache__
-rw-rw-r-- 1 homeassi homeassi 814 Mai 2 16:28 services.yaml
yes I have done so. Was merely asking since since the Great Migration all custom components are in their own subfolder with the init.py and manifest.json files, and their names arenāt referencing the CC any longer. Which might/will interfere when other components are in that folder too.
A dedicated /variable subfolder would be the logical way forward?
Does this component still work? Iām completely stumped. I have an automation which launches fine but simply wonāt set anything in the variables. I have tried all the templates in the template editor and they all return the values perfectly, but the variable just refuses to pick them up. Iāve verified the variable exists and the sensors are all named correctly. Is there something else I can do to debug this? Is there any length limitations for the attributes?
- id: posta_state_change
alias: 'Posta state change'
hide_entity: true
initial_state: 'true'
trigger:
platform: state
entity_id: sensor.cp_packages_coming_today
condition:
condition: state
entity_id: 'sensor.cp_packages_coming_today'
state: 'delivery'
action:
service: variable.set_variable
data:
variable: posta_variable
value_template: "{{ states('sensor.cp_packages_coming_today')}}"
attributes_template: >
{
"from": "{{ state_attr('sensor.cp_packages_coming_today', 'from') }}",
"date": "{{ state_attr('sensor.cp_packages_coming_today', 'date') }}",
"subject": "{{ state_attr('sensor.cp_packages_coming_today', 'subject') }}",
"body": "{{ state_attr('sensor.cp_packages_coming_today', 'body') }}"
}
Iām not sure about the attributes (never used them), but at least you need to use data_template
instead of data
.