domoticz home control and unipi

Share your installations with the rest of the World
spudgunman
Posts: 9
Joined: Sat May 30, 2015 9:03 am

domoticz home control and unipi

Postby spudgunman » Thu Sep 10, 2015 9:18 pm

built a script for the domoticz project
https://www.domoticz.com/forum/viewtopi ... =23&t=7932
ESF_nl
Posts: 9
Joined: Mon Mar 14, 2016 3:11 pm

Re: domoticz home control and unipi

Postby ESF_nl » Mon Mar 14, 2016 3:21 pm

Following the link above I requested some help. Unfortunately not so many people use UniPi on the Domoticz forum I believe. Would you please give me some directions? I've eddited the script with idx numbers. What's the next step?
BlackSoll
Posts: 31
Joined: Sat Jul 04, 2015 9:07 am

Re: domoticz home control and unipi

Postby BlackSoll » Tue Mar 15, 2016 8:41 am

ESF_nl wrote:What's the next step?


Rough install guide of json.lua

sudo mkdir /usr/local/share/lua/
sudo mkdir /usr/local/share/lua/5.2/
sudo chmod 777 /usr/local/share/lua/5.2/

put the json.lua script in the directory /usr/local/share/lua/5.2/


Did you did this ?
ESF_nl
Posts: 9
Joined: Mon Mar 14, 2016 3:11 pm

Re: domoticz home control and unipi

Postby ESF_nl » Tue Mar 15, 2016 12:06 pm

Yes, I did make the directories and put the json.lua script in there. The only thing I wasn't aware of was changing the file permission with chmod 777. I did so now.

Unfortunately clicking the virtual switches in Domoticz doesn't make the real relays click...
Domoticz dashboard.PNG

Do I have to start or load some script or program? I'm not that experienced in this field ;)
BlackSoll
Posts: 31
Joined: Sat Jul 04, 2015 9:07 am

Re: domoticz home control and unipi

Postby BlackSoll » Tue Mar 15, 2016 12:24 pm

The name of the relay at script must be the same with your virtual switch.........

unipi relais 1 must be the name in the script too...

use _ and not space at script...

Example :

Code: Select all

idxr1 = 40
relay1name = "uniPi_Relais1"
ESF_nl
Posts: 9
Joined: Mon Mar 14, 2016 3:11 pm

Re: domoticz home control and unipi

Postby ESF_nl » Tue Mar 15, 2016 5:37 pm

Thank you for you help. I renamed all the devices from the original script to replace " " by "_". Thereafter I renamed all the devices in Domoticz.
Domoticz devices.PNG
I did a reboot but unfortunately still no success.
Domoticz dashboard2.PNG

It feels like I'm so close!
BlackSoll
Posts: 31
Joined: Sat Jul 04, 2015 9:07 am

Re: domoticz home control and unipi

Postby BlackSoll » Wed Mar 16, 2016 8:55 am

It the port settings correct ? Edit the script to match with your installation.

Code: Select all

evokurl = "localhost:8181"
-------------------------------------
-- Domoticz JSON hostname:port      --
-------------------------------------
domoticzjson = "localhost:8080"


One more tip......How do you create the virtual switch ?

The right way is to go to hardware and from there choose unipi and create the switch.
ESF_nl
Posts: 9
Joined: Mon Mar 14, 2016 3:11 pm

Re: domoticz home control and unipi

Postby ESF_nl » Wed Mar 16, 2016 5:51 pm

I was full of trust my stupid mistake would be fixed now... I thought 'localhost' was a universal programming variable which would understand my host address :oops: Unfortunately changing it to 192.168.0.176 didn't change anything (nor after reboot rpi).

I've added the hardware by selecting a dummy from the dropdown list and called it UniPi. After that I've created devices (virtual sensors) from this hardware.
Domoticz hardware.PNG

Is it correct the UniPi Domoticz LUA script is saved in:
~/domoticz/scripts/lua/script_UniPi_domoticz.lua

and the json.lua in:
/usr/local/share/lua/5.2/json.lua

Are there any commands to check the services are running fine?

Code: Select all

pi@raspberrypi / $ sudo service lua status
lua: unrecognized service
pi@raspberrypi / $ sudo service json status
json: unrecognized service


Thank you very much for your help and patience!
BlackSoll
Posts: 31
Joined: Sat Jul 04, 2015 9:07 am

Re: domoticz home control and unipi

Postby BlackSoll » Wed Mar 16, 2016 6:05 pm

ESF_nl wrote:Is it correct the UniPi Domoticz LUA script is saved in:
~/domoticz/scripts/lua/script_UniPi_domoticz.lua


Here is the mistake !!!!!!!!!!!!!!! Leave localhost as it is.

Rename the script to : script_device_UniPi.lua

All of your scrips must start with script_device for hardware.........

File system based Lua scripts should be placed in the /home/pi/domoticz/scripts/lua directory. Since Lua is integrated in Domoticz it knows about the status of switches and sensors (the commandArray variable) which makes it easy to interact.
In the scripts directory the lua directory can be found. The lua scripts are named "script_device_demo.lua" and "script_time_demo.lua". By copying these examples and changing demo into a sensible identifier like script_device_light2.lua the script will become active. Device scripts will be run at every device change and time scripts will be run every minute


See here https://www.domoticz.com/wiki/Domoticz_and_Scripting
ESF_nl
Posts: 9
Joined: Mon Mar 14, 2016 3:11 pm

Re: domoticz home control and unipi

Postby ESF_nl » Thu Mar 17, 2016 8:17 pm

WOW! Super! I'm so happy the UniPi works with my Domoticz now! :D :D :D
Thank you all for your help. Couldn't have done it without you.

Return to “Installations ideas&realizations”

Who is online

Users browsing this forum: No registered users and 1 guest