rsg98 / homebridge-gpio-wpi2

Homebridge Raspberry Pi GPIO Platform (API 2) Plugin - using WiringPi as a backend
48 stars 16 forks source link

polling is not working #25

Closed firaskhf closed 7 years ago

firaskhf commented 7 years ago

Hi first thank you for the amazing work that you're putting on this plugin. I have an issue that i hope you can help me with. I have i PIR sensor that's connected on gpio6 pin 25, the problem is that i can't see the status of the pir unless i close and reopen the home app or swipe up on my iphone. as if the polling is not working, and i was unable to invert the status of it. Any suggestions? this is how i'm configuring it { "name" : "GPIO6", "pin" : 25, "enabled" : "true", "mode" : "in", "pull" : "down", "inverted" : "false", "duration" : 0, "polling" : "true" a request: I was wondering if u can add PIR Sensor or motion Sensor to the Type. Regards.

rsg98 commented 7 years ago

Can you try it with "polling": "false"?

It should trap events for input pins, so the more clunky polling mechanism isn't required.

Can you confirm the version of the module, homebridge and wiringpi package that you've got installed? On Mon, 3 Jul 2017 at 12:25, firaskhf notifications@github.com wrote:

Hi first thank you for the amazing work that you're putting on this plugin. I have an issue that i hope you can help me with. I have i PIR sensor that's connected on gpio6 pin 25, the problem is that i can't see the status of the pir unless i close and reopen the home app or swipe up on my iphone. as if the polling is not working, and i was unable to invert the status of it. Any suggestions? this is how i'm configuring it { "name" : "GPIO6", "pin" : 25, "enabled" : "true", "mode" : "in", "pull" : "down", "inverted" : "false", "duration" : 0, "polling" : "true" a request: I was wondering if u can add PIR Sensor or motion Sensor to the Type. Regards.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rsg98/homebridge-gpio-wpi2/issues/25, or mute the thread https://github.com/notifications/unsubscribe-auth/ARe_tSg6zZKkZ7n_jGtXL6Cl3SeaxwFHks5sKM-igaJpZM4OMKfF .

firaskhf commented 7 years ago

ok so i managed to fix the polling issue by making a clean install. now with poll on or off the response back to the home app in fixed. but still unable to invert the status of the PIR. with no motion the sensor shows OPEN, while with motion it shows closed. i want it the other way. any suggestions? note that override cache and autoexport is true

rsg98 commented 7 years ago

Do you have overrideCache set to true? (Example in the ReadMe) - homebridge caches the values you set, so if the first time you tried it, you hadn't set inverted to true, it might be ignoring your change.

firaskhf commented 7 years ago

yes overrideCache is set to true. you mean i need to set it as False?

rsg98 commented 7 years ago

No, you have it set correctly, so I guess it's not that. In one of the closed issues I described how to clear the cache manually -

https://github.com/rsg98/homebridge-gpio-wpi2/tree/hardware-pwm-support#i-get-duplicate-pins-after-i-rename-them-or-the-plugin-is-ignoring-my-settings

On Tue, 4 Jul 2017 at 14:04, firaskhf notifications@github.com wrote:

yes overrideCache is set to true. you mean i need to set it as False?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/rsg98/homebridge-gpio-wpi2/issues/25#issuecomment-312872925, or mute the thread https://github.com/notifications/unsubscribe-auth/ARe_tby2A6jBtM0OfaOf59LEF1iz2JMlks5sKjhVgaJpZM4OMKfF .

firaskhf commented 7 years ago

i deleted everything in cachedAccessories file and restarted homebridge, still the same.

rsg98 commented 7 years ago

Just to double check - you need to stop homebridge, delete, then start (otherwise it cleverly replaces the cache!)

What type of PIR do you have and how are you wiring it up to the Pi? On Wed, 5 Jul 2017 at 12:15, firaskhf notifications@github.com wrote:

i deleted everything in cachedAccessories file and restarted homebridge, still the same.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/rsg98/homebridge-gpio-wpi2/issues/25#issuecomment-313074304, or mute the thread https://github.com/notifications/unsubscribe-auth/ARe_tduQAa-6z0LplzhO0LtvxEf5uvY3ks5sK3BlgaJpZM4OMKfF .

firaskhf commented 7 years ago

this what i did actually. regarding the pir it's the HC-SR501 PIR MOTION DETECTOR Data sheet: https://www.mpja.com/download/31227sc.pdf

rsg98 commented 7 years ago

Sorry - got my head back in the right place now!

I think this was fixed by @jdtsmith in a1550b666aad4b1ded84ded6bdcbc8d93e83b79d - but I haven't yet published an updated module to npm (because I thought I'd have finished the other upgrades by now, but not much free time at the moment!)

If you can find GPIOAccessory.js under node_modules / homebridge-gpio-wpi2, try removing the line:

sysfs.activeLow = (!self.inverted * 1);

The fix that @jdtsmith supplied (#22) provides a good explanation of what's going on with my broken logic...

firaskhf commented 7 years ago

ok so i added the 2 slashes to the line to deactivate it //sysfs.activeLow = (!self.inverted * 1); then made sure homebridge is stopped, deleted everything in cachedAccessories file, made sure overrideCache set to true, and of course "inverted" : "true", . unfortunately it's still the same. showing Open (contact sensor) by default, and when it detects movement it changes to closed. could it be because it's type is Contact Sensor? regards

rsg98 commented 7 years ago

It should be ok as a contact sensor. Does setting the inverted option in the configure file have any effect? On Wed, 5 Jul 2017 at 20:19, firaskhf notifications@github.com wrote:

ok so i added the 2 slashes to the line to deactivate it//sysfs.activeLow = (!self.inverted * 1); then make sure homebridge is stopped, deleted everything in cachedAccessories file, made sure overrideCache set to true. unfortunately it's still showing Open (contact sensor), and when it detects movement it changes to closed. could it be because it's type is Contact Sensor? regards

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/rsg98/homebridge-gpio-wpi2/issues/25#issuecomment-313200281, or mute the thread https://github.com/notifications/unsubscribe-auth/ARe_tSL7iMZ_pnsxgFKm-PyjlTvofrcEks5sK-G0gaJpZM4OMKfF .

firaskhf commented 7 years ago

So i figured out what was the problem regarding the invert state of the PIR. before it was showing as OPEN in the home app. what i wanted was to invert that state. i tried changing inverted state and pull state in the config.json file but with no luck. what i realized is that whenever you want to change a state in the config.json file, you need to clear the cachedAccessories file before starting homebridge. even if "overrideCache" is set to true.

What i tried and worked for me was as follows: stopped homebridge, then cleared the cachedAccessories file, then i changed the state of "inverted" from false to true, finally i restarted homebridge again. voilà it worked :)

Hope sharing this will help anybody.