RF motion sensor with Shelly1 and esphome

Hello,

I’m asking for some example code that people are using with RF motion sensor via RF Bridge and the Shelly1 with esphome flashed on it.

The Shelly1 is flashed with esphome and installed behind one of my light switches.

I want to turn on the porch light when motion is detected by the motion sensor.

I can see both the Shelly1 and the motion sensor in Hass I just can’t seem to get the automation correct.

This is my first exposure to Hass so I’m still learning so I’m hoping I can learn from other people’s code that they’re using.

Any help would be much appreciated.

Thanks,
Chris

how about show us what you have already done.

does the RF motion send a ON when motion and then does it send a OFF no motion after A time frame

so the automation would look some like this

- id: Office Light On
  alias: Office Light On
  initial_state: true
  trigger:
  - entity_id: binary_sensor.office_motion
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: light.office
    state: 'off'
  action:
  - data:
      entity_id: light.office
    service: light.turn_on

thats the Starting point

here a other automation I have

#=======================================================================
- id: 'Garage Door Open Lights ON'
  alias: Garage Door Open Lights ON
  initial_state: true
  trigger:
  - entity_id: binary_sensor.garage_door
    platform: state
    to: 'on'
    for: '00:00:02'  # wind blow the door a bit
  - entity_id: binary_sensor.garage_side_door
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: sensor.day_night
    state: Night
  - condition: state
    entity_id: light.garage
    state: 'off'
  action:
  - data:
      entity_id: light.garage
    service: light.turn_on
  - delay: 00:10:00
  - data:
      entity_id: light.garage
    service: light.turn_off

hope this helps

The motion sensor sends an ON when motion is detected then I have it go off after 10 seconds.

I’ll try to get your code working for me.

Thanks for the info.

Like I said I’m pretty new to all this.

Will the code that you supplied look to see if the light is already on? The Shelly is behind a light switch so it might have been manually turned on.

I’m not sure if that will mess with the code above.

in the condition bit

  condition:
  - condition: state
    entity_id: sensor.day_night
    state: Night
  - condition: state
    entity_id: light.garage
    state: 'off'

above saying is it Night and the garge light is off when both are true do the next bit

thats the hard off is the off bit

Your logic should

if motion turn light on after a delay of ??? mins turn off then if more motion with in the ??? mins Extend the off longer hope that make cents

now this is something I can not get HA to do

BUT

I used nodered

this flow put a delay of 3mins
each time there is a motion it just send a new ON and reset the OFF
if no motion for 3min send the OFF

this is my work around works for me.

[{"id":"b70f2601.75f3d8","type":"debug","z":"88b0cdb8.1b02a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":180,"wires":[]},{"id":"d2afe3ce.63891","type":"delay","z":"88b0cdb8.1b02a","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":280,"wires":[["645b8ccf.d17ef4"]]},{"id":"4a18849.797197c","type":"mqtt out","z":"88b0cdb8.1b02a","name":"","topic":"nodered/motion","qos":"","retain":"","broker":"382381db.f5a70e","x":580,"y":100,"wires":[]},{"id":"f25fa27a.8e9b6","type":"function","z":"88b0cdb8.1b02a","name":"","func":"if (msg.payload ==\"ON\") {\n    msg.reset = true;\n    msg.payload = \"ON\"\n}\nelse{\n    \n    msg.payload = \"ON\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":100,"wires":[["4a18849.797197c","b70f2601.75f3d8","d2afe3ce.63891"]]},{"id":"41f90787.387518","type":"mqtt out","z":"88b0cdb8.1b02a","name":"","topic":"nodered/motion","qos":"","retain":"","broker":"382381db.f5a70e","x":580,"y":280,"wires":[]},{"id":"645b8ccf.d17ef4","type":"function","z":"88b0cdb8.1b02a","name":"","func":"if (msg.payload ==\"ON\") {\n    msg.payload = \"OFF\"\n}\nelse{\n    msg.payload = \"OFF\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":280,"wires":[["41f90787.387518","b70f2601.75f3d8"]]},{"id":"c8d8d2f6.e8e0c","type":"mqtt in","z":"88b0cdb8.1b02a","name":"Office Motion","topic":"stat/SONOFF-FAN/POWER","qos":"2","datatype":"utf8","broker":"382381db.f5a70e","x":110,"y":100,"wires":[["f25fa27a.8e9b6"]]},{"id":"382381db.f5a70e","type":"mqtt-broker","z":"","name":"Hassio MQTT","broker":"192.168.1.240","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Great,

I’ll try your code.

Thanks for the help