Binding to Domoticz

How to integrate SPC Web Gateway with different Home Automation Systems
foogy
Posts: 1
Joined: Sat 29 Oct 2016, 05:47

Re: Binding to Domoticz

Post by foogy » Tue 01 Nov 2016, 20:57

I had some problems getting this binding to work. The solution for me was to change method from POST to PUT in the createDomoticzVariable function.

I also had problems with swedish charcters (å ä ö) in my user variables. I solved it by changing
path: '/json.htm?type=command&param=updateuservariable&vname=' + globalVariableHC2 + '&vtype=2&vvalue=' + value and
path: '/json.htm?type=command&param=saveuservariable&vname=' + globalVariableHC2 + '&vtype=2&vvalue=' + value
to
path: '/json.htm?type=command&param=updateuservariable&vname=' + encodeURI(globalVariableHC2) + '&vtype=2&vvalue=' + value
and
path: '/json.htm?type=command&param=saveuservariable&vname=' + encodeURI(globalVariableHC2) + '&vtype=2&vvalue=' + value

shalafi
Posts: 7
Joined: Thu 03 Jan 2019, 09:05

Re: Binding to Domoticz

Post by shalafi » Fri 20 Sep 2019, 18:50

Anyone here? ;)

Trying the new spc-gw 1.4 together with the binding and domoticz version 4.11324
And keep getting the error below, It seems to do somthing, but not all the way...

Code: Select all

Connect Error: Error: socket hang up
{ area:
   [ { id: '1',
       name: 'Hela huset',
       mode: '0',
       last_set_time: '1568982633',
       last_set_user_id: '1',
       last_set_user_name: 'Familjen',
       last_unset_time: '1568986768',
       last_unset_user_id: '1',
       last_unset_user_name: 'Familjen',
       last_alarm: '1562923875' } ] }
unset
{ status: 'success', data: { area: [ [Object] ] } }
{
   "message" : "Uservariable G_SPC_AREA_Hela_huset does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "status" : "ERR"
}

{ status: 'success',
  data:
   { zone:
      [ [Object], [Object], [Object], [Object], [Object], [Object] ] } }
{
   "message" : "Uservariable G_SPC_ZONE_INPUT_PIR_Hall_Uppe does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_PIR_Hall_Uppe does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_INPUT_Bakd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_Bakd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_INPUT_Balkongd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_Balkongd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_INPUT_Ytterd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_Ytterd�rr does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_INPUT_PIR_Hall_Nere does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_PIR_Hall_Nere does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_INPUT_PIR_Sovrum does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "message" : "Uservariable G_SPC_ZONE_STATUS_PIR_Sovrum does not exist",
   "status" : "ERR",
   "title" : "UpdateUserVariable"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}

{
   "status" : "ERR"
}


shalafi
Posts: 7
Joined: Thu 03 Jan 2019, 09:05

Re: Binding to Domoticz

Post by shalafi » Fri 20 Sep 2019, 19:45

I'm no js coder but when looking at the code it says:

path: '/json.htm?type=command&param=saveuservariable&vname=' + globalVariableHC2 + '&vtype=2&vvalue=' ............

According to the API docs, there is no "saveuservariable",I guess it's called "adduservariable"


I did a quick and dirty check and replaced both path: '/json.htm?type=command&param=update lines with (first) adduservariable, ran the js, then i changed both do updateuservariable, then I get all my variables and eacy run updates the values from SPC

I stil get the first error in the log (above post)│Connect Error: Error: socket hang upNope, fixed.. some strange authentication error.. :oops:

https://www.domoticz.com/wiki/Domoticz_ ... _variables

Strange, I wish i knew more javascript :-)

stephan@ats
Posts: 2
Joined: Fri 18 May 2018, 22:29

Re: Binding to Domoticz

Post by stephan@ats » Tue 07 Jan 2020, 23:59

hi,

i have this problem when it start the node-spc-domoticz-binding.js

Code: Select all

pi@raspberrypi:~/node-spc-domoticz-binding $ ./node-spc-domoticz-binding.js
SPC WebSocket client connected
{ area:
   [ { id: '1', name: 'Woonhuis', mode: '0', not_ready_set: '1021' } ] }
unset
{ status: 'success', data: { area: [ [Object] ] } }
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
{ status: 'success',
  data:
   { zone:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] } }
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Failed to parse reply, expected JSON

Code: Select all

config.json
{
   "spc_gw_host":"192.168.0.97",
   "spc_gw_port":"8088",
   "spc_ws_user":"ws_user",
   "spc_ws_password":"ws_pwd",
   "spc_get_user":"get_user",
   "spc_get_password":"get_pwd",
   "hc2_user":"spc",
   "hc2_password":"spc",
   "domo_host":"192.168.0.254",
   "domo_port":"8811",
   "naming":"0"
}

iam getting stuck.

the spc web gateway is working good.

Code: Select all

<config>
   <enable_get_auth>yes</enable_get_auth>
   <enable_put_auth>yes</enable_put_auth>
   <enable_ws_auth>yes</enable_ws_auth>
   <enable_edp_encryption>yes</enable_edp_encryption>
   <enable_ssl_encryption>yes</enable_ssl_encryption>
   <access_control_list>+192.168.0.0/24</access_control_list>
   <http_port>8088</http_port>
   <local_port>8089</local_port>
   <tcp_port>16000</tcp_port>
   <spc_id>1000</spc_id>
   <gateway_id>1100</gateway_id>
   <spc_time_diff>0</spc_time_diff>
   <spc_dst>yes</spc_dst>
</config>
user and pass are still default.

hope that someone have an sollution for me.

greets stephan

Post Reply