ELV!Cube PHP Library

Forum about the home automation suites by ELV etc

Moderator: jrkalf

SilentHunter
Starting Member
Starting Member
Posts: 1
Joined: Sat Dec 28, 2013 12:53 pm

ELV!Cube PHP Library

Post by SilentHunter »

Hi *,

I have written a complete single (standalone) PHP Library (Object Orientated) for controlling and reading the Max!Cube and Max!Devices. (If anybody is interested please ask me :D )
Many reading operations are based on the script our user mega (many thanks for that) uploaded.

But I got stuck at a very important point. The weekly program. From the, I call it "mega-script", he wrote:

Code: Select all

for ($j = 1 ; $j <= 7 ; $j++)
{
	$readlen = 26;// Sat, Sun, Mon, Tue, Weg, Thu, Fri
	$program = array();
	unset($program);
	for($i = $pos; $i < $readlen+$pos ; $i+=2)
	{
		$bin  = str_pad(decbin(hexdec(dechex(ord(substr($str,$i,1))))),8,"0",STR_PAD_LEFT).str_pad(decbin(hexdec(dechex(ord(substr($str,$i+1,1))))),8,"0",STR_PAD_LEFT);
		//echo $bin."  ";
		$deg = bindec(substr($bin,0,7));
		//$deviceconf[$hilf["RFAdress"]]["WeeklyProgramm".$j.""] .= ($deg/2)."^C ";
		$min = bindec(substr($bin,7,9));
		//$deviceconf[$hilf["RFAdress"]]["WeeklyProgramm".$j.""] .= number_format(($min*5/60),2)."hr | ";

		
		$program["deg"][] = ($deg/2);
		$program["time"][] = number_format(($min*5/60),2);
	}
	$pos += $readlen;
}
But the problem is that I am getting strange time values:

Code: Select all

8.58 - 17.67 - 23.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00 - 24.00
What is 17:67? This time does not exist or am I wrong?

Happy hollidays and a happy new year 2014!

SilentHunter
Massi
Member
Member
Posts: 51
Joined: Tue Nov 05, 2013 4:01 pm

Re: ELV!Cube PHP Library

Post by Massi »

Hello Silent!
I also started working on php+max cube so i'm really interested in your library :)
At the moment, i'm only reading from the cube (i'm reading from my thermostates the instant temperature and the programmed temperature and from my devices the valve aperture %)
Saving these data on a mysql db every 5 minutes allows me to graph the actual temp - set temp - aperture percentage.
I haven't worked on weekly programm yet, so we can help each other maybe :)

My system: cube + 6 thermostates + 7 devices + eco switch

i can't pm you..
User avatar
Phaeton
Advanced Member
Advanced Member
Posts: 573
Joined: Wed May 19, 2010 12:44 pm
Location: Wassenaar
Contact:

Re: ELV!Cube PHP Library

Post by Phaeton »

Hello silent. I'm also interested in your library. I'll soon start working with max.

Verstuurd vanaf mijn GT-I9300 met Tapatalk
groeten,
Harry
Massi
Member
Member
Posts: 51
Joined: Tue Nov 05, 2013 4:01 pm

Re: ELV!Cube PHP Library

Post by Massi »

btw, i'm quite sure we are loosing something in reading C entry for weekly program.
I mean, this is my C entry for one of my wall thermostats

C:07de3e,ywfePgMEEP9LRVEwMjQ0MDc5KCA9CUBsRpxNDkEgQSBBIEEgRSBFIEUgRSBFIEUgQGxNDkEgQSBBIEEgQSBFIEUgRSBFIEUgRSBAVExgQMBE2E0OQSBBIEUgRSBFIEUgRSBFIEBUTGBAwETYTQ5BIEEgRSBFIEUgRSBFIEUgQFRMYEDARNhNDkEgQSBFIEUgRSBFIEUgRSBAVExgQMBE2E0OQSBBIEUgRSBFIEUgRSBFIEBUTGBAwETYTQ5BIEEgRSBFIEUgRSBFIEUg

