Binding to Domoticz

How to integrate SPC Web Gateway with different Home Automation Systems
fergalom
Posts: 15
Joined: Fri 11 Sep 2015, 09:16

Binding to Domoticz

Post by fergalom »

Binding to Domoticz Home automation system based on Gorans Fibaro Binding code.

Creates and updates user variables in Domoticz which can be used further to give indication of alarm status or drive the events based system.

https://github.com/fergalom/node-spc-domoticz-binding
Rena
Posts: 14
Joined: Sun 13 Sep 2015, 19:00

Re: Binding to Domoticz

Post by Rena »

Excellent! Just what I was looking for!
Does SPC Web Gateway works with the OS that´s bundled with the Domoticz PI-image?
https://www.domoticz.com/wiki/Domoticz_ ... i_SD_Image
fergalom
Posts: 15
Joined: Fri 11 Sep 2015, 09:16

Re: Binding to Domoticz

Post by fergalom »

yes this is what I am using.
Rena
Posts: 14
Joined: Sun 13 Sep 2015, 19:00

Re: Binding to Domoticz

Post by Rena »

thanks!
littlejoe
Posts: 1
Joined: Sun 11 Oct 2015, 10:26

Re: Binding to Domoticz

Post by littlejoe »

Hi, i have some problems installing the SPC Web GW -Domoticz Binding.
i have istalled the SPC Web Gateway and the Domoticz Server on the same Raspberry!
The SPC Web GW works fine and i can send and receive commands to the SPC-Alarm-System.

The Domoticz Web_Interface works fine also, i have configured the Temp Sensor of my Raspi to test the system.

By installing the SPC Binding the command "nmp install" doesnt work. I have got an error log (see att)

Can anyone help me?
Thanks in advance
nmp-debug-log.pdf
(13.88 KiB) Downloaded 731 times
fergalom
Posts: 15
Joined: Fri 11 Sep 2015, 09:16

Re: Binding to Domoticz

Post by fergalom »

think you need to update node.
I have v0.12.1
thos
Posts: 8
Joined: Mon 09 Nov 2015, 21:45

Re: Binding to Domoticz

Post by thos »

Hi,
Have SPC Web Gateway installed and working, but getting some mixed results on this binding to Domoticz

See logs:

Code: Select all

<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
Failed to parse reply, expected JSON
Error: socket hang up
Error: socket hang up
Error: socket hang up
Error: socket hang up
Error: socket hang up
{
   "status" : "ERR"
}

{
   "status" : "OK",
   "title" : "UpdateUserVariable"
}

<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
Failed to parse reply, expected JSON
{
   "status" : "OK",
   "title" : "UpdateUserVariable"
}

{
   "status" : "OK",
   "title" : "UpdateUserVariable"
}

{
   "status" : "OK",
   "title" : "UpdateUserVariable"
}

Error: socket hang up
Error: socket hang up
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
{
   "status" : "OK",
   "title" : "SaveUserVariable"
}

{
   "status" : "OK",
   "title" : "SaveUserVariable"
I'm then getting some variables through to Domoticz, but not all, and only on first run, not getting any updates.

Is there any limit on zones? I've got 12, but it only seems to load 9.

Running Ubuntu 12.04, Node v0.10.37, Domoticz v2.3552.

Any help appreciated, will take another look tomorrow night to see which calls exactly are failing.
thos
Posts: 8
Joined: Mon 09 Nov 2015, 21:45

Re: Binding to Domoticz

Post by thos »

So, I've commented out
//getSpcStatus('zone', handleSpcZoneData);

and it works fine.

Also tried only putting 2-3 Zones through (not the 12 on my system), and this works also, soon as I increase this to 4/5/6 zones I get 400 errors.

So looks like problem is this is pushing too many API calls to Domoticz, quicker than it can handle - in which case some sleep time / delay (or some nice exponential back-off / retry logic) might help.
thos
Posts: 8
Joined: Mon 09 Nov 2015, 21:45

Re: Binding to Domoticz

Post by thos »

Have it working with some modification

if (res.statusCode == 400) { /* Create variable if not found */
console.log('400 Error, aborting, waiting and retrying');
setTimeout(function(){
setDomoticzVariable(globalVariableHC2, value)
}, 1000);
req.abort();
return;
}

May not be 100% accurate, but seems to work, I'm new to JS, and this async programming has my head melted.
But now loading 26 variables from SPC Gateway, and updating nicely ..
gol
Webbplatsadministratör
Posts: 72
Joined: Sun 01 Jun 2014, 19:38

Re: Binding to Domoticz

Post by gol »

@thos
Yes, it seems that the Domoticz web server has problem to manage all updates in parallell. Another solution would be to wait for the reply for each update request before sending next request.
Maybee I can help you with an example. But that will be tomorrow.
Post Reply