ELV Max! Heating control system

For heating/cooling related questions in Domoticz

Moderator: leecollings

BobS
Posts: 15
Joined: Friday 05 June 2015 11:49
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Rotterdam, NL
Contact:

Re: ELV Max! Heating control system

Post by BobS »

Use Max! tot three years now.
Setup:
Cube,
Living room with 2 radiator thermostats, wall thermostat and windowswitch on garden door.
4 rooms with 1 radiator thermostat, wall thermostat and windowswitch each.
Eco switch (hardly used).
Switch to turn pump on/off (city heating)

I use my own program on the raspberry pi with domoticz.
All temperatures, setpoints, radiator flows and windows status are visible in domoticz.
Setpoints for the wall thermostats are set through timers in domoticz.

All works fine, only problem I have is the Cube losing it's configuration a few times each year.
If that happens local control still works and Domoticz still receives data until it is rebooted.

Bob.
n1c0l45
Posts: 37
Joined: Monday 25 April 2016 9:45
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.4834
Location: France
Contact:

Re: ELV Max! Heating control system

Post by n1c0l45 »

Thanks for the feedback. When the cube lose its configuration, a simple reboot fix it or do we have to reconfigure everything? Is it possible to save the configuration?
BobS
Posts: 15
Joined: Friday 05 June 2015 11:49
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Rotterdam, NL
Contact:

Re: ELV Max! Heating control system

Post by BobS »

When the Cube looses the configuration rebooting the Cube will not help.
You must then teach in the devices again and configuration must be entered with the (windows) utility program.
Sometimes not all devices are gone but just some.
Happens to me about 2 to 3 times a year.
I have seen more reports of this on the internet.

As far as I know there is no official tool to backup and restore the configuration.
I have seen some reports about such a tool on the net but never bothered to try it.
n1c0l45
Posts: 37
Joined: Monday 25 April 2016 9:45
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.4834
Location: France
Contact:

Re: ELV Max! Heating control system

Post by n1c0l45 »

that's quite annoying if you have to do the settup é or 3 times a year!
and the most recent versions also seems to have to problem...
I really don't know if i take the risk r if i pay more to get something "safer"
jorishp

Re: ELV Max! Heating control system

Post by jorishp »

http://download.kopsan.de/test/ there was a backup tool from Max!buddy.
did not test it with the latest firmware
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

ELV Max! Heating control system

Post by mvzut »

jorishp wrote:http://download.kopsan.de/test/ there was a backup tool from Max!buddy.
did not test it with the latest firmware
Thanks, didn't know about that one. However, the program (at least the windows version) relies on the maxbuddy.de domain being available to download stuff from, which it isn't. I was partly able to trick it into downloading files from a local server (by changing my hosts file), but it still complains about libraries it can't download, so I'm stuck.

Pitty, would have been great if I could do backups, since my Cube still looses all it's settings about every 3-4 weeks. There are only 4 devices, and I have become so "trained" in it that I have connected everything again in under 5 minutes, but it's still annoying.

When I have time I'll also try the Linux version of the backup program, although that requires me to use a graphical UI which is disabled on my Domoticz system and I don't want to fiddle with it too much. But I have another Pi lying around somewhere that I could try it with, I'll keep you posted.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
wmccann
Posts: 1
Joined: Wednesday 21 September 2016 23:27
Target OS: Windows
Domoticz version:
Contact:

Re: ELV Max! Heating control system

Post by wmccann »

Hi,

Been using Max! system since March 2013 now with homeseer. Took a bit of programing but have it working - had it even setup that if you press boost in a room, the boiler would be switched on by HS.

1) MaxBuddy has not worked for about 2 years - there was a firmware upgrade which changed a lot of how the system worked - the developer of MaxBuddy! stopped supporting it at this point - pity as it was a good piece of software

2) I have about 2 configuration losses per year (have 11 rooms, 11 thermostats and 13 valves). I am fairly sure it has to do with how often you access the cube - I was polling it every 5 minutes, now I do it about every 15 it does not happen as often. I was so exasperated that I bought a second cube to see if I had a faulty one (about 2 years after the first one) - no difference.

3) Unfortunately the support from ELV is hopeless - They have ignored the config loss issue since the start.

It is the best system I have seen so far, though pity about the config issue. Still looking for the utopian solution.

W.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

ELV Max! Heating control system

Post by mvzut »

Thanks for sharing your experiences wmccann!
wmccann wrote:Hi,