And this is the C entry for the radiator of the SAME room of the above thermostat
C:077461,0gd0YQIEEP9LRVEwMDQ2NDA3KCA9CQcUAzRM/wBAbEacTQ5BIEEgQSBBIEUgRSBFIEUgRSBFIEBsTQ5BIEEgQSBBIEEgRSBFIEUgRSBFIEUgQFRMYEDARNhNDkEgQSBFIEUgRSBFIEUgRSBAVExgQMBE2E0OQSBBIEUgRSBFIEUgRSBFIEBUTGBAwETYTQ5BIEEgRSBFIEUgRSBFIEUgQFRMYEDARNhNDkEgQSBFIEUgRSBFIEUgRSBAVExgQMBE2E0OQSBBIEUgRSBFIEUgRSBFIA==

Base64 decoded, they have not the same data in the weekly program range. And they should, isn't it?
I tried fetching weekly program data from the thermostat and could not match it with my real program.
So basically i'm lost :)
any idea? :)
Massi
Member
Member
Posts: 51
Joined: Tue Nov 05, 2013 4:01 pm

Re: ELV!Cube PHP Library

Post by Massi »

Ok, adding a piece to my previous answer i can't see yet :)
From the radiator thermostat you can find the weekly program. Starting from byte 29, as described in the other 3d.
The "problem" of your "17:67" is that you are applying the wrong function (number_format) instead of applying something like:

$minutes = $minutes = bindec(substr($singleDayProgram,7,9))*5; //you did this right
$endHour = intval($minutes/60); //this is the hour the single piece of program will end
$emdMinute = str_pad($minutes%60,2,"0",STR_PAD_LEFT); //this is the minute the single piece of program will end, it's the MOD of the division padded to lenght 2

It's a time, so your "17:67" is, i think, 17:40 (two third - 67% - of an hour)
isn't it? :)

Looking to the C entry of my wall thermostat, it seems that weekly program data starts from 22nd byte..
blake7
Starting Member
Starting Member
Posts: 3
Joined: Fri Jan 10, 2014 2:41 pm

Re: ELV!Cube PHP Library

Post by blake7 »

Hi, I'd be interesting in knowing more about this. I'm no programmer but can work my way through things. I'm trying to get a system that will read all the devices and report the actual temperature, etc., and build up a history. I'm looking for a simply set of instructions / step and what program / front end to use. I currently have 9 TRV's, 3 Wall Thermostat's and 1 Cube. Thanks.
pbrand
Member
Member
Posts: 100
Joined: Wed Oct 01, 2008 10:17 pm
Location: Netherlands
Contact:

Re: ELV!Cube PHP Library

Post by pbrand »

Massi wrote: Looking to the C entry of my wall thermostat, it seems that weekly program data starts from 22nd byte..
The C entry has different data for the radiator thermostat and the wall thermostat, Massi.

The device specific data of the wall thermostat has four temperature settings (comfort, eco, max set point, min set point) and then the weekly program whereas the radiator thermostat has more settings (like temperature offset, decalcification settings, boost settings etc.) so they do not begin at the same byte position.

One thing I found out by the way was that the time of a set point in the weekly program is used as the to time and not the from time.

So if a set point in the byte array says 19 degrees, 08:00, it means the thermostat will be set to 19 degrees, until 08:00 and not, like I first thought, from 08:00.

Also I think the weekly program in the 'normal' radiator thermostat is a dummy, since the 'normal' radiator thermostats don't have a weekly program. For that, you need the thermostat+, or of course the wall thermostat.
pbrand
Member
Member
Posts: 100
Joined: Wed Oct 01, 2008 10:17 pm
Location: Netherlands
Contact:

Re: ELV!Cube PHP Library

Post by pbrand »

blake7 wrote:Hi, I'd be interesting in knowing more about this. I'm no programmer but can work my way through things. I'm trying to get a system that will read all the devices and report the actual temperature, etc., and build up a history. I'm looking for a simply set of instructions / step and what program / front end to use. I currently have 9 TRV's, 3 Wall Thermostat's and 1 Cube. Thanks.
Search in the forum blake, and you will find several people who have already written some software to do this. Some of which are more willingly to share their software than others of course :)

You can look at those packages to see if they suit you. And if you have the patience you can wait for yet another software from me :mrgreen:

I'm planning to write a MAX! gateway which use MQTT for communication. And also planning to rewrite my google calendar scheduler to also use MQTT so it can control the max! thermostats in a more intelligent way (with preheating algorithms) then the thermostats itself do.
Massi
Member
Member
Posts: 51
Joined: Tue Nov 05, 2013 4:01 pm

Re: ELV!Cube PHP Library

Post by Massi »

