Combine two temp sensors, only at certain time

I have two temperature sensors.
I want to create a new sensor that records the value of sensor 1, except in the hours between 07:00 and 12:00. At that interval record sensor 2 instead.

How to achieve that?

Use two template sensors triggered at the times you want.

Template sensor set up in the UI under Helpers with a state template of:

{{ states('sensor.temp2') if 7 <= now().hour < 12
   else states('sensor.temp1') }}

If this is an outside temperature sensor compensating for sun load, can you just take the smaller value? I have an east- and a west-facing sensor, and taking the smaller value works well.

personally, i would do it via the ui.

go here:

choose template

then choose template sensor (not binary sensor)

name it something and for the state template put this:

{{  states('sensor.your_sensor_1')  if today_at('07:00') < now() < today_at('12:00') else states('sensor.your_sensor_2') }}
1 Like

Thanks for all good replies, this is perfect. Chose to use the simple solution from @armedad