arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
467 stars 104 forks source link

HC SR04 support #30

Closed mpikoz closed 5 years ago

mpikoz commented 6 years ago

would really love to be able to use hcsr04 ultrasonic sensor to be able to tell if garage door open/closed. any chance support for this sensor might be coming?

mpikoz commented 6 years ago

If not, does anyone know of a homebridge plugin that does work with the HC-SR04 ultrasonic sensor to report it's distance measurement in homebridge?

arachnetech commented 6 years ago

You could use it with an ESP8266 - but note that for Garage Doors Homekit is only interested in a open/closed state so you wouldn't really get the benefits of a distance sensor.

mpikoz commented 6 years ago

Thank you for your response! There are several things that you could do though with the one sensor. If in the code you could define different measurements, you could tell if the door is open or closed and when closed whether a car is in the spot or not. Mine is mounted on the ceiling so that when the door is open I get a reading of 60cm and when the door is closed it reports 173cm. Whatever the difference between ceiling and floor would mean that no car is present etc. Heck each of the family cars is likely a different height so that you could probably get granular enough to be able to report who's car is in what slot in the garage. Appreciate your time and hard work on our behalf!

arachnetech commented 5 years ago

homebridge-mqttthing is only interfacing between MQTT messages and https://github.com/arachnetech/homebridge-mqttthing/issues/31, so unless I'm missing something if you want to use one of these sensors to detect the state of your garage door you can build one into an MQTT-speaking device and send the appropriate messages. mqttthing now supports decoding/encoding through user-defined JavaScript too, in which you could implement any required custom logic.

Closing for now, but please feel free to re-open if I've missed something.