Been using Max! system since March 2013 now with homeseer. Took a bit of programing but have it working - had it even setup that if you press boost in a room, the boiler would be switched on by HS.
Welcome HomeSeer user, what brought you to the Domoticz forum? Thinking about stepping over? Image
I also control my boiler depending on the demand for heat, in fact that's the main purpose why I wanted to integrate it into Domoticz. I poll the valve positions and if one of them is above say 20% the boiler will be turned on using the OTGW.
wmccann wrote: 1) MaxBuddy has not worked for about 2 years - there was a firmware upgrade which changed a lot of how the system worked - the developer of MaxBuddy! stopped supporting it at this point - pity as it was a good piece of software
I did use MaxBuddy for a while, i.e. the Linux version in a headless mode, calling a custom script every minute that handled the communication with Domoticz. This (kind of) worked for me until I stepped over to direct communication to the Cube using lua, half a year ago or so. The only thing that didn't work well was sending temperature setpoints to the MAX! system.
wmccann wrote: 2) I have about 2 configuration losses per year (have 11 rooms, 11 thermostats and 13 valves). I am fairly sure it has to do with how often you access the cube - I was polling it every 5 minutes, now I do it about every 15 it does not happen as often. I was so exasperated that I bought a second cube to see if I had a faulty one (about 2 years after the first one) - no difference.
You seem to have way less configuration losses than me. You trigger me with your remark on the polling frequency, I do it every minute! Now changed this to 5 minutes, see what that does. More than 5 minutes will effectively make the solution worthless for me, since I control my boiler with it and that would mean my family members will start to complain that the room is not heating up.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Scheffie
Posts: 7
Joined: Wednesday 18 September 2013 21:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

ELV Max! Heating control system

Post by Scheffie »

I'm currently using the Max cube for several years using the headless configuration and never lost any data on the cube. The only disturbance I have is the decalcification. I really wish you could disable this function since the calibration on my valves is not accurate enough (only one is calibrating correctly)
sylre
Posts: 1
Joined: Monday 03 October 2016 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ELV Max! Heating control system

Post by sylre »

Hey !

Just tried your script and getting an error :

Code: Select all

2016-10-03 09:21:00.588 Error: EventSystem: in /root/domoticz/scripts/lua/script_time_max.lua: /root/domoticz/scripts/lua/script_time_max.lua:132: attempt to concatenate field '?' (a nil value)
Any idea ?

Thanks !

Sylvain
mvzut wrote:I finally found some time to build te functionality I wanted (based on your great code Westcott)!

Firstly, I created the following (virtual) devices in Domoticz:
- a temperature sensor for each room
- a thermostat setpoint for every wall mounted thermostat
- a percentage sensor for each valve (optional, but I need this to control my heater)

I named the devices exactly the same as in the MAX! Cube configuration, this is very important otherwise my script will not work. The temperature sensors have to be named afer the MAX! room names.

I am currently using this script (I called it "script_time_max.lua" and put it in ~/domoticx/scripts/lua):

Code: Select all

package.loadlib("core.so", "*")
local Socket = require "socket"
local Basexx = require "basexx"

local MaxIP='192.168.178.46'
local MaxPort = 62910

local Rooms   = {}
local Devices = {}
local Room_nums = {}

function age(timestring)
  t = {}
  t.year = string.sub(timestring,1,4)
  t.month = string.sub(timestring,6,7)
  t.day = string.sub(timestring,9,10)
  t.hour = string.sub(timestring,12,13)
  t.min = string.sub(timestring,15,16)
  t.sec = string.sub(timestring,18,19)
  return os.difftime(os.time(),os.time(t))
end

function maxCmd_H(data)
--   print('H='..data)
end

function maxCmd_M(data)
   i = 0
   j = 0
   
    while true do    -- find next comma
      i = string.find(data, ",", i+1)
      if not i then break end
     j = i
    end
   
   s   = data:sub(j+1)
   dec = Basexx.from_base64(s)
   num_rooms = string.byte(dec,3)
   pos=4
   
   for i=1, num_rooms do
      room_num = string.byte(dec, pos)
      name_len = string.byte(dec, pos+1)
      pos  = pos+2
      name = dec:sub(pos, pos+name_len-1)
      pos  = pos+name_len
      adr  = Basexx.to_hex(dec:sub(pos, pos+2))
      Rooms[room_num] = name
      pos = pos+3
   end
      
   num_devs = string.byte(dec, pos)
   for i=1, num_devs do
      dtype = string.byte(dec, pos+1)
      adr   = Basexx.to_hex(dec:sub(pos+2, pos+4))
      snum  = dec:sub(pos+5, pos+14)
      name_len = string.byte(dec, pos+15)
      pos  = pos+16
      name = dec:sub(pos, pos+name_len-1)
      pos  = pos+name_len
      room_num = string.byte(dec, pos)
      Room_nums[adr] = room_num
      Devices[adr] = name
   end

end

function maxCmd_C(data)
--   print('C='..data)
end

