I wanted something similar last night, so pasting it here in case it helps someone in time for halloween. It’s rough, and could definitely be improved upon. It was surprisingly difficult to get Home Assistant working with a bluetooth speaker, but this is what I did to get motion triggered Spooky sounds and lightning!
Bits and bobs needed:
- Zigbee Motion Sensor (LIkely works with whatever motion sensor you have to hand)
- Hue Lights (May work with other lights)
- Bluetooth wireless speaker (to hide in the hedge)
- A dedicated Raspberry Pi to connect to the bluetooth speaker. (I used a 3B+)
- Node-Red integration
- A bunch of spooky sounds (I used this as the sound that plays when the lights flash)
Basic Premise:
We’re going to use the motion sensor to trigger a node-red flow that will trigger some hue lights to flash and play some sounds from a hidden bluetooth speaker.
Steps I took:
1. Install the Zigbee Motion Sensor. (Skip if you’ve already got one working.)
2. Install the Lights. (Skip if you’ve already got one or more working.)
3. Setting up a new volumio instance on your network
The hardest part for me was getting something that would allow HomeAssistant to make noise over a bluetooth speaker with sufficiently low latency. I eventually landed on a working solution with volumio running on a dedicated raspberry pi. (I tried Mopidy and MPD on raspbian with low success rates when trying to get bluetooth working. Appreciate that Volumio is using MPD, but the permissions all appear to be setup so it works, if you follow the steps below.)
To do this you can use the standard Raspberry Pi Imager to burn an instance onto a fresh SD card in a Raspberry Pi. The initial setup instructions here work pretty much fine, with some minor differences, but I had no issues burning this onto a Pi with no ethernet and did everything wirelessly.
N.B. You will need to ensure that SSH is enabled on the Volumio so you can access it remotely
Once you have setup Volumio and you’ve checked (using the headphone jack) that it can play audio locally (I used a radio stream to test this.) You should be set to upload the sounds you want to use. You should be able to find you volumio on the network with the name you chose and it exposes its filesystem as a network share e.g. \volumio\internal . Just drag your sound files across from your local machine and check they play.
4. If it hasn’t already appeared in HomeAssistant you just need to add your Volumio device. (Add Integration ‘volumio’.) This will register a media player entity that you can use from Home Assistant (Almost there!)
5. Deploy a node red-flow that wires it all together. I’ve expanded out some bits here to make it clearer what’s happening. But the flow ‘exposes itself as a button on the interface’, ‘reacts to motion events’ and randomly chooses to either ‘just play a sound’ or ‘creates lightning and plays a thunder crack sound’.
The flow JSON is:
[{"id":"6163fb7697b2ca3b","type":"tab","label":"Halloween","disabled":false,"info":"","env":[]},{"id":"f21ddcec254e88fb","type":"api-call-service","z":"6163fb7697b2ca3b","name":"Light Flash","server":"6fbe91ef.20338","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.main_living_room_ceiling","light.signify_netherlands_b_v_lct010_light","light.signify_netherlands_b_v_lct015_light_6"],"data":"{\"rgbww_color\":[255,255,255,255,255]}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":200,"wires":[["2b79e45c5bf9615c"]]},{"id":"f6c953ea3306e764","type":"inject","z":"6163fb7697b2ca3b","name":"TestFlow","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":80,"y":340,"wires":[["9d57a186db3d69c2"]]},{"id":"2b79e45c5bf9615c","type":"api-call-service","z":"6163fb7697b2ca3b","name":"Light Flash off","server":"6fbe91ef.20338","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.main_living_room_ceiling","light.signify_netherlands_b_v_lct010_light","light.signify_netherlands_b_v_lct015_light_6"],"data":"{\"transition\":0.1}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":200,"wires":[["a8a15050e839ab48"]]},{"id":"a8a15050e839ab48","type":"api-call-service","z":"6163fb7697b2ca3b","name":"Light Flash","server":"6fbe91ef.20338","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.main_living_room_ceiling","light.signify_netherlands_b_v_lct010_light","light.signify_netherlands_b_v_lct015_light_6"],"data":"{\"rgbww_color\":[255,255,255,255,255]}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":200,"wires":[["d456f15c5fc21d4d"]]},{"id":"d456f15c5fc21d4d","type":"api-call-service","z":"6163fb7697b2ca3b","name":"Light Flash off","server":"6fbe91ef.20338","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.main_living_room_ceiling","light.signify_netherlands_b_v_lct010_light","light.signify_netherlands_b_v_lct015_light_6"],"data":"{\"transition\":0.5}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1360,"y":200,"wires":[[]]},{"id":"918fe9cc34a663dc","type":"ha-device","z":"6163fb7697b2ca3b","name":"Motion Detected","server":"6fbe91ef.20338","version":1,"exposeAsEntityConfig":"","inputs":0,"deviceType":"trigger","device":"de298413d08013aa68db4aa04e9f2405","event":{"type":"motion","platform":"device","device_id":"de298413d08013aa68db4aa04e9f2405","entity_id":"277eb2175ca044257a0574b63e913cde","domain":"binary_sensor","metadata":{"secondary":false}},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":160,"y":420,"wires":[["9d57a186db3d69c2"]]},{"id":"a0d851079e66a470","type":"api-call-service","z":"6163fb7697b2ca3b","name":"Play Sound","server":"6fbe91ef.20338","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":["media_player.hedgeplayer_2"],"data":"{\t \"media_content_id\":\"{\\\"service\\\": \\\"mpd\\\", \\\"type\\\": \\\"song\\\", \\\"title\\\":\\\"\" & msg.payload &\"\\\", \\\"uri\\\":\\\"music-library/INTERNAL/\" & msg.payload &\"\\\"}\"\t,\"media_content_type\":\"music\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1370,"y":320,"wires":[[]]},{"id":"9d57a186db3d69c2","type":"random","z":"6163fb7697b2ca3b","name":"","low":1,"high":"3","inte":"true","property":"payload","x":320,"y":340,"wires":[["2a625920d67265ed"]]},{"id":"2a625920d67265ed","type":"switch","z":"6163fb7697b2ca3b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":470,"y":340,"wires":[["f21ddcec254e88fb","8208ef241593b711"],["19c70fac787b4a98"],["19c70fac787b4a98"]]},{"id":"19c70fac787b4a98","type":"random","z":"6163fb7697b2ca3b","name":"","low":1,"high":"6","inte":"true","property":"payload","x":560,"y":480,"wires":[["36d9fe29a721ad2f"]]},{"id":"36d9fe29a721ad2f","type":"switch","z":"6163fb7697b2ca3b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"},{"t":"eq","v":"5","vt":"str"},{"t":"eq","v":"6","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":690,"y":480,"wires":[["a03f92c179aaf198"],["d1a1d6882e515d7b"],["192c7e1b1db1c1bb"],["72089461f673a0aa"],["6606510e147dd194"],["5c4ed2450f67a48e"]]},{"id":"8208ef241593b711","type":"change","z":"6163fb7697b2ca3b","name":"thunder-crack-31702.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"thunder-crack-31702.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":320,"wires":[["a0d851079e66a470"]]},{"id":"72089461f673a0aa","type":"change","z":"6163fb7697b2ca3b","name":"wolf-howling-140235.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"wolf-howling-140235.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":560,"wires":[["a0d851079e66a470"]]},{"id":"6606510e147dd194","type":"change","z":"6163fb7697b2ca3b","name":"boo-and-laugh-7060.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"boo-and-laugh-7060.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":600,"wires":[["a0d851079e66a470"]]},{"id":"5c4ed2450f67a48e","type":"change","z":"6163fb7697b2ca3b","name":"owl-2-139676.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"owl-2-139676.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":640,"wires":[["a0d851079e66a470"]]},{"id":"192c7e1b1db1c1bb","type":"change","z":"6163fb7697b2ca3b","name":"creepy-halloween-horror-voice-run-vol-006-165226.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"creepy-halloween-horror-voice-run-vol-006-165226.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":520,"wires":[["a0d851079e66a470"]]},{"id":"d1a1d6882e515d7b","type":"change","z":"6163fb7697b2ca3b","name":"halloween-witch-sound-creepy-laughter-9-vol-001-159177.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"halloween-witch-sound-creepy-laughter-9-vol-001-159177.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":480,"wires":[["a0d851079e66a470"]]},{"id":"a03f92c179aaf198","type":"change","z":"6163fb7697b2ca3b","name":"horror-sound-possessed-5-run-away-girl-vol-001-167388.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"horror-sound-possessed-5-run-away-girl-vol-001-167388.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":440,"wires":[["a0d851079e66a470"]]},{"id":"e577fe7a0ac6a661","type":"ha-button","z":"6163fb7697b2ca3b","name":"SpookyDoorSound","version":0,"debugenabled":false,"outputs":1,"entityConfig":"436737764cfd3da4","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":130,"y":260,"wires":[["9d57a186db3d69c2"]]},{"id":"6fbe91ef.20338","type":"server","name":"Home Assistant","addon":true},{"id":"436737764cfd3da4","type":"ha-entity-config","server":"6fbe91ef.20338","deviceConfig":"be12b2152558955d","name":"SpookyDoorSound","version":"6","entityType":"button","haConfig":[{"property":"name","value":"SpookyDoorSound"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"be12b2152558955d","type":"ha-device-config","name":"SpookyDoorSound","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}]
6. Go mad trying to diagnose why it isn’t working.
If you get to here, I found using the developer tools to inject a service was pretty helpful in diagnosing the issue. This post has a working example that I found very helpful.
7. Setup Volumio to use a bluetooth speaker.
The next bit is ropey, to say the least, but through a combination of the following posts I was able to get my volumio to use a wireless bluetooth speaker: here, here and here. This is not for the particularly faint-hearted and I recommend reading all three posts before commencing on it or you’ll find the last post has you reworking the contents of one of the downloads in the first post (you’re welcome ).
Hope this helps someone, appreciate the detail isn’t all there in this post, but the linked posts should cover all you need! Happy Halloween xx