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 :-)

Post Reply