What is the best way to turn on a light with a pir sensor?

what is the best way to turn on a light with a pir sensor?
But if the light is on, the pir sensor should not send repeated commands to turn the light (f it is already on)

I would rather keep them ON, and turn them ON manually. Just do not want that a 433MHz signal is fired all the time, if the switch is still ON

EDIT I do this especially because HA and the hardware is not 100% reliable, and old grandma can’t stay in the kitchen without light, it is dangerous. SO to turn automatically on is nice (if it fails there is the manual swith as always), but if it switvhes off, for no good reason, there is a problem. So I rtather turn it off ONLY manually (but do not want the the trigger always send a ON command, if the light is still ON)

So add a condition that the light is off.

what I would need to add?

# motion Kitchen
  - alias: "Motion Kitchen"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_1cc3
        from: 'off'
        to: 'on'
    condition:
      - condition: sun
        after: sunset
    action:
      - service: switch.turn_on
        data_template:
          entity_id: switch.kitchen

You can have multiple conditions. Add a condition that checks the state of your light. Search the forum for an example of how to use multiple conditions.

like this?

# motion Kitchen
  - alias: "Motion Kitchen"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d000127acc3
        from: 'off'
        to: 'on'
    conditions:
      - condition: sun
        after: sunset
      - condition: state
        entity_id: switch.kitchen
        state: 'off'
    action:
      - service: switch.turn_on
        data_template:
          entity_id: switch.kitchen

little problem is that is a switch 433MHz, so not sure the state is correct (it should, but)

I tried this, but is not working (the sensor I see triggering in HA, but light not turning on), are there any errors???

  - alias: "Motion entrance strip light"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.neo_coolcam_battery_powered_pir_sensor_sensor_2_0
        from: 'off'
        to: 'on'
    condition:
      - condition: sun
        after: sunset
    action:
      - service: light.turn_on
        data:
          entity_id: light.foyer_strip
      - delay: '00:01:00' 
      - service: light.turn_off
        data:
          entity_id: light.foyer_strip
#

The sensor show is triggered in HA front end
If I trigger the automation manually the light go on

But alone the automation is not working. Is the code? How to troubleshoot?

Anyone?

I have 3 automation based on pir, and none works… man…

You could try this- alias: BedRoom1 Motion turn on lamp initial_state: True trigger: - platform: state entity_id: binary_sensor.BedRoom1_motion from: 'off' to: 'on' condition: - condition: sun after: sunset - condition: state entity_id: light.BedRoom1_light state: 'off' action: service: light.turn_on entity_id: light.BedRoom1_light

You sure about conditions like that?
In instructions they say to use the AND

Both ways seem to work from me.

  • alias: BedRoom1 Motion turn on lamp
    initial_state: True
    trigger:
    • platform: state
      entity_id: binary_sensor.BedRoom1_motion
      from: ‘off’
      to: ‘on’
      condition:
      condition: and
      conditions:
    • condition: sun
      after: sunset
    • condition: state
      entity_id: light.BedRoom1_light
      state: ‘off’
      action:
      service: light.turn_on
      entity_id: light.BedRoom1_light

Check your spacing because things change with copy and paste

you can use the preformatted icon of the editor

ok.- alias: BedRoom1 Motion turn on lamp initial_state: True trigger: - platform: state entity_id: binary_sensor.BedRoom1_motion from: 'off' to: 'on' condition: condition: and conditions: - condition: sun after: sunset - condition: state entity_id: light.BedRoom1_light state: 'off' action: service: light.turn_on entity_id: light.BedRoom1_light

I tried copy paste before you cancelled, I also have a mi flora which makes a nice addition

I had some formatting issues :slight_smile: So you have the code?

No, did not manage.

if you press this, you can format the code, and is easier to copy paste (just add a first blank line, the select first line and all the code, then press the button </> )

- alias: Esszimmerdecke abends an initial_state: True hide_entity: False trigger: platform: event event_type: motion event_data: entity_id: binary_sensor.motion_sensor_156d0001305exx condition: condition: and conditions: - condition: time after: '19:00:00' before: '23:00:00' - condition: sun after: sunset - condition: numeric_state entity_id: sensor.Esszimmer_Miflora_light_intensity below: 100 action: - service: script.turn_off entity_id: script.timed_diningroom_lamp_timer_off - service: scene.turn_on entity_id: scene.esszimmer_abends - service: script.turn_on entity_id: script.timed_diningroom_lamp_timer_off