pbrand wrote:The C entry has different data for the radiator thermostat and the wall thermostat, Massi.
We are sure about this, now :)
i didn't find this case in the "protocol" thread..
Also I think the weekly program in the 'normal' radiator thermostat is a dummy, since the 'normal' radiator thermostats don't have a weekly program. For that, you need the thermostat+, or of course the wall thermostat.
i can confirm that thermostat+ and wall thermostat have the same format of weekly program. I have not simple thermostat so don't know that case :)

Can i ask you something about your "preheating algorithms"?
How do you think you can handle the different heating time with different outside temp?
More than this, gaining 1 degree between 20 and 21 will take much longer than from 16 and 17..
just curious :)
pbrand
Member
Member
Posts: 100
Joined: Wed Oct 01, 2008 10:17 pm
Location: Netherlands
Contact:

Re: ELV!Cube PHP Library

Post by pbrand »

Massi wrote:We are sure about this, now :)
i didn't find this case in the "protocol" thread..
I think the protocol thread is a bit outdated since there is more information coming available but that thread doesn't seem to be maintained anymore. But still, it contains a lot of usefull information :)
Massi wrote: Can i ask you something about your "preheating algorithms"?
How do you think you can handle the different heating time with different outside temp?
More than this, gaining 1 degree between 20 and 21 will take much longer than from 16 and 17..
just curious :)
My first version of the 'algorithm' is fairly simple actually. I do not take into account, the outside temperature yet. Also, I have defined the delta T for a room as a constant. In my experience heating from 16-17 or 20-21 makes not a large difference. At least not in my house :)

4 hours before a temperature change is scheduled (in google calendar) I check the room temperature and the desired temperature. Based upon the delta T for the room at some point it needs to start heating which it does. If at some point it seems that the target temperature won't be reached in time, I increase the desired temperature with 5 degrees. This will result in opening the radiator valve at 100%.

As you can see the algorithm is extremely simple. However, I have been using it for more than a year now and though simple, it also works :)
There are lots of caveats one can think of and room to improve. But well, since in practise it actually works quite well, I have no great need to improve the algorithm.

But planned improvements for the next version might be:
-take the outside temperature into account (but only if it changes very suddenly or so)
-dynamically adjust the delta T parameter for a room based upon gathered statistical data

So to summarise, my algorithm is ridiculously simple and does not take in to account any of your possible caveats.

But still it works very well :)
Massi
Member
Member
Posts: 51
Joined: Tue Nov 05, 2013 4:01 pm

Re: ELV!Cube PHP Library

Post by Massi »

pbrand wrote:I think the protocol thread is a bit outdated since there is more information coming available but that thread doesn't seem to be maintained anymore. But still, it contains a lot of usefull information :)
This makes sense :)
As far as you know, is there an updated "bible" of the protocol?
So to summarise, my algorithm is ridiculously simple and does not take in to account any of your possible caveats.
But still it works very well :)
Thanks :)
pbrand
Member
Member
Posts: 100
Joined: Wed Oct 01, 2008 10:17 pm
Location: Netherlands
Contact:

Re: ELV!Cube PHP Library

Post by pbrand »

Massi wrote:As far as you know, is there an updated "bible" of the protocol?
As far as I know there is not, Massi. There are several sources of information, mainly existing software packages like fhem, max buddy, hacs etc.

I am however intending to blog about my findings regarding searching in all packages I know of. So that should result in an up-to-date overview again :D And I also intend to keep that information as up-to-date as possible as far a I am (made) aware of new insights :)
mane
Starting Member
Starting Member
Posts: 1
Joined: Sat Mar 15, 2014 12:25 pm

Re: ELV!Cube PHP Library

Post by mane »

Hi silenthunter,
I'm also intrested in getting your max-php library.
Iwant to include it in my ip-symcon environment.

Thanks forward... :)
wwolkers
Member
Member
Posts: 273
Joined: Tue Sep 23, 2008 10:10 am
Location: Netherlands
Contact:

Re: ELV!Cube PHP Library

Post by wwolkers »

https://github.com/Bouni/max-cube-protocol contains quite some usefull information, in case it wasn't posted here yet
Kingsammy
Starting Member
Starting Member
Posts: 17
Joined: Mon Dec 19, 2011 11:10 am

Re: ELV!Cube PHP Library

Post by Kingsammy »

Hello,

i am also interested in your php-library. Can you please send it to me? Thanks in advance.

Best regards

Kingsammy
Post Reply

Return to “Homematic, FS20, FHT, ESA and ELV”