How can I detect the PIR status?

hello
I flashed tasmota on a nodemcu. I connected a PIR to this nodemcu.

I would like to use that PIR as a switch.

My PIR updates only the value inside the circle but not the switch icon.

thank you in advance for your kind support and help. :slight_smile:

The PIR is an input. It is a binary sensor not a switch. A switch is an output.

Thank you tom_l,
I connected PIR to the GPIO14 and set it as a Switch, this is why I tried to configure it as a switch.
Is it correct to set as a switch and read it as a binary sensor?

Ok now I begin to understand.

In HA a switch is a control you can use to toggle an associated output device (like a relay) on or off.

In Tasmota a switch is an input you can use to control a relay.

You have no relay connected to the nodemcu, so there should be no switch in HA to control it. Just the binary sensor to read the Tasmota switch (PIR) state.

Did you use discovery or did you write yaml to set up the nodemcu in HA?

By the way, a better option than Tasmota might be esphomeyaml.

It is very simle to flash the device using a Hassio addon:

Sensors are defined using simple yaml code, like the PIR for example:

There are a lot of other devices just as easy to configure:

1 Like

Thann you,
now I begin to understand too :slight_smile:

The PIR is configured as Switch in NodeMCU flashed Tasmota (ok)
The PIR is configured as Binary Sensor in HA, I wrote yaml. Below my configuration:

binary_sensor:

  • platform: mqtt
    name: “Presence Detection”
    state_topic: “tele/node_casetta/SENSOR”
    payload_on: “ON”
    payload_off: “OFF”
    device_class: moving
    expire_after: 1
    value_template: ‘{{ value_json.Switch1 }}’

image

And it works! presence detection works but doesn’t not seem working in real time, it works like a polling.
I tried to move my hand once fast in front of the PIR and the sensor detect but HA doens’t see anything.
Thoughts?

I don’t have any experience with Tasmota on a nodemcu, only on sonoff devices. They react in practically real time.

Watch this, it shows how to use Tasmota with a PIR on nodemcu. Basically, Don’t use switch1 use switch 2.

I really think you’d be better off with esphomeyaml on the nodemcu though.

I’ m watching the same video suggested by you right now :slight_smile:
thankl yuo so far, very appreciated!

From the video, I think your problem is that you should be using switch2, not switch1.