Automation between a specific time and state sensor


finally i was able to retrieve my alarm pir sensors as binary_sensors in HA
they have a polling for every 5 sec, so to turn a light on in a room, its not suitable
but however, i can use them for other cool stuff

for example
if i wakeup in the morning, i want to turn on the music and turn on a light
so i want some specific conditions on this automation
condition1 : run only between 06.00 and 07.00 am
condition2: only on weekdays
condition3 : turn on, ONLY if offcourse my mediaplayer is not playing, otherwise i would have to many turn_on services, so only if state of is OFF

can anyone help me with those 3 conditions?

- alias: Pir sensor kitchen
  initial_state: on
    platform: state
    entity_id: binary_sensor.pir_sensor_1
    from: 'off'
    to: 'on'

plenty of choices
a) many separate conditions (don’t like in complex cases)
b) condition: template


And don’t forget to share the result with us :wink:

ow, ok , thats indeed well documented , ok that will do!


this should do it, we will see tomorrow :slight_smile:

- alias: Risco Living Opstaan
  initial_state: on
    platform: state
    entity_id: binary_sensor.risco_living
    from: 'off'
    to: 'on'
  - condition: time
    # At least one of the following is required.
    after: '06:30:00'
    before: '07:30:00'
      - mon
      - tue
      - wed
      - thu
      - fri
  - condition: state
    entity_id: sensor.harmony_state_off
    state: 'on'      
  - service: light.turn_on
    entity_id: light.keuken
  - service: switch.turn_on

why sensor.harmony_state_off and on? confusing… shouldn’t it be a binary_sensor then? :wink:
and initial_state: on isn’t normally needed

Yeah, it’s confusing indeed, when there is no activity on my harmony, that sensor is on :wink:

well, I got it but generally it’s a bad choice of name (as ideally it should be self-explanatory by itself, which is not in your case)… just saying :wink:

Yeah, I need to clean up some code :slight_smile:

1 Like