function maxCmd_L(data)
   pos = 1
   dec = Basexx.from_base64(data)
   L_hex = Basexx.to_hex(dec)
   L_len = string.len(L_hex)
   
   while (pos < L_len) do

      s = L_hex:sub(pos,(pos+1))
      data_len  = tonumber(s,16) + 1
      hex  = L_hex:sub(pos,pos+(data_len*2))
      adr  = hex:sub(3,8)
      room_num = string.format("%02X", Room_nums[adr])
      room = Rooms[Room_nums[adr]]
      name = Devices[adr]
      if not name then name=adr end
      valve_info = tonumber(hex:sub(13,14),16)
      batt = bit32.extract(valve_info,7,1)
      bst  = bit32.extract(valve_info,3,1)
      mode = bit32.extract(valve_info,0,2)
      
      if (batt==0) then sbat="OK" else sbat="Low" end
      if (mode==0) then smode="Auto" elseif (mode==1) then smode="Manual"
      elseif (mode==2) then smode="Holiday" elseif (mode==3) then smode="Boost" end
      

      if (data_len == 13) then	-- WallMountedThermostat (dev_type 3)
        valve_pos = -1
        s = hex:sub(17,18)
        setpoint = tonumber(s,16) / 2
        s = hex:sub(23,26)
        temp = tonumber(s,16) / 10
        dtype = "Thermostat"
      elseif (data_len == 12) then -- HeatingThermostat (dev_type 1 or 2)
        s = hex:sub(15,16)
        valve_pos = tonumber(s,16)
        s = hex:sub(17,18)
        setpoint = tonumber(s,16) / 2
        if (mode ~= 2) then
          s = hex:sub(19,22)
          temp = tonumber(s,16) / 10
        else
          temp = 0
        end
        dtype = "Valve"
      end
      
      if temp < 5 then temp = temp + 25.5 end --necessary since first two digits seem to be unused?

	  
      -- Update virtual devices in Domoticz and update MAX! setpoints if necessary
      --print(dtype.."  "..name.."  Setpoint="..setpoint.."  Temp="..temp.."  Valve pos="..valve_pos)
      
      if dtype == "Valve" then
	if tonumber(otherdevices_svalues[name]) ~= valve_pos then
          table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..valve_pos})
        end
		
      elseif dtype == "Thermostat" then
        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[room]..'|0|'..temp})
	setpoint_Domoticz = tonumber(otherdevices_svalues[name])
	if setpoint_Domoticz ~= setpoint then
          if age(otherdevices_lastupdate[name]) > 60 then --Domoticz thermostat value must be updated
            table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..setpoint})
          else --Max! setpoint must be updated
            MaxCmdSend(adr, room_num, "manual", setpoint_Domoticz)
          end
        end
      end

      pos = pos + (data_len*2)
   end
end


function MaxCmdSend(id, room, mode, setpoint)

   bits  = setpoint * 2
   smode = string.upper(mode)
   if smode == 'MANUAL' then
      bits = 64 + bits
   elseif smode == 'BOOST' then
      bits = 192 + bits
   elseif smode == 'VACATION' then
      bits = 128 + bits
   end

   hex = "000440000000"..id..room..string.format("%x",bits)
   sendStr = Basexx.to_base64(Basexx.from_hex(hex))
   i, status = tcp:send("s:"..sendStr.."\r\n")
   
   if not i then
      print("MAX TCP send failed - "..status)
      return
   end
end


commandArray = {}

tcp = Socket.connect(MaxIP, MaxPort)

if not tcp then
   print("Socket connect failed for "..MaxIP..':'..MaxPort)
   return
end

tcp:settimeout(2)

local time = os.date("*t")

while (time.min ~= 0) do
    s, status, partial = tcp:receive()
    if (status) then
      print("TCP receive - "..status)
      break
    end
      
   local line = (s or partial)
   local cmd  = line:sub(1,1)
   local data = line:sub(3)
   
   if (cmd == 'H') then
      maxCmd_H(data)
   elseif (cmd == 'M') then
      maxCmd_M(data)
   elseif (cmd == 'C') then
      maxCmd_C(data)
   elseif (cmd == 'L') then
      maxCmd_L(data)
      break
   end
end

tcp:close()

return commandArray
Now every minute all Domoticz thermostats are read, and if the value is different from the MAX! setpoint, a new setpoint is sent to the corresponding MAX! thermostat. If the setpoint has changed externally, e.g. on the wall-mounted thermostat itself of via the MAX! app, it is updated in Domoticz. Next to this, the actual room temperatures are logged in Domoticz (virtual) temperature sensors.

I'm very happy with the way it works now. There is still one minor problem/annoyance: When the script changes a thermostat setpoint in Domoticz, it takes more than 10 seconds for some strange reason. Everything works though, you only get an error message in the log. I have posted a question about this in another forum thread, seems more people are experiencing this problem.

Please note that this is all using manual setpoints. You can still use automatic temperature programs on your MAX! Cube, but these will be overridden every time you change the setpoint in Domoticz (and vice-versa). It's probably better (and in my opinion more user friendly too) to leave alone the MAX! programming functionality altogether, and create all your setpoint timers in Domoticz.

A nice addition to make it almost completely novice-proof could be automatic device creation at first time use. I've seen this being done using JSON commands somewhere, need to dive into that sometime. From that point on, it's probably not extremely difficult to convert it into an actual Domoticz plugin?! But at the moment that's still a few bridges too far for me... Image

Anyone interested in testing this code? After manually adding (and correctly naming!) all the required sensors, the code should work out-of-the-box, you only need to change the IP address of your Cube in the top section of the script.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: ELV Max! Heating control system

Post by mvzut »

sylre wrote:Hey !

Just tried your script and getting an error :

Code: Select all

2016-10-03 09:21:00.588 Error: EventSystem: in /root/domoticz/scripts/lua/script_time_max.lua: /root/domoticz/scripts/lua/script_time_max.lua:132: attempt to concatenate field '?' (a nil value)
Any idea ?

Thanks !

Sylvain
Is line 132 the following line?

Code: Select all

        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[room]..'|0|'..temp})
