The energy usage of the XAP800 mixer is in standby around 20-25 Watts, well, that’s too much for doing ‘nothing’. The device is great and even with the ZMC script to control it from Homeseer, I want to reduce the energy usage. I tried to setup the voice recognition as well, but it’s not working well in my situation, so the XAP800 is just a big speaker switch that consume a lot of energy.
Some time ago I bought the Raspberry Pi 2. I don’t have to tell the advantages are of such a device. I used it as a Spotify player, I used it as a webserver and even I installed Domoticz to look around what the possibilities are. Most of my current home automation hardware isn’t compatible with Domoticz, so the Pi disappeared in the closet. The energy usage of this device is quite low, say between 0.5 and 5 Watt.
This year I want to finish some projects and accomplish my ideas before buying new stuff. Replacing the XAP800 is one of the projects.
Question:
- How can I use the Pi to replace the XAP800?
- How to control the speakers. Just easy: use relays. The most of the tutorials in the internet explaining how to switch a light. Could it be working with a speaker as well?
- How to controll the relais from Homeseer.
I bought a pcb with 8 relays on it, a breadboard and some wires (low investment) to create a setup.
There are a lot of tutorials how to setup the Raspberry Pi with an Apache webserver, were you can run Python scripts. After 2 days, it was not working for me…. other options? Yes, Domoticz. I rembered that Domoticz do have function to control the GPIO pins. If this is going to work, I can control the relays.
Other question:
- Is Domoticz accessible via API because I want to control it via, for example, Homeseer? Yes it is. Via JSON you can control actions and even read the current status of a device.
Finally, how to setup the Pi:
- Install Domoticz via this image.
- Install wiringPi.
- Edit the “domoticz.sh” file with command: “sudo nano /etc/init.d/domoticz.sh”.
- Add at the very bottom of this file the GPIO pins you are using, like:
esac
:
#Run export GPIO Raspberry
/usr/local/bin/gpio export 2 out
/usr/local/bin/gpio export 3 out
/usr/local/bin/gpio export 17 out
- Save file: Ctrl+O
- Exit file: Ctrl+X
- Restart Pi: “sudo shutdown -r now”
- In Domoticz add new hardware “GPIO port”
- In Domoticz add a new manual switch and use the following credentials:
Hardware: GPIO port (as named while the GPIO port is added on the dashboard of Domotcz).
Enter a devicename for the switch
Switch Type: On/Off
Type: GPIO
GPIO: choose the GPIO pin you used in your hardware setup page. Select here (one of) the line(s) that is marked with (OUTPUT)
Example configuration:
When the switch is working, the relay is switching on or off, you can try to control the same switch via the JSON command.
First you need to know the id number of the switch. You can see this in via Setup-Devices or run the following url in your browser to get all the id numbers:
http://<raspberry-ip>:8080/json.htm?type=command¶m=getlightswitches Possible result:
-
{
IsDimmer: false,
Name: “Relais 1”,
SubType: “Impuls”,
Type: “Lighting 1”,
idx: “7”
-
},
The idx for my relay (named “Relais 1”) = 7.
The JSON command to turn that relay to On, will be:
http://<raspberry-ip>:8080/json.htm?type=command¶m=switchlight&idx=7&switchcmd=On
To control the relay from another application, it has to run this url. In my case the vb.NET script will be run from an event:
Sub or Function = Main
Scipt Paramters contains 3 variables, seperated by the “more” character. How to enter the 3 variables:
relais|<switch-id>|<to-status>
or in my case I created also a scene in Domotcz, with type “group” (because a group can be switched to On AND Off, while a scene can only be switched On), that turn all switches to the same status (On or Off):
group|<scene-id>|<to-status>
The vb.NET script will be:
‘ Script get 3 parameters from Event and create an url to control the Domoticz devices
‘ Script get 3 parameters from Event and create an url to control the Domoticz devices
Sub Main(ByVal parms as Object)
Dim scriptinput as String = parms
Dim results() as String = scriptinput.Split(“|”)
Dim control as String = results(0)
Dim id as String = results(1)
Dim status as String = results(2)
Dim url as String
Dim Debug = 1 ‘0/1
If Debug > 0 Then hs.writelog(“Domoticz”, control & ” | ” & id & ” | ” & status)
Select case control
Case “relais”
url = “http://<raspberry-ip>:8080/json.htm?type=command¶m=switchlight&idx=” & id & “&switchcmd=”
Case “group” ‘ Switch a group, because a scene can only be switched On
url = “http://<raspberry-ip>:8080/json.htm?type=command¶m=switchscene&idx=” & id & “&switchcmd=”
Case Else
url = url
End Select
Select Case status
Case “On”
url = url & “On”
Case Else
url = url & “Off”
End Select
Dim finalurl = hs.URLAction(url, “GET”, “”, “”)
End Sub
Finally you can switch via an easy way the appropriate speaker from Homeseer, via JSON in Domoticz, which control the GPIO pin to control a certain relay:
To see this in action, a short movie here:
Related Posts
February 16, 2016
Retrieve current Spotify track data into Homeseer
February 13, 2016
Control Spotify from Homeseer via Tasker
November 15, 2014
This is nice blog i love read it always