rogro82 / hass-variables

Home Assistant variables component
236 stars 59 forks source link

Question: Template inside a variable #46

Closed poudenes closed 1 year ago

poudenes commented 3 years ago

Hi All,

Is it possible to do something like this:

adaptive_kelvin:
    value: "{{ states.switch.adaptive_lighting_sensor.attributes.color_temp_kelvin | round(0)}}"
    attributes:
      friendly_name: 'Adaptive Kelvin'
      icon: mdi:theme-light-dark

And use this variable "adaptive_kelvin" into automation? something like this:

- service: light.turn_on
   data:
     entity_id: light.livingroom_all
     brightness_pct: 100
     kelvin: "{{ [variable.adaptive_kelvin] }}"

kind regards,

poudenes commented 3 years ago

Nobody can tell me if this is possible?

Mariusthvdb commented 3 years ago

Have you tried?

Using states of the variables in my automations here without issues

poudenes commented 3 years ago

Have you tried?

Using states of the variables in my automations here without issues

Can you show me some code? I tried some things but im not that good in coding.. hehe

pdwonline commented 3 years ago

states.switch.adaptive_lighting_sensor.attributes.color_temp_kelvin should be something like: state_attr('switch.adaptive_lighting_sensor.attributes','color_temp_kelvin') Look at https://www.home-assistant.io/docs/configuration/templating#states