My goal is to get a value from a sensor (temperature) and do some math with it and add this new value to a variable.
Afterwards I like to get the value of this variable back in an automation.
I am confused with the use of variables:
- how do I have to initialize a variable in automation.yaml? Is this an extra service?
- how can I update the variable with a new value?
- how can I use this variable in the action of the automation?
My example is this one:
- id: '1613935335031'
alias: Temperature to RGB
description: ''
trigger:
- platform: state
entity_id: sensor.unk_manufacturer_unk_model_b2bd6c22_temperature
condition: []
action:
- service: variable.set_variable
data:
variable:
- service: light.turn_on
entity_id: light.tz3000_dbou1ap4_ts0505a_level_light_color_on_off
data:
brightness: <variable here>
rgb_color:
- 0
- 0
- 255
mode: single
I like to set the temperature in a variable, do some calculations and then update the variable with the new calculated value.
Is this a good entry point for my questions?