I assume you have at least one wall mounted thermostat, right? Otherwise it wouldn't even process this part of the script. The only explanation I can think of is that you don't have a temperature device for each room. You need to create these virtual temperature devices using the Dummy hardware component, and their names should be the same as the room names you use in your MAX! system (with the same spelling, capitals, etc.). Did you create such device(s)?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: ELV Max! Heating control system

Post by blackdog65 »

@mvzut
Hi there,
I've just tried your script and get this in the log

Code: Select all

 2016-10-04 17:15:01.042 Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_time_max.lua: /home/linaro/domoticz/scripts/lua/script_time_max.lua:1: unexpected symbol near '[' 
I realise that this may be because I don't have everything set up correctly yet.
Could you clarify exactly what virtual devices are needed per real device? i.e. wall stat = virtual thermostat etc.

Many thanks Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
daveabbott007
Posts: 7
Joined: Friday 03 June 2016 16:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ELV Max! Heating control system

Post by daveabbott007 »

Blackdog65, i had exactly the same issue - remove [ code ] and [ /code ] from the top and bottom of the script and it will clear the error.

I now have the following issue and cant find a resolve,

lua: max.lua:2: module 'basexx' not found:
no field package.preload['basexx']
no file '/usr/local/share/lua/5.2/basexx.lua'
no file '/usr/local/share/lua/5.2/basexx/init.lua'
no file '/usr/local/lib/lua/5.2/basexx.lua'
no file '/usr/local/lib/lua/5.2/basexx/init.lua'
no file './basexx.lua'
no file '/usr/share/lua/5.2/basexx.lua'
no file '/usr/share/lua/5.2/basexx/init.lua'
no file './basexx.lua'
no file '/usr/local/lib/lua/5.2/basexx.so'
no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/basexx.so'
no file '/usr/lib/lua/5.2/basexx.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './basexx.so'

anyone know how to resolve, /usr/local/share/lua/ and /usr/share/lua/ arnt on my Raspberry pi install, how do i install this?
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: ELV Max! Heating control system

Post by blackdog65 »

@daveabbott007
Many thanks... so obvious once you see it :roll:

I now get the

Code: Select all

2016-10-07 11:17:01.022 Error: EventSystem: in script_time_max.lua: [string "package.loadlib("core.so", "*")..."]:139: attempt to concatenate field '?' (a nil value)
error with both

Code: Select all

local useWMT = false
and

Code: Select all

local useWMT = true
As to your problem, I think it's similar to this viewtopic.php?f=34&t=841&start=160#p86836 I think it's down to a Debian bug with regard to where it puts lua-5.x i.e. in a non-standard location. Sorry I can't be more specific

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
c1381ie
Posts: 5
Joined: Friday 07 October 2016 22:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany, Stuttgart
Contact:

Re: ELV Max! Heating control system

Post by c1381ie »

mvzut wrote:
sylre wrote:Hey !

Just tried your script and getting an error :

Code: Select all

2016-10-03 09:21:00.588 Error: EventSystem: in /root/domoticz/scripts/lua/script_time_max.lua: /root/domoticz/scripts/lua/script_time_max.lua:132: attempt to concatenate field '?' (a nil value)
Any idea ?

Thanks !

Sylvain
Is line 132 the following line?

Code: Select all

        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[room]..'|0|'..temp})
I assume you have at least one wall mounted thermostat, right? Otherwise it wouldn't even process this part of the script. The only explanation I can think of is that you don't have a temperature device for each room. You need to create these virtual temperature devices using the Dummy hardware component, and their names should be the same as the room names you use in your MAX! system (with the same spelling, capitals, etc.). Did you create such device(s)?
Hi,

ich have the same Problem and can't find any Error in my config. I become the following error when i execute my script:

Code: Select all

pi@raspberrypi:~/domoticz/scripts$ lua script_time_max.lua
lua: script_time_max.lua:129: attempt to index global 'otherdevices_svalues' (a nil value)
stack traceback:
        script_time_max.lua:129: in function 'maxCmd_L'
        script_time_max.lua:213: in main chunk
        [C]: in ?
this are my device names i become shown from my rooms:

Code: Select all

pi@raspberrypi:~/domoticz/scripts$ lua max.lua
Rooms
-----
Schlafzimmer    0EB2AA
Flur    0EB427
Bad     0EAF39
GWC     0EB385
Kueche  0EB573
Wohnzimmer
        0AEEC4

