Week day as condition in automation?

Hi,
I have a automation that turns on the engine heater if the temperature goes below -5 celsius and if the time is 06:15 but not later than 08:00.
I also would like to state the days of the week when this automation should run. How do I do this?

- id: '12345678913354'
  alias: Engine heater on minus 5 or lower
  trigger:
  - below: '-5'
    entity_id: sensor.utomhustemperatur_temperature
    platform: numeric_state
  condition:
  - after: 06:15
    condition: time
  - before: 08:00
    condition: time
  action:
  - data:
      entity_id: switch.motorvarmare
    service: switch.turn_on

The Workday Binary Sensor should do the trick!

Scroll almost to the bottom to the “Time Conditions” section. You can select which days to run on there.

4 Likes

Thank you!
Do I need to add a “and” to the script now that I have two conditions in my automation? (Both temperature and time/day)

With conditions they default to and.

Ok, thanks for the reply!
Do you mean the “and” needs to be added or that it is added by the system by default?
However, as the script is right now it does not work.

you don’t need to add it because it is the default… If you have multiple conditions they are AND already so don’t need to be specified.

1 Like

Post the code as you have it now and let us know what you mean by “it doesn’t work”.

The code below works without condition. The switch will turn on if it is -5 degrees or less.
But I also want it to start at 06:15 and not later than 08:00.
When I added the conditions the automation stopped working.

- id: '12345678913354'
  alias: Engine heater on minus 5 or lower
  trigger:
  - below: '-5'
    entity_id: sensor.utomhustemperatur_temperature
    platform: numeric_state
  condition:
  - after: 06:15
    condition: time
  - before: 08:00
    condition: time
  action:
  - data:
      entity_id: switch.motorvarmare
    service: switch.turn_on

I have a similar automation for a light based on the sun angle…

My below triggers not in quotes. My after and before ARE in quotes.

It maybe your indenting for the action… also I think your condition with time being specified twice is not working!

- id: 'light'
  alias: Turn Lounge Light On Elevation < 25° & after 4PM
  trigger:
  - platform: numeric_state
    below: 25
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
  - platform: time
    at: '16:00:00'
  condition:
  - condition: time
    after: '16:00:00'
    before: '18:30:00'    
  - condition: template
    value_template: '{{states.sun.sun.attributes.elevation < 25}}'
  action:
  - service: light.turn_on
    data:
      brightness_pct: 75
      entity_id: light.lounge
      kelvin: 3100

(Note I have 2 triggers as I don’t want it going on in winter at 3pm lol)

- id: '12345678913354'
  alias: Engine heater on minus 5 or lower
  trigger:
  - platform: numeric_state
    below: -5
    entity_id: sensor.utomhustemperatur_temperature    
  condition:
  - condition: time
    after: '06:15'
    before: '08:00'
    condition: time
  action:
  - service: switch.turn_on
    data:
    entity_id: switch.motorvarmare
1 Like

Perfect, got it to work!
Thanks!

1 Like