Combine Workday Sensor with Time

Hi,

I would like to combine the Workday Sensor with time. I have this automation:

- id: 'Week'
  alias: Week
  trigger:
  - platform: numeric_state
    entity_id: sensor.hz_temp
    below: 21
  - platform: time
    at: '05:15:01'
  - platform: time
    at: '08:15:01'
  condition:
    condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.hz_temp
      below: 21
    - condition: or
      conditions:
        - condition: time
          after: '05:15:00'
          before: '22:15:00'
          weekday:
            - mon
            - tue
            - wed
            - thu
            - fri
        - condition: time
          after: '08:15:00'
          before: '22:15:00'
          weekday:
            - sat
            - sun
  action:
  - device_id: b379fb57788d44baa998b6a5a4589835
    domain: switch
    entity_id: switch.heater
    type: turn_on

The Heater should not start before 05:15 in the week but when its a holiday the time should be like the weekend or something else.

Thanks in advance!

Create a Workday Binary Sensor for your country and province/state:

binary_sensor:
  - platform: workday
    country: your country code
    province: your province code

The sensor’s default is all weekdays are workdays (sensor will indicate on) and all other days (weekends and holidays) are not (sensor indicates off).

Your condition needs to implement the following logic:

(temp < 21) AND 
  (
   ((workday = on) AND (5:15 < time < 22:15)) OR 
   ((workday = off) AND (8:15 < time < 22:15))
  )

Try this:

- id: 'Week'
  alias: Week
  trigger:
  - platform: numeric_state
    entity_id: sensor.hz_temp
    below: 21
  - platform: time
    at: '05:15:01'
  - platform: time
    at: '08:15:01'
  condition:
    condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.hz_temp
      below: 21
    - condition: or
      conditions:
      - condition: and
        conditions:
        - condition: state
          entity_id: binary_sensor.workday_sensor
          state: 'on'
        - condition: time
          after: '05:15:00'
          before: '22:15:00'
      - condition: and
        conditions:
        - condition: state
          entity_id: binary_sensor.workday_sensor
          state: 'off'
        - condition: time
          after: '08:15:00'
          before: '22:15:00'
  action:
  - device_id: b379fb57788d44baa998b6a5a4589835
    domain: switch
    entity_id: switch.heater
    type: turn_on
2 Likes

Awesome, thanks alot for your help! :+1: :smile:

1 Like