Devices
-------
GWC-Thermostat  0EB385
Flur-Thermostat 0EB427
SZ-Fenster      0EB2AA
Bad-Termostat   0EAF39
SZ-Wandthermostat       0EE884
SZ-Balkontuere  0F1707
WZ-Fenster rechts       0AEEC4
WZ-Fenster Strasse      0AED89
Eco Taster      0810A7
WZ-Fenster links        0AEEC2
Kueche-Thermostat       0EB573
WZ-Fensterkontakt       073B4A
SZ-Balkon       0EAFDC
WZ-Wandthermostat       09128A
WZ-Couch        0EB389
PuTTYPuTTYPuTTYPuTTY
Device status
-------------
Valve   WZ-Fenster links        Setpoint=15     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Thermostat      SZ-Wandthermostat       Setpoint=16     Temp=19.9       Valve pos=-1    Battery=OK      Mode=Manual
Valve   SZ-Fenster      Setpoint=16     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Valve   WZ-Fenster Strasse      Setpoint=15     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Valve   Kueche-Thermostat       Setpoint=5      Temp=17.5       Valve pos=0     Battery=OK      Mode=Manual
Valve   Flur-Thermostat Setpoint=5      Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Valve   WZ-Couch        Setpoint=15     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Valve   WZ-Fenster rechts       Setpoint=15     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Valve   Eco Taster      Setpoint=15     PuTTYTemp=0     Valve pos=0     Battery=OK      Mode=Auto
Valve   SZ-Balkon       Setpoint=16     Temp=0  Valve pos=0     Battery=OK      Mode=Manual
Thermostat      WZ-Wandthermostat       Setpoint=15     Temp=19.1       Valve pos=-1    Battery=OK      Mode=Manual
Thermostat      WZ-Fensterkontakt       Setpoint=15     Temp=19.1       Valve pos=-1    Battery=OK      Mode=Auto
Thermostat      SZ-Balkontuere  Setpoint=15     Temp=19.1       Valve pos=-1    Battery=OK      Mode=Auto
Valve   Bad-Termostat   Setpoint=5      Temp=18.5       Valve pos=0     Battery=OK      Mode=Manual
Valve   GWC-Thermostat  Setpoint=5      Temp=0PuTTY     Valve pos=0     Battery=OK      Mode=Manual
this are my Sensors in Domoticz. (extern Picture Hoster URL: https://picload.org/image/rdaicrgo/domoticz.png)
Image

I don't see my error. I can put my script here when you need it.

thank you very much for your help.
c1381ie
Posts: 5
Joined: Friday 07 October 2016 22:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany, Stuttgart
Contact:

Re: ELV Max! Heating control system

Post by c1381ie »

Hello,

i'm on the next Step. Teh first error i have found was that i test the script outside from /domotics/scripts/lua/ Now the script runs without the TCP error.
But i have another Error:

Code: Select all

2016-10-11 07:52:00.868 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_max.lua: /home/pi/domoticz/scripts/lua/script_time_max.lua:122: attempt to compare nil with number
i have 2 Wallthermostats and 10 Valves. Complete i have 5 Rooms. The Script don't run.

@mvzut
can you help me to become your Script ready to run ?!, Please.

On the Line 121 stand:

Code: Select all

      if temp < 5 then temp = temp + 25.5 end --necessary for me since first two digits seem to be unused?
what type of Sensors i need when i set the Parameter useWMT = false ?

i have create the following virtual dummy devices:

2x wall mounted thermostat (vitrual -> Temperature only)
10x valve (vitrual -> Thermostat-Setpoint)

i have on my Cube Konfig even 2 Windows Contacs and 1 Eco Switch. Do i need to set up these in Domoticz that the Script run well ?

Tanky you for Answer.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: ELV Max! Heating control system

Post by mvzut »

c1381ie wrote:@mvzut
can you help me to become your Script ready to run ?!, Please.
Hi c1381ie,
I have been very busy the past days, but next week I have more time. I'll see if i can help you then.
Martijn
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
c1381ie
Posts: 5
Joined: Friday 07 October 2016 22:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany, Stuttgart
Contact:

Re: ELV Max! Heating control system

Post by c1381ie »

mvzut wrote: Hi c1381ie,
I have been very busy the past days, but next week I have more time. I'll see if i can help you then.
Martijn
Hello Martijn,

i have found one Part that's the Problem. i use an "Eco Switch" an your Script cant konfigure this Item. The Next Part is when i habe Door Switche there is also a Problem. I have added following Line of Code:

Code: Select all

				if name ~= "EcoTaster" and name ~= "Switch-SZ" and name ~= "Switch-WZ" then
					if setpoint_Domoticz ~= setpoint then
						if age(otherdevices_lastupdate[name]) > 60 then 												--Domoticz thermostat value must be updated
							table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..setpoint})
							if Debug=="YES" then print("Domoticz setpoint updated") end
						else 																							--Max! setpoint must be updated
							MaxCmdSend(adr, room_num, "manual", setpoint_Domoticz)
							if Debug=="YES" then print("MAX! setpoint updated") end
						end
					end
				end
then i work's. but i dont understand the following Part of your Script:

Code: Select all

if temp < 5 then temp = temp + 25.5 end 																		--necessary for me since first two digits seem to be unused?
this line i must comment out. When ist not commentet out the Script runs in error. Can you explain was this part doing ?

Regards
Marcel
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

ELV Max! Heating control system

Post by mvzut »

c1381ie wrote:

Code: Select all

if temp < 5 then temp = temp + 25.5 end 																		--necessary for me since first two digits seem to be unused?
this line i must comment out. When ist not commentet out the Script runs in error. Can you explain was this part doing ?

