Switching a light on basic time condition, but searching for timer brings only countdown results here

Hi,

I struggle to put in a simple automation.

I want a light to go on at 6:50 am and go off at 5:10 pm.

I can build a time condition like this (to prevent defining over midnight)

alias: lights_on_7to5
description: ''
mode: single
trigger:
  - platform: device
    device_id: ''
    domain: ''
    entity_id: ''
condition:
  - condition: not
    conditions:
      - condition: time
        after: '17:50'
        before: '06:50'
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
action:
  - service: switch.turn_off
    data: {}
    target:
      device_id: 2b85d044acd1733e937f68354146e74a

but what do I use as a trigger

and how does it get switched on?

Since I dont know the state, I cant just toggle it, I would need to check if its off, if so then toggle at 6:50am, other wise do nothing, and at 5:10pm the same, if its off, do nothing, if on, toggle.

Thanks.

Manne

From what you have described the times are the triggers. By using trigger ids and a choose action you can handle the on and off action simply:

alias: lights_on_7to5
description: ''
mode: single
trigger:
  - platform: time
    at: '06:50:00'
    id: on
  - platform: time
    at: '17:10:00'
    id: off
condition: []
action:
  - choose:
    - conditions:
        - condition: trigger
          id: off
      sequence:
        - service: switch.turn_off
          data: {}
          target:
            entity_id: switch.XXXX
    - conditions:
        - condition: trigger
          id: on
      sequence:
        - service: switch.turn_on
          data: {}
          target:
            entity_id: switch.XXXX
1 Like

@Didgeridrew thanks. Got that now.

Have a heating / ac with similar issue, any advice on this one?

alias: SM_heating/AC
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.office_temperature
    below: '20'
  - platform: numeric_state
    entity_id: sensor.office_temperature
    above: '22'
condition: []
action:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: or
                conditions:
                  - condition: time
                    after: '05:00'
                    before: '16:00'
                    weekday:
                      - mon
                  - condition: time
                    after: '06:50'
                    before: '15:00'
                    weekday:
                      - tue
                      - wed
                      - thu
                      - fri
              - condition: numeric_state
                entity_id: sensor.office_temperature
                below: '20'
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.officeheating
      - conditions:
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.office_temperature
                above: '22'
              - condition: time
                after: '10:00'
                before: '17:00'
                weekday:
                  - mon
                  - tue
                  - wed
                  - thu
                  - fri
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.office_ac
    default:
      - service: climate.turn_off
        data: {}
        target:
          entity_id:
            - climate.officeheating
            - climate.buro_ac
mode: single

I try to controll a generic thermostat.

I would like the heating to have temp condition boost from

mo 5-8
tu-fr 6-8

temp condition home
mo-th 8-16
fr 8-12

rest should be temp condition away

and only if the temp at evaluation is below the current set for home temp from the generic thermostat

If ac is on, then heat should be off (not just away) and vice versa.

For AC temp home time is mo-th 10-17 and fr 10-14
outside is away
AC only activated when temp at “forcast” sensor (I use one for cover control) is above 24°C

AC does not need to be a generic thermostat, a simple swicht is enough, the AC needs to be started manually anyway after each power resume. but I dont want the ac to run and then the heater to kick in, or run half the night and such things.

Thanks