Turn lightstrip red if temperature is turned up

Hey Guys,

I am new to this forum but already gained some experience with Home Assistant but not so much with scripts and Automations not using the UI. However, my current project is challenging me quite a bit. so I hope you can help me out here.

my target is that if I turn up the desired temperature of my Homematic IP Thermostat, my Hue Lightstrip turns red and after 5 sec goes back into the same condition as it was before.

I am facing 2 major issues:

  1. how do I detect that the temperature was turned up and not down. I know only the way to detect the state change but not how to compare it with the previous state/attribute. Also comparing it to a certain threshold value will not help me here.
  2. How can I store the current state/attributes (color, on/off state, dimmer value) of my lightstrip BEFORE I turn it red. Reason for this is of course that I want the previous scene restored after 5s of red light.

It is basically both related to saving current values in another variable which I can compare something with.

Is that somehow possible with Home Assistant?

Thanks for your help in advance and have a great weekend.

Regarding your 1st question:

I don’t have Homematic IP, but Homematic (classic). The assigned “climate” entities provide two attributes of relevance:

  • temperature (Soll-Temperatur, target temperature)
  • current_temperature (Ist-Temperatur)

You could create a binary template sensor to compare temperature to current_temperature and report, if temperature becomes higher then current_temperature. Also, the Trend sensor might be worth a look.

Regarding your 2nd question I don’t have an answer. Creating scenes on the fly would be a possible solution, but unfortunately that’s not yet implemented.

1st

Trigger on any state change to temp. Then use a template condition to compare trigger.to_state and trigger.from_state.

2nd

Trickier. But I think you could start with setting the relevant attributes of your light into input_ entities. Then change light to red. Then delay. Then using input_ entities to restore.

Or create scenes on the fly.

2 Likes

Oh, it’s there? Fantastic.

This has been implemented more than a year ago:

Great Guys. Thank you very much. I’ll try right tomorrow with Trend and Scenes on the fly.

Yup. Creating a scene would be better.

Hey Guys,

back again. I just don’t get it to run. I am having issues with the binary Trend sensor: I set up 2 sensors according to the documentation page of the Trend function. one should become true when the living room temp is turned up and the other one should actiavate once it is turned down.

However, everytime I change the temperature on the thermostat in my living room, no matter which direction, both sensors turn true and hence my automation does not know what to do.

below is my code and as an example the logbook showing that both automations have been started because both binary trend sensors have turned true before at the same time.

What am I doing wrong? Help?? :weary:


# Binärsensor um zu prüfen ob Temperatur hoch oder runtergedreht wurde
binary_sensor:
  - platform: trend
    sensors:
      temp_down:
        friendly_name: "triggersensor_temp down"
        entity_id: climate.hmip_wohnzimmer
        attribute: temperature
        max_samples: 2
        min_gradient: -0.000005
        device_class: cold

  - platform: trend
    sensors:
      temp_up:
        friendly_name: "triggersensor_temp up"
        entity_id: climate.hmip_wohnzimmer
        attribute: temperature
        max_samples: 2
        min_gradient: 0.000005
        device_class: heat`