Regards
Marcel
I added this line because it seems the Cube only sends temperature info in two digit hex numbers, which allows a maximum temperature of 25.5 degrees (16*16/10). When my temperature is e.g. 28 degrees, the script reports 2.5 degrees (28-25.5). I solved that in a very crude manner by assuming any temperature below 5 degrees is probably actually 25.5 plus that value. The original author of the core script (Westcott) later found out that the Cube does send the temperature in a four digit hex, but for me that didn't seem to work somehow. By the way, this can all be read in this thread a few pages back.

Back to your problem:
Probably, the "temp" variable doesn't always get a value, at least not for all your device types. So it sometimes gives an error when you check the value and add 25.5 if necessary. You can do two things to remove this error:
1. Remove or comment out the line altogether (like you're doing now), but you may then run into problems next summer when temperatures start to increase again.
2. Move this line to the line directly after the "temp = tonumber(s,16) / 10" line above (note that this line occurs twice, so you have to copy the line to both locations)

Let me know if this solves the issue.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
c1381ie
Posts: 5
Joined: Friday 07 October 2016 22:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany, Stuttgart
Contact:

Re: ELV Max! Heating control system

Post by c1381ie »

Hello,

i have tested. When i change the lines (your sencond pos 2.) then i become only 25.5 as Temp in my sensors.

2016-10-15 10:06:00.885 LUA: Valve TH-WZ-rechts Setpoint=8 Temp=25.5 Valve pos=0
2016-10-15 10:06:00.885 LUA: Valve TH-WZ-mitte Setpoint=8 Temp=25.5 Valve pos=0
2016-10-15 10:06:00.885 LUA: Valve TH-WZ-couch Setpoint=8 Temp=25.5 Valve pos=0
2016-10-15 10:06:00.885 LUA: Valve TH-WZ-links Setpoint=8 Temp=25.5 Valve pos=0

this is my acutal code:

Code: Select all

--./script_time_max.lua
----------------------------------------------------------------------------------------------------------
-- Script parameters 
----------------------------------------------------------------------------------------------------------
package.loadlib("core.so", "*")
local Socket = require "socket"
local Basexx = require "basexx"
local Rooms = {}
local Devices = {}
local Room_nums = {}

local MaxIP = "192.168.66.30"
local MaxPort = 62910
local useWMT = false 				--# Set to true if there is a wall mounted thermostat in every room, then this one will be used for setpoint getting/setting

Debug = "YES"                    	--# Turn debugging on ("YES") or off ("NO")
 
----------------------------------------------------------------------------------------------------------
-- Script functions
----------------------------------------------------------------------------------------------------------
function age(timestring)
    t = {}
    t.year = string.sub(timestring,1,4)
    t.month = string.sub(timestring,6,7)
    t.day = string.sub(timestring,9,10)
    t.hour = string.sub(timestring,12,13)
    t.min = string.sub(timestring,15,16)
    t.sec = string.sub(timestring,18,19)
    return os.difftime(os.time(),os.time(t))
end
function maxCmd_H(data)
	--if Debug=="YES" then print('H='..data) end
end
function maxCmd_M(data)
	i = 0
	j = 0
	
	while true do    				--find next comma
		i = string.find(data, ",", i+1)
		if not i then break end
		j = i
	end
	
	s   = data:sub(j+1)
	dec = Basexx.from_base64(s)
	num_rooms = string.byte(dec,3)
	pos=4
	
	for i=1, num_rooms do
		room_num = string.byte(dec, pos)
		name_len = string.byte(dec, pos+1)
		pos  = pos+2
		name = dec:sub(pos, pos+name_len-1)
		pos  = pos+name_len
		adr  = Basexx.to_hex(dec:sub(pos, pos+2))
		Rooms[room_num] = name
		pos = pos+3
	end
	
	num_devs = string.byte(dec, pos)
	
	for i=1, num_devs do
		dtype = string.byte(dec, pos+1)
		adr   = Basexx.to_hex(dec:sub(pos+2, pos+4))
		snum  = dec:sub(pos+5, pos+14)
		name_len = string.byte(dec, pos+15)
		pos  = pos+16
		name = dec:sub(pos, pos+name_len-1)
		pos  = pos+name_len
		room_num = string.byte(dec, pos)
		Room_nums[adr] = room_num
		Devices[adr] = name
	end
end
function maxCmd_C(data)
	--if Debug=="YES" then print('C='..data) end
end
function maxCmd_L(data)
	pos = 1
	dec = Basexx.from_base64(data)
	L_hex = Basexx.to_hex(dec)
	L_len = string.len(L_hex)

	while (pos < L_len) do
		s = L_hex:sub(pos,(pos+1))
		data_len  = tonumber(s,16) + 1
		hex  = L_hex:sub(pos,pos+(data_len*2))
		adr  = hex:sub(3,8)
		room_num = string.format("%02X", Room_nums[adr])
		room = Rooms[Room_nums[adr]]
		name = Devices[adr]
		if not name then name=adr end
		valve_info = tonumber(hex:sub(13,14),16)
		batt = bit32.extract(valve_info,7,1)
		bst  = bit32.extract(valve_info,3,1)
		mode = bit32.extract(valve_info,0,2)
		if (batt==0) then sbat="OK" else sbat="Low"	end
		if (mode==0) then
			smode="Auto"
		elseif (mode==1) then
			smode="Manual"
		elseif (mode==2) then
			smode="Holiday"
		elseif (mode==3) then 
			smode="Boost"
		end

        if (data_len == 13) then -- WallMountedThermostat (dev_type 3)
            valve_pos = -1
            s = hex:sub(17,18)
            setpoint = tonumber(s,16) / 2
            s = hex:sub(23,26)
            temp = tonumber(s,16) / 10
            dtype = "Thermostat"
        elseif (data_len == 12) then -- HeatingThermostat (dev_type 1 or 2)
            s = hex:sub(15,16)
            valve_pos = tonumber(s,16)
            s = hex:sub(17,18)
            setpoint = tonumber(s,16) / 2
            if (mode ~= 2) then
                s = hex:sub(19,22)
                temp = tonumber(s,16) / 10
            else
                temp = 0
            end
            dtype = "Valve"
        end

        --Temperaturdevices den Status aktualisieren
	    if temp ~= 0 and dtype == "Valve" then 
	        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name.." (Valve)"]..'|0|'..temp..';'..valve_pos..';0'})
        elseif  temp ~= 0 and dtype == "Thermostat" then
            table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[room]..'|0|'..temp})
        end
        
        if smode=="Manual" then
			--Update virtual devices in Domoticz and update MAX! setpoints if necessary
			if Debug=="YES" then print(dtype.."  "..name.."  Setpoint="..setpoint.."  Temp="..temp.."  Valve pos="..valve_pos) end
			if dtype == "Valve" then
				--table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name.." (Valve)"]..'|0|'..temp..';'..valve_pos..';0'})
				if not useWMT and tonumber(otherdevices_svalues[name])~=nil then 																							--Use valve to check setpoint mismatch
					setpoint_Domoticz = tonumber(otherdevices_svalues[name])
					---if name ~= "EcoTaster" and name ~= "Switch-SZ" and name ~= "Switch-WZ" then
						if setpoint_Domoticz ~= setpoint then
					        print(otherdevices_lastupdate[name])
					        print(age(otherdevices_lastupdate[name]))
							if otherdevices_lastupdate[name]~=nil and age(otherdevices_lastupdate[name]) > 120 then 		--Domoticz thermostat value must be updated
								table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..setpoint})
								if Debug=="YES" then print("Domoticz setpoint updated") end
							else        																				--Max! setpoint must be updated
								MaxCmdSend(adr, room_num, "manual", setpoint_Domoticz)
								if Debug=="YES" then print("MAX!Valve setpoint updated") end
							end
						end
					---end
				end   
			elseif dtype == "Thermostat" then
				--table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[room]..'|0|'..temp})
				setpoint_Domoticz = tonumber(otherdevices_svalues[name])
				if setpoint_Domoticz ~= setpoint then
					print(otherdevices_lastupdate[name])
					print(age(otherdevices_lastupdate[name]))
					if otherdevices_lastupdate[name]~=nil and age(otherdevices_lastupdate[name]) > 120 then 				--Domoticz thermostat value must be updated
					    table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..setpoint})
					    if Debug=="YES" then print("Domoticz setpoint updated") end
					else 																								--Max! setpoint must be updated
					    MaxCmdSend(adr, room_num, "manual", setpoint_Domoticz)
					    if Debug=="YES" then print("MAX!WMT setpoint updated") end
					end
				end
			end
		end	
		dtype=""
		name=""
		setpoint=""
		temp=""
		valve_pos=""
		pos = pos + (data_len*2)
	end
