How to define a value based on different entities values?

Dear,
I have just added my heating via ebus to HA.
What I now want to do is to add a “state” sensor, which is based on certain sensor values.

To give you an impression - what I want to do something like this

If sensor.desired_temperature changes
Then
if newsensorvalue.desired_temperature matches sensor.absence_temperature then set sensor.heating_state to “Absence”
Else
if newsensorvalue.desired_temperature matches sensor.veto_temperature then set sensor.heating_state to “Quick Veto”
Else
set sensor.heating_state to “Time controlled”

I tried to get it working using automation with a starte change trigger. However, I seem to be lost in the further approach.

Can anyone please guides me on the right path?

Thank you,
Regards

Connor

Hi Philip,

Template - Home Assistant.

Template - Home Assistant.

@Sir_Goodenough

Thank you for your feedback. So templating seems the way to go. Since I did not work with this so far, I will have a look into what you shared.
One follow-up question - the state_sensor I described, would be a helper/ template one, right?

Hi, I hope I understand correct…

Yes, add helper template sensor called heating state, and set the template more or less like this:
(test template in dev tools first)

{% if states('newsensorvalue.desired_temperature')|int(0) == states('sensor.absence_temperature')|int(0)  %}
Absence
{% elif states('newsensorvalue.desired_temperature')|int(0) == states('sensor.veto_temperature ')|int(0) %}
Quick Veto
{% else %}
Time controlled
{% endif %}

@rekenaar : Thank you, you perfectly understood.
With this template, I was able to learn something and to settle my issue.
Thank you!

Nice!

Just a side note for version 2: you should probably first test availability of the sensors, otherwice the template would return the first option since int(0) means it will return 0 when the sensor is unavailable.

Thank you for pointing this out - but first of all a happy New Year.
If I was rather in my „comfort zone“ (I am working with the MS Power Platform rather than with Jinja2), I would have the another condition added like

{% if states(‘newsensorvalue.desired_temperature’)|int(0) == „unavailable“ %}
Check variable setting
{% elif states(‘newsensorvalue.desired_temperature’)|float(0) == states(‘sensor.absence_temperature’)|float(0) %}
Absence
{% elif states(‘newsensorvalue.desired_temperature’)|float(0) == states('sensor.veto_temperature ')|float(0) %}
Quick Veto
{% else %}
Time controlled
{% endif %}

Does this make sense from your perpective?

Hi, thanks and same good wishes for you.

I think it will work like that, but the “official” way would be as follow:

{% if not has_value(‘newsensorvalue.desired_temperature’)  %}