Puck.js Lite button release event

Posted on
  • Hi,

    In my quest to find a way to know if a door is locked, I stumbled on the very promising Puck.js project.
    The Puck.js Lite is small (enough), simple and efficient and would be able to do all I need, except possibly one thing: fire a button release event.

    The idea is to mount the Puck inside the door casing, replace the button with an external one and position the button in the strike plate hole in such a way that it is only pressed by the deadbolt when the door is locked.
    As far as I can tell, by looking at the examples and Home Assistant integration, there are only pressed events available (single, double, long, etc.). For my concept to work, I'd like the Puck to fire an event when the button is pressed (door being locked), and an event when the button is being released (door being unlocked).

    While it might not be the 'normal' purpose of the device, is there already a button release event available, despite it not being included in the documentation?
    If not, is it possible to introduce this event?
    If yes, will this still be in an energy efficient way? Not that there's some permanent activation taking place due to the way the hardware is currently set up. We are talking about presses that can take minutes/hours/days/weeks in the end.

  • Hi - so you're asking specifically about the BTHome being able to send a 'release' event to Home Assistant with https://www.espruino.com/BTHome ?

    Because to detect a button release, you just use setWatch with edge:"falling" instead of edge:"rising"

    For BTHome, what's supported is just what's shown on: https://bthome.io/format/

    We implement most of that, and there is no 'release' event. I think you have two options really:

    • don't use events - for example you can just tell BTHome to advertise {type:"locked", v:true} - and then I think you can just detect when that value changes in Home Assistant, and fire something off based on that?
    • Have two events - a 'door locked' event and a 'door opened' event

    ... or you could ask the BTHome devs if they want to add a new event type, but that could take a while!

    Just a note but Puck.js (Lite or Normal) has a bunch of spare GPIOs pins on it that are easily accessible - so there's no need to replace the button, you just wire things up to the other pins that are already there

  • Darn, I should have dug into the BTHome specs a bit more first. I did not expect the protocol itself actually lacking such an event.

    Thank you for the alternative suggestions, much appreciated.
    It does make things all a bit more uncertain. The idea is to use a Shelly Plus 2PM as a Bluetooth gateway. This should pick up the Puck button press/release and pass it to Home Assistant. Though Shelly docs on this functionality is limited to non-existent. I'd have to inquire about it to make sure that they don't impose some limitation on what kind of messages/events can be passed along.
    Your BTHome docs make it look promising though.

    I was going to say that by looking at your BTHome implementation, it will be throwing an exception when I just introduce an unknown type/property like "locked". But you were referring to 'cheating' with the BTHome "lock" sensor property, which you actually renamed to "locked". I suppose that'll do just fine indeed.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Puck.js Lite button release event

Posted by Avatar for user157746 @user157746