end
function MaxCmdSend(id, room, mode, setpoint)
	bits  = setpoint * 2
	smode = string.upper(mode)
	if smode == 'MANUAL' then
		bits = 64 + bits
	elseif smode == 'BOOST' then
		bits = 192 + bits
	elseif smode == 'VACATION' then
		bits = 128 + bits
	end

	hex = "000440000000"..id..room..string.format("%x",bits)
	sendStr = Basexx.to_base64(Basexx.from_hex(hex))
	i, status = tcp:send("s:"..sendStr.."\r\n")

	if not i then
		print("MAX! TCP send failed - "..status)
		return
	end
end

----------------------------------------------------------------------------------------------------------
-- CommandArray
----------------------------------------------------------------------------------------------------------
commandArray = {}
    local m = os.date('%M')
    if (m % 2 == 0) then
        --print("The 3 minute script interval reached")
    	tcp = Socket.connect(MaxIP, MaxPort)
    
    	if not tcp then
    	   print("MAX! Socket connect failed for "..MaxIP..':'..MaxPort)
    	   return
    	end
    
    	tcp:settimeout(2)
    	local time = os.date("*t")
    
    	while (time.min ~= 0) do
    		s, status, partial = tcp:receive()
    		if (status) then
    			print("MAX! TCP receive - "..status)
    			break
    		end
    		  
    		local line = (s or partial)
    		local cmd  = line:sub(1,1)
    		local data = line:sub(3)
    	   
    		if (cmd == 'H') then
    			maxCmd_H(data)
    		elseif (cmd == 'M') then
    			maxCmd_M(data)
    		elseif (cmd == 'C') then
    			maxCmd_C(data)
    		elseif (cmd == 'L') then
    			maxCmd_L(data)
    			break
    		end
    	end
    	tcp:close()
    end
