Closed mikebannan closed 3 years ago
I found that my problems were due to a misunderstanding of how most relays (including mine) work:
I seriously doubt whether “most” relays work like that. Many have both NO and NC outputs (normally open vs normally closed) and whether you want to use reversed
really depends on which output you use, instead of on the relay.
But anyway, it’s a good suggestion to be more explicit how low and high are interpreted by default, and when reversed
is set. I’ve been meaning to add the boot/config.txt
setting to the Wiki, but haven’t got to that yet.
Done
I was new to Homebridge and the Raspberry Pi, and got a Pi specifically to control some switches with relays. After many hours of Googling, trial-and-error, and unnecessary homebridge-rpi tickets here, I found that my problems were due to a misunderstanding of how most relays (including mine) work:
0 (low) = on 1 (high) = off
homebridge-rpi provides a reversed config.json key, but no explanation of why this might be useful. In the trial-and-error stage of my project I found that setting
"reversed": true
worked, without knowing why it worked. But this had the unintended consequence of the switches setting themselves to on after a reboot. (Which my ignorance made baffling, since GPIO readall showed the pins driving 0 (low), which obviously meant off to me.)So, to help other ignorant people, I suggest the following addition to homebridge-rpi documentation in the wiki for devices that have the config.json
reversed
key:The
reversed
key is provided to accommodate relays that require 0 (low) for on and 1 (high) for off. This is true for most relays. To prevent such relays from turning on upon reboot you may also want to add a line to your boot/config.txt to set the pin to 1 (high); for examplegpio=12=op,dh
.(Thank you for your good work and deep patience, Erik!)