Time of Day heating blueprint/selecting time of day

I’ve got a bunch of binary Sensors

- platform: tod
  name: MORNING
  after: "05:00"
  before: sunrise

- platform: tod
  name: DAY
  after: sunrise
  before_offset: "-01:00"
  before: sunset

- platform: tod
  name: EVENING
  after: sunset
  after_offset: "-01:00"
  before: "22:00"

- platform: tod
  name: LATEEVENING
  after: "22:00"
  before: "23:00"

- platform: tod
  name: NIGHT
  after: "23:00"
  before: "05:00"

I’ve got automations that trigger of the change to DAY and to do something. Working well.

But I want to be able to evaluate “what is my current tod”. In my brain that needs to be a “thing” that I can ask is it DAY or is it MORNING.

I’ve tried putting them in a group:

times_of_day:
  name: Times of Day
  entities:
    - binary_sensor.NIGHT
    - binary_sensor.MORNING
    - binary_sensor.DAY
    - binary_sensor.EVENING
    - binary_sensor.LATEEVENING

But I’m not sure thats what I want either. Ultimately I want to use these in a blueprint for heating (shamelessly pulled from : Home Assistant Blueprint For Heating (github.com) ) , so I can say, if DAY then here is a threshold to use for heating, if MORNING then here is a different threshold for heating.

Here’s the trigger part of the blueprint where i’m trying to evaluate for the user having selected binary_sensor.DAY that I’m in that time period.

trigger:
- platform: homeassistant
  event: start
- platform: event
  event_type: automation_reloaded
- platform: time_pattern
  minutes: /1
action:
- choose:
  - conditions:
    - condition: numeric_state
      entity_id: !input 'temp_sensor'
      below: !input 'min_temp'
    sequence:
    - service: input_boolean.turn_on
      target:
        entity_id: !input 'heating'
  default:
  - service: input_boolean.turn_on
    target:
      entity_id: !input 'heating'
mode: single

Its the condition other than temperature I’m trying to figure out.

1 Like

Copy-paste the following template into the Template Editor:

{{ expand('group.times_of_day') | selectattr('state', 'eq', 'on') | map(attribute='name') | first }}

You can use that template to create a Template Sensor. It can be used in a State Trigger.

And I assume once it’s template sensor it can also be used for conditions?

So in my blueprint the user has chosen DAY then I can evaluate template sensor = user input

So I’ve made the following blueprint. The time of day sensor (I think is working properly). I don’t really know what I’m doing, just sort of hacked around.

Ideally I’m hoping to end up with an automation per binary_sensor with thresholds for each.
So I need to compare the current time of day = the users inputted binary sensor.

Here’s a gist Heating blueprint for time of day · GitHub

Yes, for conditions and/or triggers.

Did the suggested template produce the desired result? Do you need help creating a Template Binary Sensor with it?

No that was enough to get me going thanks.

Now moved on to the blueprint. Maybe I’m trying to run before I walk. But I already know how I like to use my heating based on the rules have in openhab, so I’m trying to replicate those.

1 Like