-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alarm audio playback to a Bluetooth speaker from Raspberry Pi Zero W #59
Comments
Hello! The command that is used to play audio under the hood:
One of the things that we noticed while investigating #44 is that in order to change the audio output device you need to change a system variable:
You may need to try hw:2,0, hw:3,0 until you finally get sound from your Bluetooth speaker. |
Thanks for the quick response. Probably a dumb location but where is the bashsrc file located so I am able to edit it? Is it within the plugin folder? |
There are no dumb questions, the ~ symbol means the user directory :) So if you are logged in as root the file path would be /root/.bashrc on your Raspberry Pi. |
doh! It was only when I tried to edit it the first time it was coming up empty so I knew I was in the wrong file. I have now added the lines to the file and will give it a go. If I leave the audio path blank does it default to the sounds included in the plugin? |
Yup! The default sounds are simple informative messages generated with a Google AI voice. |
I have gone through and changed the file .bashrc file in my user directory to both 1,0 , 2,0 and 3,0 but none playback the alarm noise when I manually trigger it. I know the speaker is working as if I run:
It plays... A bit lost now. I see there is a command option in the settings can I simply add the above command under the "Current Mode: Triggered"? |
Can you paste the output of the following command here to see which identifier corresponds to your speaker?
BTW, yes you can use the command options to play the audio file manually but the plugin won’t be able to stop the sound. |
Ran the command and got this output: **** List of PLAYBACK Hardware Devices **** |
It looks like you have to play with the subdevice identifier, can you try to change the number in bold (from zero to seven) export AUDIODEV=hw:0,0 restart Homebridge and use the plugin? |
Should I restart Homebridge after each change to the bashrc file, even though that file isn't being specifically read by Homebridge itself? |
Yes, restart it after each change as the plugin creates a shell that needs the updated environment variables for the audio command. |
Thanks. I will run through it methodically and update. Homebridge takes to a while to restart on the Pi Zero W! Just to rule out me incorrectly calling the sound file. If I simply want to the use the alarm.wav file, do I simply put the file name |
On the Sorry! I need to improve the documentation but I’ve been quite busy and right now I’m finishing another project. |
Oh, and even though the extension is different i think it may play the sound anyways so use |
So I went through the process 8 times changing the subdevice identifier but seemingly didn't resolve it. Still unsure what the issue is... Just to minimise the variables I just used the default sounds. |
Hopefully this works: export AUDIODEV=bluealsa (Restart Homebridge and test) |
so... I still cant get any sound output when I change the states in the plugin but when I run: Which seems to me I may have something set wrong in the settings of the app. I have pasted a crop of the config below I have a couple of Webhooks so I have obfuscated those for obvious reasons! { |
That’s really weird. Set the audio volume option to 100 just in case, also run in debug mode by using There you would see the full command that the plugin is executing, if it works when you execute it by yourself then it could be a permissions issue. Can you confirm me if it works by executing the command that gets printed in debug mode? |
100% a permission issue. Getting closer to a resolution. I run Homebridge with pm2 usually just to auto start it when the pi boots. So stopping Homebridge with pm2 and running it direct in the terminal with -D plays perfectly as expected and this is the log output: 8/22/2020, 22:27:04] [Home Alarm] Current mode (Off) So for some reason pm2 is not allowing it. I set up pm2 ages ago so will try and edit the config so it will run Homebridge in debug mode and report back. |
I have now removed pm2 and am using hb-service. After a bit of panic as I thought it completely obliterated my config (as it sets up a new instance) I have managed to restore everything over by moving my config files over to the new directory... but things still aren't right. If I run Homebridge as a service by If I run Homebridge directly by Do you know if there is any way to start the hb-service in debug mode? I have tried looking through the help pages but there isn't anything obvious. |
On the Homebridge UI, navigate to Can you check which user allows the sound to be played? Either root, pi or homebidge. |
so with debug logging there are no permission errors seen in the log, the output is identical to a previous post: [8/23/2020, 00:33:42] [Home Alarm] Current mode (Away) I am running the hb-service as the pi user as I installed it with the command running Homebridge directly from the terminal is calling it from the npm directory of One option to try is running hb-service as root, but I don't really want to do that long term. |
Maybe the steps followed here can help you: It looks like it requires root but it can be changed to allow non-root users 🙂 |
Will give that a look tomorrow, it is getting pretty later here tonight and I have been trying with this for a bit too long! I tried running hb-service as root but it wouldn't start. No logs were added to the log file and the config-ui wouldn't start. So annoying that it works when Homebridge isn't being run as a service. It 100% is a permission issue, but I would have thought that running it as a service would be running it with high permissions than locally within my user directory. |
I will admit playing around with deamons for bluetooth looks a little bit outside of my comfort zone... |
That’s understandable. I’ll check this out next week and look for alternatives. |
Did a bit more playing which ultimately caused my to brick the pi due to running a command which obliterated a large amount of files! Luckily I took a back up of the Homebridge config. After a morning of rebuilding, I used the Homebridge image in the end as I was running Stretch Lite anyways. Using the Config-X restore it rebuilt everything and loaded my original config, installed bluealsa and connected my speaker. Added the lines to the .bashrc and gave the whole thing a restart. Ran the |
In the end I have purchased a cheap USB speaker and connected it to the Pi. With a bit of tweaking on the default sound card I have it outputting successfully to the device. Still cant work out why the bluetooth connection isn't working, but it isn't something I need right now. |
Once I got some free time I’d like to investigate what’s happening here, I consider it quite important for the plugin and I definitely want it working. I’ll see what I can do, soon hopefully. |
Let me know if you want me to test anything or generate any logs if you need anything to help debug it. Happy to help. |
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Hi,
Firstly the plugin is awesome I have managed to integrate a number of sensors and Webhooks into the capability however I am looking to getting the alarm to play audio to a connected bluetooth speaker on the Pi.
I have managed to test and verify a bluetooth speaker with the pi and configured the connection with bluetoothctl and succeed in getting audio to playback using bluealsa. The Pi will auto reconnect to the bluetooth speaker when it boots.
I have set the location of the audio file in the config and installed but I am unsure what command is being used to initiate the playback. In order to push via bluetooth and not default to HDMI (which I think its doing) you need to insert arguments into the playback instruction:
aplay -D bluealsa /home/pi/alarm.wav
Would there be any way to have this feature added? Or if it is a function that is currently built in could you point me in the right direction to resolve?
The text was updated successfully, but these errors were encountered: