Introduction: Voice Feedback for Your Home Automation System (HC2)
In this instructables guide I'm using the following;
- Fibaro Home Center 2 (aka HC2), LUA programming is required so Home Center Lite wont work (i guess)
- Fibaro smoke sensors, (Instead of smoke sensors you could use motion sensors for testing all things out.)
- Raspberry Pi with RuneAudio installed. ( I used a Pi Model B but any unit that can run RuneAudio will work)
- Active speaker
For some time ago a decided to invest in some smart devices for my home. Primarily in smoke detectors that could work together. I bought two fibaro smoke sensors that communicate over z wave technology and sadly without doing much research before my investment.
The fibaro smoke sensors can talk to z wave devices, they can in the event of fire turn on lights and so on but they can not trigger another smoke sensors alert sound, so if one sensor is triggered only that one sounds. In some way this is good because it would be easier to locate the fire but then again i would rather buy cheaper smoke detectors. So how can i alert my family if the fire starts in our garage?
With a Aeon Labs siren that thing was solved! In both of my smoke sensors i added the Aeon Labs siren to the second association group and now if either one of my smoke sensors triggers the Aeon Labs siren also sounds, perfect i can now be sure to hear the fire alarm if its triggered in the garage.
So quite much money for this easy task.
But what if we could expand our fire alarm system to do more?
I decided to try and get voice feedback from my fibaro home center 2 (HC2), so in the event of fire the HC2 would tell me with voice where the fire is (based on witch sensor that was triggered).
The HC2 have a audio out and mic in 3.5 jack but after some reading there are not used so that was a dead end.
Raspberry to the rescue!
I searched for possible solutions and found this article: https://www.instructables.com/id/Raspberry-Pi-as-H...
A really good guide and my Raspberry was up and running in no time.
Step 1: Prepare Raspberry Pi
Follow this really good article to get RuneAudio up n running on your Raspberry Pi.
I connected a USB memory to my Pi with pre-recorded wav files. You can almost use any kind of soundfiles with RuneAudio witch is great. I created my wav files with Audacity ( http://www.audacityteam.org/ ) and a microphone. I recorded a couple of soundfiles. For the garage smoke sensor feedback i recorded a wav file that says; Fire in garage, dial 911, fire extinguisher is by the entrance door.
In RuneAudio i turned on repeat mode for soundtracks so that my wav files are playing in loop.
Then crate a Playlist for each of the feedback sounds that you got. Click on Library then USB Storage, next browse to your sound files and double click the sound that you are going to create a playlist for. The soundfile is played through your speakers in a loop now. You might also have notice the popup in the right corner telling you that the file has been added to the playlist, Grate!
Click on Queue in RuneAudio. That will take you to the actual playlist queue.
In the bottom left corner you have buttons for managing the playlist, save it, delete it etc.
Click on save playlist button and give the playlist a good name, this name is going to be used in a http request so it is a good advice to avoid spaces and special characters in the playlist name. For instance it is better to name the playlist: firegarage rather then name it Fire in the garage! (in the http request this would need to be something as follows; Fire%20in%20the%20garage%21 , not so grate!... better to use firegarage that would in the http request just be firegarage , much better in my opinion.
Ok so now the Raspberry Pi is up n running with playlists saved for each feedback sound.
Lets move on.
Step 2: RuneAudio Commands
To be able to start playing our playlist we created we need to get our playing URLs set up and tested.
RuneAudio is based on MPD (Music Player Daemon, it is a flexible, powerful, server-side application for playing music). You can control your RuneAudio with almost any kind of client, including with easy URLs in any kind of browser or programming language that can make http requests.
Look at the MPD command referense to get an idea of what you can do. https://www.musicpd.org/doc/protocol/
For this guide i am going to use basic commands and that is the commands Load, Play and Clear.
To start a playlist just by visiting a url we first need to Load the playlist to our play queue. Remember our playlist that we named firegarage. Lets load that in to our play queue. This is done by visiting
(I prefer to access the rune by it's static configured IP address but for this demo i'm using a easier way)
More info here how to access your RuneAudio: http://www.runeaudio.com/documentation/
So lets try the address in your favourite web browser. You should now if you look in the RuneUI see that the playlist is loaded and ready to be played.
Lets hit the next command.
And your sound file would now play (Hopefully)
The last command that we are going to test is the clear command that clears the play queue witch also stop playback.
Grate! The sound file have stopped and we are ready to move on!
Step 3: Program Your HC2
Log in to your HC2 and click on Scenes
Click on Add scene
I'm not so good in programming LUA so i usually starts of by creating a block scene and then convert it to LUA and then adds the missing candy to the code. Lets do that in this guide also.
Click on add block scene
Click the plus sign
Click on Devices and select your device that you want to configure voice feedback for.
You now have the block scene that looks like in one of the pictures.
[ SmokeSensor ] == [ breached ] [ 0 s ]
[ AND ]
Change And to Then
Save the block scene (Page reloads and you end up in the basic section of the scene.)
Tick the box next to [Do not allow alarm to stop scene while alarm is running] so that the scene is activated even when in alarm mode. Name your scene, lets say we name it FIRE-GARAGE-VF (VF = Voice Feedback)
Click on save
Then click on Advance
Your now in block scene editing area and there you click on Switch scene to LUA based (button named change)
Where it says Switch scene edit mode to LUA based there is a button that says Turn on. Click that button and you can start edit the LUA code.
In the code window we can see the following code:
--[[%% properties 5 value %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getValue(5, "value")) > 0 ) or startSource["type"] == "other" ) then <--- here are our previously configured command URLs going to be end
The above code states;
Get status of sensor number 5 if its grater then 0 or the type of the sensor status is other then execute the commands that are between then and end
So our magic URLs goes in and voila;
--[[%% autostart %% properties 5 value %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getValue(5, "value")) > 0 ) or startSource["type"] == "other" ) then local httpClient = net.HTTPClient(); httpClient:request('http://runeaudio.local/command/?cmd=load%20firegarage') httpClient:request('http://runeaudio.local/command/?cmd=play') end
Click on save and your almost good to go.
Repeat this step and add a new scene, but in block scene editing mode you select safe instead of breached, you also name this scene to FIRE-GARAGE-VF-STOP and finally instead of adding the command URLs for load and play you add only the clear command like following;
--[[%% properties 5 value %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getValue(5, "value")) == 0 ) or startSource["type"] == "other" ) then local httpClient = net.HTTPClient(); httpClient:request('http://runeaudio.local/command/?cmd=clear') end
Now your set to test the whole thing out.
The whole idea needs to be more secured in some aspects. If it's going to be used with smoke sensors and relied on we need to address problems such as power failure, fire on the HC2, repeat mode in RuneAudio etc. but this guide should get you started. And even if we haven't secured our voice feedback or HC2 the Fibaro Smoke Sensor are still going to sound it's integrated alarm sound like any other smoke sensor.
With this set up it would be really nice to get a welcome message when you disarm the alarm system or maybe if there is a brake in in the middle of the night while you are asleep and you here the siren and are also getting a voice feedback. For instance; Brake in kitchen door, Police have been notified, releasing teargas in 30 seconds.
I found how to make http request in LUA code in this article:
We have a be nice policy.
Please be positive and constructive.