Domoticz home control and unipi

  • built a script for the domoticz project ... =23&t=7932

  • built a script for the domoticz project ... =23&t=7932

  • 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?

  • @ESF_nl:1wzpyg4q:

    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 ?

  • 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…[attachment=0:2t7hpg0u]Domoticz dashboard.PNG[/attachment:2t7hpg0u]
    Do I have to start or load some script or program? I'm not that experienced in this field

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

    idxr1 = 40
    relay1name = "uniPi_Relais1"

  • 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.
    [attachment=1:31eyc481]Domoticz devices.PNG[/attachment:31eyc481] I did a reboot but unfortunately still no success.
    [attachment=0:31eyc481]Domoticz dashboard2.PNG[/attachment:31eyc481]
    It feels like I'm so close!

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

    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.

  • 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 Unfortunately changing it to 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.
    [attachment=0:qeoq8655]Domoticz hardware.PNG[/attachment:qeoq8655]
    Is it correct the UniPi Domoticz LUA script is saved in:

    and the json.lua in:

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

    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!

  • @ESF_nl:3i5lzae8:

    Is it correct the UniPi Domoticz LUA script is saved in:

    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

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

  • Glad it helped

    Keep in mind that you can name your switches whatever you,livving room light,hot water switch etc.
    Just put the same name to your script too and all work ok

  • Does anybody know what this error message means in the Domoticz log?

     2016-03-21 21:23:26.843 Error: EventSystem: commandArray in script /home/pi/domoticz/scripts/lua/script_device_UniPi.lua should only return ['string']='actionstring' or [integer]={['string']='actionstring'}
    2016-03-21 21:23:57.866 Error: EventSystem: commandArray in script /home/pi/domoticz/scripts/lua/script_device_UniPi.lua should only return ['string']='actionstring' or [integer]={['string']='actionstring'}
    2016-03-21 21:23:59.242 Error: EventSystem: commandArray in script /home/pi/domoticz/scripts/lua/script_device_UniPi.lua should only return ['string']='actionstring' or [integer]={['string']='actionstring'} 
    ```I've got screens full of them…

  • I think that it has to do with user variables. Did you do this correctly ? Go to setup->more options->user variables

    to use these you also need to create a user variable as a floating variable and name it 'ai1_value' assign a default level of zero
    --and respectivly 'ai2_value' for the 2nd sensor also floating and also starting with zero

    But best to ask about these questions on domoticz forum cause it has to do with it's settings and scripting and not unipi. You will get more support there about scripts

  • @ESF_nl
    Hi ESF_NL, I've just got the unipi working on raspberry pi running domoticz.
    Everything is working except for the Dig. inputs. They work in evok, not in domoticz.

    Did you get these working?

    Kind regards ,

  • @vandura
    Hello Vandura,

    I am also using this Unipi board , domoticz and the Lua script ( version b0.98) fom Spudgunman. I can control the relays on the board but using the Digital inputs do not work. Did you got this working by now? If yes, how did you succeed?

    gts , Krist ON4API

  • @spudgunman

    Hello spudgunman ,

    Thank you for this script . I am using it to control the relays on the Unipiboard from my Domoticz system.
    But I should also like to use the inputs. Did you continue your development so that inputs can also be used?
    I am using your beta version 0.98.

    Kind regards,
    Krist - ON4API

  • Hey, some one get solution for digital inputs nad one wire? Relays works nice. Im realy dont mnie how config that in script.