return commandArray
i have also another litte Problem. i don't Understand why this is so. i Do the following:

Set Point WandTH-WZ to an Number of "10.5" all woring fine except the Valve "TH-GuestWC"
after 4 Minutes (my Script runs only all 2 Minutes) the Valce even has become the new "10.5"
but when i Cange the TH-GuestWC then only this ist Updated.

i Think that the WandTH-WZ is the Problem, bt why. When i set an new Setpoint why become the
TH-GuestWc this Value.

The WandTH-WZ is an Thermostat (WMT) and the TH-GuestWC is an Valve.

Here ist the LOG:

2016-10-15 11:34:00.624 LUA: Valve TH-Kueche Setpoint=16.5 Temp=17.7 Valve pos=0
2016-10-15 11:34:00.625 LUA: Valve TH-Flur Setpoint=8 Temp=18.8 Valve pos=0
2016-10-15 11:34:00.625 LUA: Valve TH-GuestWC Setpoint=10 Temp=15.6 Valve pos=0
2016-10-15 11:34:00.625 LUA: Thermostat WandTH-WZ Setpoint=10 Temp=18.3 Valve pos=-1
2016-10-15 11:34:00.625 LUA: Valve TH-WZ-rechts Setpoint=10 Temp=18.3 Valve pos=0
2016-10-15 11:34:00.625 LUA: Valve TH-WZ-mitte Setpoint=10 Temp=18.3 Valve pos=0
2016-10-15 11:34:00.625 LUA: Valve TH-WZ-couch Setpoint=10 Temp=0 Valve pos=0
2016-10-15 11:34:00.626 LUA: Valve TH-WZ-links Setpoint=10 Temp=0 Valve pos=0
2016-10-15 11:34:00.630 EventSystem: Script event triggered: script_time_max
2016-10-15 11:34:00.644 EventSystem: Script event triggered: script_time_variable
2016-10-15 11:35:00.220 EventSystem: Script event triggered: script_time_variable
2016-10-15 11:36:00.820 LUA: Valve TH-Kueche Setpoint=16.5 Temp=17.7 Valve pos=0
2016-10-15 11:36:00.821 LUA: Valve TH-Flur Setpoint=8 Temp=18.8 Valve pos=0
2016-10-15 11:36:00.821 LUA: Valve TH-GuestWC Setpoint=10 Temp=15.6 Valve pos=0
2016-10-15 11:36:00.821 LUA: Thermostat WandTH-WZ Setpoint=10 Temp=18.3 Valve pos=-1
2016-10-15 11:36:00.821 LUA: 2016-10-15 11:35:49
2016-10-15 11:36:00.821 LUA: 11
2016-10-15 11:36:00.822 LUA: MAX!WMT setpoint updated
2016-10-15 11:36:00.822 LUA: Valve TH-WZ-rechts Setpoint=10 Temp=18.3 Valve pos=0
2016-10-15 11:36:00.822 LUA: Valve TH-WZ-mitte Setpoint=10 Temp=18.3 Valve pos=0
2016-10-15 11:36:00.822 LUA: Valve TH-WZ-couch Setpoint=10 Temp=0 Valve pos=0
2016-10-15 11:36:00.822 LUA: Valve TH-WZ-links Setpoint=10 Temp=0 Valve pos=0
2016-10-15 11:36:00.824 EventSystem: Script event triggered: script_time_max
2016-10-15 11:36:00.831 EventSystem: Script event triggered: script_time_variable
2016-10-15 11:37:00.393 EventSystem: Script event triggered: script_time_variable
2016-10-15 11:38:01.026 LUA: Valve TH-Kueche Setpoint=16.5 Temp=17.7 Valve pos=0
2016-10-15 11:38:01.027 LUA: Valve TH-Flur Setpoint=8 Temp=18.8 Valve pos=0
2016-10-15 11:38:01.027 LUA: Valve TH-GuestWC Setpoint=10.5 Temp=15.9 Valve pos=0
2016-10-15 11:38:01.027 LUA: 2016-10-15 11:26:42
2016-10-15 11:38:01.027 LUA: 679
2016-10-15 11:38:01.027 LUA: Domoticz setpoint updated
2016-10-15 11:38:01.027 LUA: Thermostat WandTH-WZ Setpoint=10.5 Temp=18.5 Valve pos=-1
2016-10-15 11:38:01.027 LUA: Valve TH-WZ-rechts Setpoint=10.5 Temp=0 Valve pos=0
2016-10-15 11:38:01.027 LUA: Valve TH-WZ-mitte Setpoint=10.5 Temp=18.3 Valve pos=0
2016-10-15 11:38:01.028 LUA: Valve TH-WZ-couch Setpoint=10.5 Temp=18.3 Valve pos=0
2016-10-15 11:38:01.028 LUA: Valve TH-WZ-links Setpoint=10.5 Temp=18.3 Valve pos=0
2016-10-15 11:38:10.458 EventSystem: Script event triggered: script_time_variable
2016-10-15 11:38:10.500 EventSystem: Script event triggered: script_time_max
2016-10-15 11:39:00.534 EventSystem: Script event triggered: script_time_variable

Do you have an Idea ?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest