I just got a Puck.JS. I have been reading for the past few days on BLE, NRF.SetAdvertising, setWatch, tutorials, videos etc. Some excellent stuff out there, but very scattered and some old and some new, so I am a bit confused.
What I want to do is pretty straight forward - I thought.
I want to press the button on the Puck.js and turn my stereo on/off through Home Assistant.
To do this (I think) I want to press the Puck.js button and send a BLE advertisement to a BLE-MQTT Gateway (ESPHome) which turns it into MQTT pub which I can subscribe to in Home Assistant and use to run an automation which will turn a media_player on and off.
So press- stereo on
Another press - stereo off.
Just a plain ol' toggle.
But I also want the other BLE advertising to go ahead, not just at the button press.
So... right now I can get E.GetTemperature and E.Battery using NRF.SetAdvertising and can read it via the Gateway/MQTT fine into Home assistant just fine.
And I can also toggle the state of the button on and off.
But...
What I can't do is all of that together. It is an either/ or. Here is my code
With this code in Puck, (and viewing ble output in nrfconnect) I first see temp and batt, but as soon as I press the button, 0xFFFF gets set with buttonState but Temp and Batt are no longer visible.
How do I get button state to be passed as and when it is toggled, AND keep temperature and battery going at some set interval as well?
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.
My first Espruino project.
I just got a Puck.JS. I have been reading for the past few days on BLE, NRF.SetAdvertising, setWatch, tutorials, videos etc. Some excellent stuff out there, but very scattered and some old and some new, so I am a bit confused.
What I want to do is pretty straight forward - I thought.
I want to press the button on the Puck.js and turn my stereo on/off through Home Assistant.
To do this (I think) I want to press the Puck.js button and send a BLE advertisement to a BLE-MQTT Gateway (ESPHome) which turns it into MQTT pub which I can subscribe to in Home Assistant and use to run an automation which will turn a media_player on and off.
So press- stereo on
Another press - stereo off.
Just a plain ol' toggle.
But I also want the other BLE advertising to go ahead, not just at the button press.
So... right now I can get E.GetTemperature and E.Battery using NRF.SetAdvertising and can read it via the Gateway/MQTT fine into Home assistant just fine.
And I can also toggle the state of the button on and off.
But...
What I can't do is all of that together. It is an either/ or. Here is my code
With this code in Puck, (and viewing ble output in nrfconnect) I first see temp and batt, but as soon as I press the button, 0xFFFF gets set with buttonState but Temp and Batt are no longer visible.
How do I get button state to be passed as and when it is toggled, AND keep temperature and battery going at some set interval as well?
Thanks