Looks good, although I guess you could keep advertising battery/temperature even when the button is pressed, and should probably advertise 0x0F/btnData.state all the time so home assistant knows the button is there all the time, just not pressed?
the advertised count reverting to 0 after the button is pressed doesn't seem fast enough
What exactly isn't it fast enough for?
It's actually a bit unfortunate that they chose to do buttons this way, because it feels like either you have a short timeout and you risk the button press getting never received, or you have a long one and potentially other devices think the button is pressed more than once. If the button had been advertised as a 'press count' that just incremented when the button was pressed things would have been much easier - no timeout would be needed.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Looks good, although I guess you could keep advertising battery/temperature even when the button is pressed, and should probably advertise 0x0F/btnData.state all the time so home assistant knows the button is there all the time, just not pressed?
What exactly isn't it fast enough for?
It's actually a bit unfortunate that they chose to do buttons this way, because it feels like either you have a short timeout and you risk the button press getting never received, or you have a long one and potentially other devices think the button is pressed more than once. If the button had been advertised as a 'press count' that just incremented when the button was pressed things would have been much easier - no timeout would be needed.