Page 1 of 1

Niko Home Control status check

Posted: Thursday 14 April 2016 22:43
by tcorneillie
hi all,

i'm looking for a way to update the status of my Domoticz switches, which control my Niko Home Control lights.
The on and off actions in Domoticz are controlled via a python script which executes a JSON request to the NHC gateway. For instance:

script:///home/pi/domoticz/scripts/python/Set_NHC.py "2" "100" "<IP of the nHC gateway>"

this would set the lights for id 2 (kitchen) to ON (100)

I can also execute a script which returns me the full list of all devices and their statuses (in JSON)

So now i would like to match them every X secs. Because it is possible to change the status from outside of Domoticz by pressing a light button in the house (= NHC button).

I thought it would be somewhat like the script i found about updating Philips HUE light statuses, but i can't seem to manage to tweak it for my needs.
https://www.domoticz.com/wiki/Philips_H ... Hue_status

Any suggestions?

Thanks in advance!

Kind regards,
Tom

Re: Niko Home Control status check

Posted: Thursday 14 April 2016 22:57
by deennoo
For Niko : use a crontab every 1 minute

Re: Niko Home Control status check

Posted: Friday 15 April 2016 8:25
by tcorneillie
thanks deennoo,

i went running this morning (my usual think-it-over-routine) and i came up with exactly the same thing: why not doing it with a cron and that http://[domoticzip]:[port]/json.htm?...
So if you think this is an option too, chances are higher it'll work ;-)

Kind regs,
Tom

Re: Niko Home Control status check

Posted: Monday 09 May 2016 15:36
by JHTechnics
Hi,

You should write an interface in nodeJS and open a socket to Niko Home Control.
below some details on what to send :

Tcp port 8000 packets to sent

{"cmd": "startevents"} #to receive events
{"cmd": "listactions"} #to get action list and status
{"cmd": "listlocations"}#to get location list
{"cmd": "executeactions", "id": 1, "value1": 100}

Packets received :

after listations cmd :
{"cmd":"listactions","data":[ {"id":0,"name":"Light hall","type":1,"location":1,"value1":0},{"id":1,"name":"Light Living","type":1,"location":3,"value1":100},{"id":2,"name":"Light Kitchen","type":1,"location":2,"value1":0}]}

after executeactions cmd :
{"event":"listactions","data":[{"id":0,"value1":0}]}

In your case you need to open a socket and send the {"cmd": "startevents"} to receive information on what action is started by a hardware switch.

Regards,
Jeroen Hollemans
JH Technics

Re: Niko Home Control status check

Posted: Tuesday 10 May 2016 10:34
by tcorneillie
hi Jeroen,

Sounds like you know what you're talking about. That's great!
the cronjob is implemented for the moment, but it is occasionally causing issues with events and timers, so it's good for now, but certainly not a keeper.

Unfortunately, i don't have NodeJS experience, so your solution sounds a bit 'unknown territory' to me.

You don't have, by any chance, some kind of example?

Thank you in advance and thank you already for the hint.

Kind regards,
Tom

Re: Niko Home Control status check

Posted: Sunday 15 May 2016 23:27
by tcorneillie
i am thinking about somehow adding the status update script to the web interface of domoticz.

the only time i need to know the status of devices is when i'm accessing the user interface. Or am i overlooking something...

The cronjob every 1min is causing troubles on timers and sometimes it switches lights back to the previous state on pressing the Niko Home Control switches.

Maybe someone can help me on this? Is there a way to add an extra script to the index.html (for instance) of domoticz?

Kind regs and thanks for all info!
Tom