it’s a Mi Band, not a 2.
now at 49% after 3 weeks, but I don’t use it for notification.
Batterylife is estimated at 30 days, but I will get a lot more out of it.
Hi,
I bought an happyBubble too.
for me it’s perfect to do presence detection. With Android, BT and Wifi detection is draining my battery so fast…
I called mine home (i have only one HappyBubbles), if my beacon is not seen its status become ‘away’.
If Happy Bubbles detect it, its status become ‘home’
It works very well.
For my side, i bought nut2 beacon from china (low cost beacon which works fine)
Thank you for your feedback! I’m happy to hear it’s working well for you. Also thank you for that Nut2 link. I will have to purchase one of those and test them, they look very nice.
AN ibeacon is coming. I have 4 HB, but now installed only one. When I will install more then one which is the code of presence?
I mean I am sure that same object will be identified simulaneously by 2 HB (the rooms are not too far away), will the HB handle the difference and state the presence from the HB that is nearer the ibeacon? Or we need to code that?
That’s right, that’s what the presence server https://github.com/happy-bubbles/presence is for. Your HB’s will detect many of the same beacons at once, but with different signal strengths. The Presence server can figure out which beacon is most likely closes to which detector, and can forward those results over to other systems, like Home Assistant.
I have a tutorial here: https://www.happybubbles.tech/presence/docs/rpi3_setup/ for how to set it up on a Raspberry Pi.
I am using now a FItbit (at least I use it for something ) and let’s see if it is good.
Any particular instruction for using the Fitbit tracker with HB?
Depends if your fitbit broadcasts it’s mac address.
You could try to unpair it and check if it broadcasts or not in HB.
I had the same with my pebble watch and couldn’t use it, hence the mi band.
Ok, now I setup 2 HB, and I register my Fitbit charge HR, which is seen by the presence server.
Can you give a simple code to be used in HA?
Basically the most important topic is happy-bubbles/presence/changes
how to use it in automation, examples?
I have the following config:
- platform: mqtt_room
device_id: <device_id>
name: miband
state_topic: 'happy-bubbles/presence/ha'
time_out: 5
away_timeout: 60
in the automations you just need to use the state of the sensor.
If you have multiple locations, you can use a virtual switch.
- platform: template
sensors:
miband_home:
value_template: '{%- if is_state("sensor.miband", "away") %}
away
{%- else -%}
home
{%- endif %}
And you can use it in automation:
automation:
- alias: "turn on lights when dark living"
trigger:
- platform: sun
event: sunset
condition:
- condition: state
entity_id: sensor.miband
state: 'living'
action:
service: scene.turn_on
entity_id: scene.light_living
Thanks for posting that @yelti_be! That’s a really good example for Home Assistant using its room feature: https://home-assistant.io/components/sensor.mqtt_room/
Newb here, I do not get it
WHat is this state_topic: ‘happy-bubbles/presence/ha’ ??
This is the topic happy-bubbles/presence/changes
{“beacon_info”:{“name”:“Charge HR”,“beacon_id”:“e81b30d17295”,“beacon_type”:“”,“beacon_location”:“”,“last_seen”:1493316477,“incoming_json”:{“hostname”:“Livingroom hb”,“mac”:“e81b30xxxxx”,“rssi”:-73,“is_scan_response”:“0”,“type”:“0”,“data”:“0201041106ba5689a6fabfa2bd01467d6e00fbabad09160a180804de3e0000”,“beacon_type”:“”,“uuid”:“”,“major”:“”,“minor”:“”,“tx_power”:“”,“namespace”:“”,“instance_id”:“”},“distance”:0,“Previous_location”:“”,“Previous_confident_location”:“Livingroom hb”,“Location_confidence”:0},“name”:“Charge HR”,“beacon_name”:“Charge HR”,“previous_location”:“Livingroom hb”,“new_location”:“”,“timestamp”:1493316531}
also don’t know how to do a virtual switch. My point iis to use multiple HB in multiple room
You don’t need the changes topic i guess, just the ‘happy-bubbles/presence/ha’ topic showing the name of the room you’re in.
If you want to trigger automations you can use sensor.miband_home in conditions:
like:
- condition: state
entity_id: sensor.miband_home
state: 'home'
or use the room:
- condition: state
entity_id: sensor.miband
state: 'living'
My plan is to work with timers for lights and keep the lights on when I’m in a room.
Motion sensors start a timer, reset the timer at the end if i’m in the room.
I’m still searching for the a good automation.
I have to thank you for the software you wrote.
Would have bought your sensors but they where unavaillable at the time I started my project.
not sure how to use this for multiple room
You’re very welcome and no worries. I’m glad you’re getting use out of it and that’s why I open sourced it. If you decide to show your source for how you made it work with Raspberry Pi, sounds interesting and I would like to see that too.
Can you eloborate what you want to achieve?
I use the virtual switch to check if i’m home or not so I only have to check for 2 values in my rules.
this is one of the conditions in my automations.
ibeacon A
ibiacon B
HB detector in TVroom
HB detector in livingroom
if A is in tvroom trigger 1
if A is in livingroom trigger 2
if B is in tvroom trigger 3
if B is in livingroom trigger 4
Of course:
my quick install manual:
put file with name ssh in /boot on sdcard
change hostname in /etc/hostname
add hostsname to /etc/hosts file
sudo apt-get install build-essential python-rpi.gpio
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
sudo systemctl enable nodered.service
sudo apt-get install libbluetooth-dev libudev-dev
sudo systemctl start nodered
cd .node-red
npm install node-red-contrib-noble
node-red flow:
[{"id":"6e4c8951.083ef","type":"debug","z":"673a53ce.cab9e4","name":"","active":false,"console":"false","complete":"true","x":501.5,"y":233.5999755859375,"wires":[]},{"id":"bad603b4.5ed0e","type":"inject","z":"673a53ce.cab9e4","name":"","topic":"","payload":"on","payloadType":"str","repeat":"3","crontab":"","once":true,"x":91.5,"y":35.366668701171875,"wires":[["5328e6a7.8c0ae8","72ccdad9.ce7d6c"]]},{"id":"f585acd9.d99dc","type":"scan ble","z":"673a53ce.cab9e4","uuids":"","duplicates":true,"name":"","x":334.5,"y":110.69999694824219,"wires":[["69999006.c511e8","c87e265a.15a4b","15fd16b8.549161"]]},{"id":"15fd16b8.549161","type":"function","z":"673a53ce.cab9e4","name":"","func":"var hostname = msg.detectedBy;\nvar mac = msg.peripheralUuid;\nvar rssi = msg.rssi;\nvar is_scan_response= \"0\";\nvar type = \"3\";\nvar data = \"0201061aff4c000215e2c56db5dffb48d2b060d0f5a71096e000680068bd\"\nvar topic = \"happy-bubbles/ble/\" + hostname + \"/raw/\" + mac\nif (mac === 'c80f104b4a44'){\n var newMsg={payload: {\"hostname\": hostname, \"mac\": mac, \"rssi\": rssi,\"is_scan_response\": is_scan_response,\"type\": type, \"data\": data},topic: topic};\n}else {\n var newMsg={};\n}\nreturn newMsg; ","outputs":1,"noerr":0,"x":236.5,"y":300.6333312988281,"wires":[["6e4c8951.083ef","c56790ba.cc6e2"]]},{"id":"ceb7c4ce.e1b2f8","type":"mqtt out","z":"673a53ce.cab9e4","name":"","topic":"","qos":"","retain":"","broker":"eddcce2d.88d028","x":576.5,"y":323.79998779296875,"wires":[]},{"id":"5328e6a7.8c0ae8","type":"function","z":"673a53ce.cab9e4","name":"","func":"var newMsg = {};\nvar scan = false;\nif (msg.payload === 'on') {\n scan = true;\n } else {\n scan = false;\n}\nvar newMsg = {payload:{\"scan\": scan}};\n\n return newMsg;","outputs":1,"noerr":0,"x":167.92898559570312,"y":122.06134033203125,"wires":[["f585acd9.d99dc"]]},{"id":"ee32e9e5.de3598","type":"trigger","z":"673a53ce.cab9e4","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"3","extend":false,"units":"s","reset":"","name":"","x":387.5,"y":62.50000762939453,"wires":[[]]},{"id":"69999006.c511e8","type":"debug","z":"673a53ce.cab9e4","name":"raw","active":false,"console":"false","complete":"true","x":566,"y":111.23334503173828,"wires":[]},{"id":"c56790ba.cc6e2","type":"switch","z":"673a53ce.cab9e4","name":"name","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"$exists(undefined)\t","vt":"jsonata"}],"checkall":"true","outputs":1,"x":390.9999694824219,"y":332.066650390625,"wires":[["ceb7c4ce.e1b2f8"]]},{"id":"72ccdad9.ce7d6c","type":"delay","z":"673a53ce.cab9e4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":259.5,"y":20,"wires":[["5328e6a7.8c0ae8"]]},{"id":"c87e265a.15a4b","type":"function","z":"673a53ce.cab9e4","name":"","func":"var hostname = msg.detectedBy;\nvar mac = msg.peripheralUuid;\nvar rssi = msg.rssi;\nvar is_scan_response= \"0\";\nvar type = \"3\";\nvar beacon_type= \"ibeacon\";\nvar uuid=\"e2c56db5dffb48d2b060d0f5a71096e0\";\nvar minor= \"0068\";\nvar major= \"0068\";\nvar tx_power=\"bd\"\n\nvar topic = \"happy-bubbles/ble/\" + hostname + \"/ibeacon/\" + uuid;\nif (mac === 'c80f104b4a44'){\n var newMsg={payload: {\"hostname\": hostname, \"beacon_type\": beacon_type, \"mac\": mac, \"rssi\": rssi,\"uuid\": uuid,\"minor\": minor, \"major\": major , \"tx_power\": tx_power},topic: topic};\n}else {\n var newMsg={};\n}\nreturn newMsg; ","outputs":1,"noerr":0,"x":114.5,"y":404.23333740234375,"wires":[["ceb7c4ce.e1b2f8","6e4c8951.083ef"]]},{"id":"eddcce2d.88d028","type":"mqtt-broker","z":"","broker":"172.16.0.28","port":"1883","clientid":"Living","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
the miband only exposes rssi and no tx power, to I abused the ibeacon format to ‘callibrate’ each rpi zero w.
Ok, clear now.
if you have the correct state topic, you can use the state of the sensor like:
- condition: state
entity_id: sensor.miband
state: 'living'
or:
- alias: "livingroom light"
trigger:
platform: state
entity_id: sensor.miband
to: 'living'
action:
service: light.turn_on
entity_id: light.outside_light