Page 1 of 2

Eq3 Max - control with php scripts

Posted: Sunday 18 September 2016 18:08
by TikTicz
As summer is coming to an end, I wanted to share these php scripts with you. I use it to control the eq3 max valves/thermostats. Only the php scripts and a little (easy) blockly scripting in Domoticz is needed.

Attached a zip file with the php scripts and a readme.doc with a setup explanation.

I took this approach because I could not get de Max Buddy implementation to run (stable) in my environment. Furthermore I am not familiar with Python and Bash, so I decided to go forward with php.

The scripts (eq3………php) can also be used without Domoticz in case you want to write you own applications. The scripts reads values from your cube, and you will be able to set temperature of the valves. The scripts lacks functionality like holiday modus, etc. I use Domoticz for this kind of logic (and various other scenario’s).

As I only own a Eq3 Max cube and some valves, I developed code for this setup. In case you want to control other Eq3 Max devices, for example a wall thermostat you will need to do some additional coding.

The eq3class.php is based on code created by Mega (http://www.mega-nas.de/max/). I Just took his code and isolated the logic from the html. Did some rewriting to get a better understanding. Also solved some issues I ran into.

It runs very stable in my environment (rPi 3) and PHP also running on the Pi. While developing, I ran the php scripts on a Windows environment, also without any troubles.

I hope this helps to get the maximum comfort out of your Eq3 Max devices. I needed it to automate temperature in my house. Furthermore with the Domoticz mobile app, you can also control the Eq3 Max valves from a remote location. Although an Eq3 Max mobile app is in the appstore I am not a fan of Eq3 mobile app. Often temperature set in mobile app is not executed and the app lacks several options.

Re: Eq3 Max - control with php scripts

Posted: Sunday 18 September 2016 20:09
by Westcott
Hi TikTicz,

It's also possible to read/write the Cube using Lua directly.
See -
http://www.domoticz.com/forum/viewtopic ... &start=160

Re: Eq3 Max - control with php scripts

Posted: Wednesday 21 September 2016 19:37
by TikTicz
Hi Westcott,

I noticed. Good jod, no doubt. I went for PHP, because that is my personal favour. LUA will be a better approach for many. I just wanted to share this peace of code, for those also using PHP.

Re: Eq3 Max - control with php scripts

Posted: Saturday 29 October 2016 15:38
by bearded
Hi TikTicz,

Thanks for the .php code! I'm trying to integrate the MAX! system into my Domoticz automations. I've been using one-way JSON commands through the MAX! home automation software but without any feedback / control through Domoticz.

With my very limited scripting knowledge I have followed your helpful guide and have installed XAMPP as a .php server on my windows 10 machine. All .php scripts are saved in the domoticz/scripts\eq3 folder and also in the \xampp\htdocs folder too. I've updates the appsettings.php file with the ip addresses and ports for the cube and domoticz.

When running eq3read.php I get the following error in my browser:

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\eq3class.php on line 69

Fatal error: Call to undefined method Eq3Class::CloseSock() in C:\xampp\htdocs\eq3read.php on line 15

Do you have any idea where I might be going wrong? It's my nirvana to get full heating control though Domoticz and I'm trying desperately to find a solution!

Thanks in anticipation!

Re: Eq3 Max - control with php scripts

Posted: Saturday 29 October 2016 15:42
by Skippiemanz
Check the last posts in this topic! http://www.domoticz.com/forum/viewtopic.php?t=841

Re: Eq3 Max - control with php scripts

Posted: Sunday 30 October 2016 7:24
by bearded
Skippiemanz wrote:Check the last posts in this topic! http://www.domoticz.com/forum/viewtopic.php?t=841
Thanks @Skippiemanz but I'm a bit confused by that whole thread (it doesn't take muchImage) and I'm even less familiar with lua than I am with php! Unless there's a step by step wiki I'm lost! Thanks for the head's up though. Image


Sent from my iPhone using Tapatalk

Re: Eq3 Max - control with php scripts

Posted: Sunday 30 October 2016 13:48
by Skippiemanz
They are going to write it all up in a wiki and maybe even making a plugin! So keep youre eye on the updates of that thread

Re: Eq3 Max - control with php scripts

Posted: Sunday 30 October 2016 13:57
by bearded
Skippiemanz wrote:They are going to write it all up in a wiki and maybe even making a plugin! So keep youre eye on the updates of that thread

Brilliant! Will do. Thanks again. :-)


Sent from my iPhone using Tapatalk

Re: Eq3 Max - control with php scripts

Posted: Sunday 30 October 2016 19:53
by TikTicz
Hi Beared,

I have the same error when I configure a wrong ip or port for the cube in appsettings.php

Add this line of code in eq3read.php below line 13 ("$eq3arr = $eq3->OpenSock($cubehost,$cubeport);" ):
print_r($eq3->retarr);

