Hi Guys.
I have a sonoff basic with Tasmota firmware. I have a PIR connected to GPIO3 (can use 14 if need be) I do not want to use PIR to trigger the sonoff relay. I am only using Sonoff as means of using MQTT to be able to set some automatons using MQTT and or Service calls.
So when the motion sensor triggers, I would like it to send a message to turn a hue light on, in daughter’s bedroom via a automation.
I have the following in Binary Sensor yaml file
This is the binary senor in States. It does not change. When PIR is triggered, the STATE always shows “off” It does not change to “On”
binary_sensor.jessroom_motion Off friendly_name: JessRoom Motion device_class: motion
What am I doing wrong and how can I get this work so the State changes when the PIR motion is active? Then I can setup the Automations for it
As per “digiblur” youtube video, there are some rules setup
rule2 on switch3#state=1 do publish JessRoom/PIR/state YES endon on switch3#state=0 do publish JessRoom/PIR/state NO endon
I am still learning and slowly understand all the workflows and functions
Thanks everyone in advance everyone.
Ok so
Module Type Sonoff Basic (1)
GPIO1 = Switch 3n = PIR
GPIO3 = Switch 1(9) = Push Button
GPIO14 = Switch 2n = Not in use at present
MQTT settings
Host = IP address of HA
Port = 1883
Client = DVES_%06X
User = brucys
Password = my password
Topic = jessroom
MQTT enabled
First of all try to format your code using three ` characters before and after your blocks, so we can better read what you wrote.
Second, does your sonoff connect ok to the mqtt server on hassio? is there an MQT connection message in the tasmota console? You could monitor this from HA’s side if you install an mqtt add-on if you are using hassio or by connecting to the borker with an mqtt client where you can monitor if the tasmota’s messages are being broadcasted.
Third, I dont see why you have created a rule to change your mqtt messages on the sonoff.
I personally did like this (but i dont have a button switch as i see in your configuration, just the PIR):
On tasmota, you need to enter the switchtopic comand in order to differentiate your PIR (switch/sensor) topic with the sonoff’s relay topic.
So whatever you have set as a topic in the mqtt settings of tasmota, you need to set something different for to be sent when the PIR is triggered.
For the sonoff relay to work you need to go like this:
My relay topic set in the tasmota gui is sonoff_stairs, which means that my switch is configured with the topic cmnd/sonoff_stairs/power like this:
I see you have already set it up as switch 3n which is ok i guess, but the commands would be inverted (? that’s the n part i think)
You need to differentiate the PIR topic from the Relay topic as mentioned above. This is done with the switchtopic command. In my case switchtopic: motion/stairs/dn. This will make your tasmota publish this message whenever the pir is activated cmnd/motion/stairs/dn/POWER1 (ignore the /dn/ part, i have two pirs on my stairs).
Following this documentation, go to your console and set up the PIR correctly. Set switchmode1 acordingly, to turn on/off when motion is detected, in my case i set it to switchmode1: 1
Get your mobile phone on the console screen and go see if the messages are published correctly when you flap your hands (that’s the fun part!!)
Then you need to set up the binary switch to listen to that topic, like this:
(the /+/ part is a wild card that will listen to both my topics, cmnd/motion/stairs/dn/POWER1 and cmnd/motion/stairs/up/POWER1, you just set it to what you set as switchtopic above)
Again, i noticed you have a button switch hooked up, the info i gave you will work with just the PIR set up. Maybe disable the pushbutton configuration until you figure out the PIR and take it from there)