This will print the array with the connection error message, or an empty array if no errors occur.
In case the cube ip is wrong, the message will be something like "10061Connection Error .............................. "
In case the cube port is wrong, the message will be something like "10060Connection Error .............................."

Also be aware the cube ip can change whenever the router is rebooted, or the cube is rebooted.
If you want always want the same ip address for the cube give the cube a static ip address in the router. A static ip address is preferred.

Hope this helps,
TikTicz

Re: Eq3 Max - control with php scripts

Posted: Tuesday 01 November 2016 9:45
by bearded
@TiktTicz. Working perfectly now, thank you very much! As you suspected there was simply a small error in my i.p. addresses. Thanks very much for a great bit of scripting and a superb user guide. It's just what I've been looking for and I now have full individual control of my rad. Now I've achieved this level of control I'll be ordering another 5 eQ3 valves this week and adding them to the system.

// Just thinking, it would be great if we could read the actual temp of each valve along with the set temp. Therefore we could then write a blockly that would switch off the boiler at a 'boiler switch' when all valves were reading an actual temp within 20% of their set temp and if any dropped lower than this % the boiler could switch on! //

Once again, thank you for your efforts, really appreciate it! :D

Re: Eq3 Max - control with php scripts

Posted: Tuesday 01 November 2016 17:05
by blackdog65
Skippiemanz wrote:They are going to write it all up in a wiki and maybe even making a plugin! So keep youre eye on the updates of that thread
Just an update, the wiki for the lua version is up
https://www.domoticz.com/wiki/EQ3_MAX!
Good luck with the PHP, maybe we'll see some cross pollination in the future :D
Sean

Re: Eq3 Max - control with php scripts

Posted: Friday 04 November 2016 23:01
by TikTicz
Hi Beared,

// Just thinking, it would be great if we could read the actual temp of each valve along with the set temp. Therefore we could then write a blockly that would switch off the boiler at a 'boiler switch' when all valves were reading an actual temp within 20% of their set temp and if any dropped lower than this % the boiler could switch on! //

Since I like the idea, I have been looking into this. However it seems not possible the read the actual temperature from the valve.

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 10:56
by jack74
Hi TikTicz,

first of all I would say "very very good job"... ;) then I followed your instructions and I tried the script to read the Qube status and it worked very well (it showed all the status valves), then I tried to use the domocreatenewhardw.php and after few seconds it said "done" but when I go in domoticz I can't se any devices... :roll: :roll: what I'm wronging? Could you help me?

Thanks a lot,

Jack

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 18:08
by TikTicz
Hi Jack74,

I investigated the script and noticed I did not implement error handling very well. But my best guess for now is to make sure the ipaddress and port of the domoticz server are set to the good values in script appsettings.php.

If you think they are o.k., verify by entering this url in your browser http://ipaddress:port ( for example http://192.168.1.34:8080 )
Replace "ipadress" by the ipaddress you configured in appsettings.php at variable: $domoticzhost
Replace "port" by the port you configured in appsettings.php at variable: $domoticzport
To be sure copy and paste the values in the url. If these are set to the proper values, your browser should show the Domoticz Dashboard page.

Hope this helps,
TikTicz

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 18:28
by jack74
Hi TikTicz,
thanks a lot for your quickly answer... :)

I attached my configuration and I think that it should be correct.
Can you indicate me where I should find the files generated by the script? Is it possible that I have some permission limits?


Jack

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 19:00
by TikTicz
The syntax seems ok. Did you try "http://192.168.1.4:8080" in your browser and did it show the Domoticz dashboard?

I am not aware of any permission limits.

The script does not generate files. It creates devices in Domoticz. You can check this by selecting tabmenu "Setup" in domoticz and in the dropdownlist choose "Devices" and in one of the pages you should see something like on the screen print I included.
Klembord-2.jpg
Klembord-2.jpg (38.06 KiB) Viewed 18545 times
Also in tabmenu "Setup", option "Hardware" you should find "Eq3Virtual".
Klembord-4.jpg
Klembord-4.jpg (8.47 KiB) Viewed 18545 times

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 19:40
by jack74
Yes, I tried and it works...

I attached the http://192.168.1.4/eq3/eq3read.php results...

I don't know how to go on...

:roll:

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 19:52
by TikTicz
The eq3read.php results are fine.

Did you find "Eq3Virtual" in your Domoticz hardware tab? Can you provide a screenshot of your Domoticz hardware page?

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 19:56
by jack74
I attached two screnshots...

I hope that you can understand why the script doesn't work...

Thanks a lot for your support...

Re: Eq3 Max - control with php scripts

Posted: Sunday 20 November 2016 20:28
by TikTicz
Attached a new version of the script files. As they contain some minor (not related) improvements replace your script files with the new ones. Also find an additional script domocreatenewhardwx.php
This is the same code as domocreatenewhardw.php but with some additional print instructions for debugging. Run domocreatenewhardwx.php and see if the result makes sense to you. If not upload the result of this script and I will take a look.