ELV Max! Heating control system

For heating/cooling related questions in Domoticz

Moderator: leecollings

hasan
Posts: 34
Joined: Saturday 31 October 2015 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ELV Max! Heating control system

Post by hasan »

Hi guys,

thanks for nice topic. I have 5 valves EQ-3 with Cube and RPi with Domoticz and I would like to use Domoticz to control valves. I read all topic but I'm little bit lost. I tried to install LUA5.2 into RPi but without success. Is there somebody who can send me some "How to install to RPi"? Thanks.
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 »

@Hasan :D
Hi, some raspberry distros already have lua installed so 1st try

Code: Select all

pi@xxxxxx:~ $ lua
and you will either get something like this

Code: Select all

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
or this

Code: Select all

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
or

Code: Select all

The program 'lua' can be found in the following packages:
 * lua5.2
 * lua5.1
 * lua50
Try: sudo apt install <selected package>
if it isn't installed at all

If no lua

Code: Select all

sudo apt-get update
sudo apt-get lua5.2
should do the trick

Once you have it "in" your RasPi you may have problems with where it was placed or conflict with 5.1 or 5.0. I seem to remember I had to completely flush my system of everything lua related and reinstall... or maybe that was another project :?

But try this 1st and see how you go from there.

Sean :D
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
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 :D
1st many thanks for the hard work so far!

I had problems getting this to run so I wandered off and played with another project for a while (The wonderful Amazon Doorstop :evil: ) and then came back to it this week. At 1st I only had partial success as I could only update one room with the script yet the "Westcott test script" ;) shows all rooms stats and valves. Then it hit me, 3 rooms were set to auto in the max app. set them to manual and BOOM all showing! :D

So temps all fine, set-points fine but my valve percentages are not correct. How should the be named? e.g. my kitchen is set up as
Room = Kitchen
Stat = Kitchen-Stat
TRV = Kitchen-Rad

My virtual devices are
Temp = Kitchen
Stat = Kitchen-Stat
% = Kitchen-Rad

The 1st 2 work but not the 3rd. Others are similar V-Room, V-Room-Stat, V-Room-Rad etc. All with the same issue.

I hope this sense (and is an easy solution ;) )

Many thanks
Sean :D
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
jmbjmbjmb
Posts: 48
Joined: Monday 25 January 2016 10:41
Target OS: -
Domoticz version:
Contact:

Re: ELV Max! Heating control system

Post by jmbjmbjmb »

Hi,

I am getting the following error message with the lua script (named script_time.lua) that was posted in this forum (not that I have uncommented all prints to get the messages shown, hoping that this helps figuring what the problem is).

Code: Select all

lua scripts/lua/script_time_max.lua
H=JEQ0543318,03f77a,0113,00000000,7e71f81d,01,32,100a19,1124,03,0000
C=03f77a,7QP3egATAf9KRVEwNTQzMzE4AQsABEAAAAAAAAAAAP///////////////////////////wsABEAAAAAAAAAAQf///////////////////////////2h0dHA6Ly93d3cubWF4LXBvcnRhbC5lbHYuZGU6ODAvY3ViZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENFVAAACgADAAAOEENFU1QAAwACAAAcIA==
C=0b0442,0gsEQgICEABLRVEwNTcxNzk4JiE9CQcYAzAM/wBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIA==
C=08f6d7,0gj21wIDEP9LRVEwNTcwOTAzJiE9CQcYAzAM/wBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERIUQhFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIA==
C=08f616,0gj2FgIFEP9LRVEwNTY5OTA3JiE9CQcYAzAM/wBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIA==
C=08f6d4,0gj21AIBEABLRVEwNTcwOTA2JiE9CQcYAzAM/wBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIA==
C=09b650,zgm2UAMBEP9LRVEwODYzNzAwJiE9CURITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgBxgw
C=08f541,0gj1QQIBEP9LRVEwNTY5NjkzJiE9CQcYAzAM/wBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERITQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhNCUUgRSBFIEUgRSBFIEUgRSBFIEUgRSBESE0JRSBFIEUgRSBFIEUgRSBFIEUgRSBFIA==
C=08f556,0gj1VgIEEABLRVEwNTY5NzE0KyE9CQcYAzAM/wBESFUIRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERIVQhFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhUbETMVRRFIEUgRSBFIEUgRSBFIEUgRSBESFRsRMxVFEUgRSBFIEUgRSBFIEUgRSBFIERIVGxEzFUURSBFIEUgRSBFIEUgRSBFIEUgREhUbETMVRRFIEUgRSBFIEUgRSBFIEUgRSBESFRsRMxVFEUgRSBFIEUgRSBFIEUgRSBFIA==
lua: scripts/lua/script_time_max.lua:90: attempt to index global 'bit32' (a nil value)
stack traceback:
	scripts/lua/script_time_max.lua:90: in function 'maxCmd_L'
	scripts/lua/script_time_max.lua:202: in main chunk
	[C]: ?

Thanks
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 »

blackdog65 wrote:@mvzut :D
1st many thanks for the hard work so far!

I had problems getting this to run so I wandered off and played with another project for a while (The wonderful Amazon Doorstop :evil: ) and then came back to it this week. At 1st I only had partial success as I could only update one room with the script yet the "Westcott test script" ;) shows all rooms stats and valves. Then it hit me, 3 rooms were set to auto in the max app. set them to manual and BOOM all showing! :D

So temps all fine, set-points fine but my valve percentages are not correct. How should the be named? e.g. my kitchen is set up as
Room = Kitchen
Stat = Kitchen-Stat
TRV = Kitchen-Rad

My virtual devices are
Temp = Kitchen
Stat = Kitchen-Stat
% = Kitchen-Rad

The 1st 2 work but not the 3rd. Others are similar V-Room, V-Room-Stat, V-Room-Rad etc. All with the same issue.

I hope this sense (and is an easy solution ;) )

Many thanks
Sean :D
Your naming scheme seems correct, but I took out the updates of the valve positions in the alternative version of the script (the one that has a "useWMT" setting to work with systems without a wall mounted thermostat in every room). I figured most people would probably not need that funtionality. You should be able to put it back in by adding this line

Code: Select all

        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..valve_pos})	
directly above the line that reads "elseif dtype == "Thermostat" then".

Hope this helps.
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 »

Many thanks!
I'll try later when I get home.

My current script is based on the max buddy set up and activates the heating if 2 or more valves are open more than 50%. This works well for me so I plan to cannibalise it to work with your script (if my ability allows).

Thanks again

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
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 »

blackdog65 wrote:My current script is based on the max buddy set up and activates the heating if 2 or more valves are open more than 50%. This works well for me so I plan to cannibalise it to work with your script (if my ability allows).
and it doesn't :oops:
I've been going round in circles with this and getting further confused. :?

I have 2 scripts
Script "A" based on the script written by l0gic viewtopic.php?f=34&t=841&start=60#p38160

Code: Select all

-- script_time_Heating Valves.lua
-- Version 1.8 26/03/15
-- Script to read the % open of radiator valves
-- All radiator valves are labelled "RV <room name>"
-- search is made for  "RV " (Note space) to indicate a radiator valve
-- If found it will be interrogated for % open value

-- Thermostat are named "Stat <room name>" so a search is made for "Sta" to indicate thermostats
-- If found it will be interrogated for temperature value

-- If demand is greater than BoilerOnPercent value then fire up boiler
-- If demand is less than BoilerOnPercent minus HysterysisOffPercent then switch off boiler

-- Preset Values
BoilerOnPercent = 50               -- percentage valve open at which the boiler will be turned on
HysterysisOffPercent = 20             -- percentage below BoilerOnPercent to switch off the boiler
MinValves = 2                      -- Number of Valves that need to be open before boiler is turned on
ValvePercentOveride = 99            -- Percentage value of valve open required to override MinValves value (one room is very cold)
HolidayMinTemp = 10                -- Minimum room temperature before boiler is turned on during holiday period
HolidayHysterysisTemp = 2             -- Value to increase house temperature by while in holiday mode if boiler is turned on due to low temperatures
MissingDevicesTime = 3600            -- Value in seconds to allow before reporting a device has not been updated
email = "[email protected]"             -- email address for warnings

-- Script Variables
PercentMax = 0
TempMin = 100
ValveCount = 0
MissingDeviceCount = 0
SendAnEmail = false

-- Set printing to log options (true / false)
-- printData = false
printData = false
printDebug = false
-- printDebug = true

-- Get current date & time
t1 = os.time()
local currentDate = os.date("*t");  -- sets up currentDate.[table]
-- (currentDate.year [full], .month [1-12], .day [1-31], .hour [0-23], .min [0-59], .sec [0-59], .wday [0-6 {Sun-Sat}])
sCurrentTime = currentDate.year .. "-" .. currentDate.month .. "-" .. currentDate.day .. " " .. currentDate.hour .. ":" .. currentDate.min .. ":" .. currentDate.sec

function TimeElapsed(s) -- expects date & time in the form of 2010-01-23 12:34:56
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference -- in seconds
end



commandArray = {}
 
       -- print blank line in log
       if printData == true then
         print (" ")
         print (" *** Heating Script Output ***")
         print (" ")
       end
      
       -- Get Data from Radiator Valves
      for i, v in pairs(otherdevices) do -- Get all devices in the database
         v = i:sub(1,3) -- Grab the first three characters of the device name
         
            if (v == 'RV ') then -- are the first three characters "RV "? If so we have a Radiator Valve
            
                RoomName = i:sub(4) -- Get the rest of the name, which will be the room name
                sSetTempValue, sValvePercentOpen = otherdevices_svalues[i]:match("([^;]+);([^;]+)") -- get the valve set Point and the  valve % open (Temp, Humidity)
                sLastUpdateTime = otherdevices_lastupdate[i]
                sElapsedTime = TimeElapsed(otherdevices_lastupdate[i])
                message = RoomName .. " valve is open " .. sValvePercentOpen .. " percent " .. " Setpoint temperature is " .. sSetTempValue .. "C"  -- for debug
                message2 = RoomName .. " last seen " .. sLastUpdateTime  ..  " Elapsed time " .. sElapsedTime
                if printData == true then
                  print (message)
                  print (message2)
                end
               
                -- check for missing devices
                if sElapsedTime > MissingDevicesTime then
                SendAnEmail = false
                MissingDeviceCount = MissingDeviceCount + 1
                end
               
                -- get the % value of the most open Radiator Valve
                if tonumber(sValvePercentOpen) > PercentMax then
                  PercentMax = tonumber(sValvePercentOpen)
                end
               
                -- Count the number of valves that are open more than BoilerOnPercent
                if tonumber(sValvePercentOpen) >= BoilerOnPercent then
                  ValveCount = ValveCount + 1
                end   
               

            end
      end

       if printData == true then
         print (" ")
       end      
      
      -- Get Data from Thermostats
      for i, v in pairs(otherdevices) do -- Get all devices in the database
         v = i:sub(1,5) -- Grab the first three characters of the device name
            
            if (v == 'Stat ') then -- are the first five characters "Stat "? If so we have an EQ-3 Thermostat
            
                RoomName = i:sub(6) -- Get the rest of the name, which will be the room name
                  sTemp = otherdevices_svalues[i] -- get the temperature   
                sLastUpdateTime = otherdevices_lastupdate[i]
                sElapsedTime = TimeElapsed(otherdevices_lastupdate[i])               
                message = RoomName.." temperature is " .. sTemp .. " Centigrade "  -- for debug
                message2 = RoomName .. " last seen " .. sLastUpdateTime  ..  " Elapsed time " .. sElapsedTime
                if printData == true then
                  print(message)
                  print(message2)
                end
               
                -- get the lowest temperature of the thermostats
                if tonumber(sTemp) < TempMin then
                  TempMin = tonumber(sTemp)
                end
               
                -- check for missing devices
                if sElapsedTime > MissingDevicesTime then
                SendAnEmail = true                      -- change this to false if you do not require emails to be sent
                MissingDeviceCount = MissingDeviceCount + 1
                end
               
            end   

      end
      
        if printData == true then
         print (" ")
         print ("Number of valves open more than " .. BoilerOnPercent .. "% is " .. ValveCount .." valves")
         print("Highest valve open value is " .. PercentMax .." percent ")
         print("Lowest thermostat reading is " .. TempMin .." Centigrade ")
         print (" ")
        end
      
    if printData == true then
      if (otherdevices['CH_Switch'] == 'On')then
         print ("Current state - Boiler is ON ")
      else
         print ("Current state - Boiler is OFF ")
      end   

   end         

   -- Check the elapsed time and email if overdue
      if (SendAnEmail == true) then
         print (" ")
         print("Heating Script: missing device email sent to " .. (email) );
         notifyString = os.date("Domoticz Alert # The current time is %X on %A Lost contact with " .. MissingDeviceCount .. " Heating script devices, check if Max!Buddy is running.  #") .. (email)
         commandArray['SendEmail'] = notifyString
       end
      
      
      
      
      
      -- Perform logic
      
      if printDebug == true then
      -- view the settings to understand logic performance
         print ("PercentMax (" .. PercentMax .. "%) " .. "Boiler On value (" .. BoilerOnPercent .. "%) " .. "Boiler Off value (" .. (BoilerOnPercent - HysterysisOffPercent) .. ")% ")
         print ("Number of valves open more than " .. BoilerOnPercent .. "% is " .. ValveCount .." valves. Minimum valves setting " .. MinValves )
         print ("Maximum open value " .. PercentMax .. "%" .. " Override value " .. ValvePercentOveride .."%")
         
      print (" ")
       end   
      if (otherdevices['Holiday'] == 'Off')then -- Not on holiday
      
	if (otherdevices['Heating'] == 'On')then -- It's time to heat the house

         	if (otherdevices['CH_Switch'] == 'Off') then --If a minimum of 'MinValves' valves are on by more that pre-set value BoilerOnPercent
         
                  	if printDebug == true then
                     print ("Test passed - Boiler is OFF ")
                  	end   
                  
            	if (PercentMax > BoilerOnPercent) then

                  	if printDebug == true then
                     print ("Test passed - Radiators are open beyond the threshold ")
                  	end               
            
               	if (ValveCount >= MinValves) or (BoilerOnPercent >= ValvePercentOveride) then

                  	if printDebug == true then
                     print ("Test passed - Either multiple valves are open or override count is reached ")
                  	end   
               
                  commandArray['CH_Switch']='On' -- turn on boiler
                     	if printData == true then
                        print ("Command sent - Turn ON Boiler ")
                     	end
		end	   
               end
            end
         end
         
         if (PercentMax < (BoilerOnPercent - HysterysisOffPercent) or (ValveCount < MinValves)) and (otherdevices['CH_Switch'] == 'On')  then -- If the number of valves open more than BoilerOnPercent minus HysterysisOffPercent
            commandArray['CH_Switch']='Off' -- turn off boiler
                  if printData == true then
                     print ("Command sent - Turn OFF Boiler ")
                  end   
         end
         
      else -- on holiday
      
         if (TempMin <= HolidayMinTemp) and (otherdevices['CH_Switch'] == 'Off') then  -- house is very cold
            commandArray['CH_Switch']='On' -- turn on boiler
         end
         
         if (TempMin >= (HolidayMinTemp + HolidayHysterysisTemp)) and (otherdevices['CH_Switch'] == 'On') then  -- house is warm enough
            commandArray['CH_Switch']='Off' -- turn on boiler
         end
         
      end
    if printData == true then
      print (" ")
    end
      
 
return commandArray
This reads the cube, creates devices and controls my heating based on temperature, valve open% and holiday settings. All very clever but relies on maxbuddy and cannot change setpoints.

And the mvzut script viewtopic.php?f=34&t=841&start=220#p88647

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.1.131"
local MaxPort = 62910
local useWMT = true             --# 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  
        table.insert(commandArray, { ['UpdateDevice'] = otherdevices_idx[name]..'|0|'..valve_pos})    
         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
which reads direct without maxbuddy and can change setpoints but doesn't have the heating control.

I've been pulling my hair out trying to see a way to combine the two to create the perfect heating control script. Can any kind soul offer some pointers.

My 1st thought was to strip the "Find devices" part from l0gic's script and get the mvzut script to fill in the missing information... but as a non-coder I over-heated my brain and I'm lucky to still have functioning heating at all! :roll:

Please help me! :D

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
Skippiemanz
Posts: 230
Joined: Sunday 14 July 2013 20:21
Target OS: Linux
Domoticz version: 4.10233
Location: Alkmaar, The Netherlands
Contact:

Re: ELV Max! Heating control system

Post by Skippiemanz »

Reading through the 2 scripts a combination would be indeed haven on earth... Im unfortunetly no coder also.. Fingers crossed
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 »

blackdog65 wrote:
blackdog65 wrote:My current script is based on the max buddy set up and activates the heating if 2 or more valves are open more than 50%. This works well for me so I plan to cannibalise it to work with your script (if my ability allows).
and it doesn't :oops:
I've been going round in circles with this and getting further confused. :?
Do you mean that the % devices for the valves still don't update?
Can you maybe put a "print(valve_pos)" line below "valve_pos = tonumber(s,16)", does it print the valve positions in the log?
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 wrote:Do you mean that the % devices for the valves still don't update?
Can you maybe put a "print(valve_pos)" line below "valve_pos = tonumber(s,16)", does it print the valve positions in the log?
No, my friend. Your script works fine. I have setpoints, temps and %, all fine. My problem is using the % to control my system as in the 1st (l0gic) script.

I really do struggle with code :roll:
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
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 »

blackdog65 wrote:
mvzut wrote:Do you mean that the % devices for the valves still don't update?
Can you maybe put a "print(valve_pos)" line below "valve_pos = tonumber(s,16)", does it print the valve positions in the log?
No, my friend. Your script works fine. I have setpoints, temps and %, all fine. My problem is using the % to control my system as in the 1st (l0gic) script.

I really do struggle with code :roll:
The script written by l0gic requires your device names to start with "RV " for radiator valves, and "Stat " for thermostats. If I understand your previous post correct, you have named them:
Stat = Kitchen-Stat
% = Kitchen-Rad

Moreover, l0gic's script assumes that the setpoint temperatures & valve positions are stored together in temp/humidity devices. I have separated them: the setpoint temperature is stored in a thermostat device, and the valve position is a separate % device. I have modified the script so that it should work again for your situation:

Code: Select all

-- script_time_Heating Valves.lua
-- Version 1.9 27/10/16
-- Script to read the % open of radiator valves
-- All radiator valves are labelled "<room name>-Rad"
-- search is made for "-Rad" to indicate a radiator valve
-- If found it will be interrogated for % open value

-- Thermostat are named <room name>-Stat so a search is made for "-Stat" to indicate thermostats
-- If found it will be interrogated for temperature value

-- If demand is greater than BoilerOnPercent value then fire up boiler
-- If demand is less than BoilerOnPercent minus HysterysisOffPercent then switch off boiler

-- Preset Values
BoilerOnPercent = 50               -- percentage valve open at which the boiler will be turned on
HysterysisOffPercent = 20             -- percentage below BoilerOnPercent to switch off the boiler
MinValves = 2                      -- Number of Valves that need to be open before boiler is turned on
ValvePercentOveride = 99            -- Percentage value of valve open required to override MinValves value (one room is very cold)
HolidayMinTemp = 10                -- Minimum room temperature before boiler is turned on during holiday period
HolidayHysterysisTemp = 2             -- Value to increase house temperature by while in holiday mode if boiler is turned on due to low temperatures
MissingDevicesTime = 3600            -- Value in seconds to allow before reporting a device has not been updated
email = "[email protected]"             -- email address for warnings

-- Script Variables
PercentMax = 0
TempMin = 100
ValveCount = 0
MissingDeviceCount = 0
SendAnEmail = false

-- Set printing to log options (true / false)
-- printData = false
printData = false
printDebug = false
-- printDebug = true

-- Get current date & time
t1 = os.time()
local currentDate = os.date("*t");  -- sets up currentDate.[table]
-- (currentDate.year [full], .month [1-12], .day [1-31], .hour [0-23], .min [0-59], .sec [0-59], .wday [0-6 {Sun-Sat}])
sCurrentTime = currentDate.year .. "-" .. currentDate.month .. "-" .. currentDate.day .. " " .. currentDate.hour .. ":" .. currentDate.min .. ":" .. currentDate.sec

function TimeElapsed(s) -- expects date & time in the form of 2010-01-23 12:34:56
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference -- in seconds
end



commandArray = {}
 
       -- print blank line in log
       if printData == true then
         print (" ")
         print (" *** Heating Script Output ***")
         print (" ")
       end
      
       -- Get Data from Radiator Valves
      for i, v in pairs(otherdevices) do -- Get all devices in the database
         v = i:sub(-4,-1) -- Grab the last four characters of the device name
         
            if (v == '-Rad ') then -- are the last four characters "-Rad"? If so we have a Radiator Valve
            
                RoomName = i:sub(1,-5) -- Get the rest of the name, which will be the room name
                sSetTempValue = otherdevices_svalues[RoomName..'-Stat']
                sValvePercentOpen = otherdevices_svalues[i]
                sLastUpdateTime = otherdevices_lastupdate[i]
                sElapsedTime = TimeElapsed(otherdevices_lastupdate[i])
                message = RoomName .. " valve is open " .. sValvePercentOpen .. " percent " .. " Setpoint temperature is " .. sSetTempValue .. "C"  -- for debug
                message2 = RoomName .. " last seen " .. sLastUpdateTime  ..  " Elapsed time " .. sElapsedTime
                if printData == true then
                  print (message)
                  print (message2)
                end
               
                -- check for missing devices
                if sElapsedTime > MissingDevicesTime then
                SendAnEmail = false
                MissingDeviceCount = MissingDeviceCount + 1
                end
               
                -- get the % value of the most open Radiator Valve
                if tonumber(sValvePercentOpen) > PercentMax then
                  PercentMax = tonumber(sValvePercentOpen)
                end
               
                -- Count the number of valves that are open more than BoilerOnPercent
                if tonumber(sValvePercentOpen) >= BoilerOnPercent then
                  ValveCount = ValveCount + 1
                end   
               

            end
      end

       if printData == true then
         print (" ")
       end      
      
      -- Get Data from Thermostats
      for i, v in pairs(otherdevices) do -- Get all devices in the database
         v = i:sub(-5,-1) -- Grab the last five characters of the device name
            
            if (v == '-Stat ') then -- are the last five characters "-Stat "? If so we have an EQ-3 Thermostat
            
                RoomName = i:sub(1,-6) -- Get the rest of the name, which will be the room name
                  sTemp = otherdevices_svalues[i] -- get the temperature   
                sLastUpdateTime = otherdevices_lastupdate[i]
                sElapsedTime = TimeElapsed(otherdevices_lastupdate[i])               
                message = RoomName.." temperature is " .. sTemp .. " Centigrade "  -- for debug
                message2 = RoomName .. " last seen " .. sLastUpdateTime  ..  " Elapsed time " .. sElapsedTime
                if printData == true then
                  print(message)
                  print(message2)
                end
               
                -- get the lowest temperature of the thermostats
                if tonumber(sTemp) < TempMin then
                  TempMin = tonumber(sTemp)
                end
               
                -- check for missing devices
                if sElapsedTime > MissingDevicesTime then
                SendAnEmail = true                      -- change this to false if you do not require emails to be sent
                MissingDeviceCount = MissingDeviceCount + 1
                end
               
            end   

      end
      
        if printData == true then
         print (" ")
         print ("Number of valves open more than " .. BoilerOnPercent .. "% is " .. ValveCount .." valves")
         print("Highest valve open value is " .. PercentMax .." percent ")
         print("Lowest thermostat reading is " .. TempMin .." Centigrade ")
         print (" ")
        end
      
    if printData == true then
      if (otherdevices['CH_Switch'] == 'On')then
         print ("Current state - Boiler is ON ")
      else
         print ("Current state - Boiler is OFF ")
      end   

   end         

   -- Check the elapsed time and email if overdue
      if (SendAnEmail == true) then
         print (" ")
         print("Heating Script: missing device email sent to " .. (email) );
         notifyString = os.date("Domoticz Alert # The current time is %X on %A Lost contact with " .. MissingDeviceCount .. " Heating script devices, check if Max!Buddy is running.  #") .. (email)
         commandArray['SendEmail'] = notifyString
       end
      
      
      
      
      
      -- Perform logic
      
      if printDebug == true then
      -- view the settings to understand logic performance
         print ("PercentMax (" .. PercentMax .. "%) " .. "Boiler On value (" .. BoilerOnPercent .. "%) " .. "Boiler Off value (" .. (BoilerOnPercent - HysterysisOffPercent) .. ")% ")
         print ("Number of valves open more than " .. BoilerOnPercent .. "% is " .. ValveCount .." valves. Minimum valves setting " .. MinValves )
         print ("Maximum open value " .. PercentMax .. "%" .. " Override value " .. ValvePercentOveride .."%")
         
      print (" ")
       end   
      if (otherdevices['Holiday'] == 'Off')then -- Not on holiday
      
   if (otherdevices['Heating'] == 'On')then -- It's time to heat the house

            if (otherdevices['CH_Switch'] == 'Off') then --If a minimum of 'MinValves' valves are on by more that pre-set value BoilerOnPercent
         
                     if printDebug == true then
                     print ("Test passed - Boiler is OFF ")
                     end   
                  
               if (PercentMax > BoilerOnPercent) then

                     if printDebug == true then
                     print ("Test passed - Radiators are open beyond the threshold ")
                     end               
            
                  if (ValveCount >= MinValves) or (BoilerOnPercent >= ValvePercentOveride) then

                     if printDebug == true then
                     print ("Test passed - Either multiple valves are open or override count is reached ")
                     end   
               
                  commandArray['CH_Switch']='On' -- turn on boiler
                        if printData == true then
                        print ("Command sent - Turn ON Boiler ")
                        end
      end      
               end
            end
         end
         
         if (PercentMax < (BoilerOnPercent - HysterysisOffPercent) or (ValveCount < MinValves)) and (otherdevices['CH_Switch'] == 'On')  then -- If the number of valves open more than BoilerOnPercent minus HysterysisOffPercent
            commandArray['CH_Switch']='Off' -- turn off boiler
                  if printData == true then
                     print ("Command sent - Turn OFF Boiler ")
                  end   
         end
         
      else -- on holiday
      
         if (TempMin <= HolidayMinTemp) and (otherdevices['CH_Switch'] == 'Off') then  -- house is very cold
            commandArray['CH_Switch']='On' -- turn on boiler
         end
         
         if (TempMin >= (HolidayMinTemp + HolidayHysterysisTemp)) and (otherdevices['CH_Switch'] == 'On') then  -- house is warm enough
            commandArray['CH_Switch']='Off' -- turn on boiler
         end
         
      end
    if printData == true then
      print (" ")
    end
      
 
return commandArray
Please note however that I haven't tested it myself... Let me know your results!

UPDATE 27-10-2016 23:17
I have taken out a few errors in the adapted script after publishing it. Please use the latest version.
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 »

WOW! @ mvzut!!! :shock: :o :shock:
Many thanks for such a fast AND comprehensive reply. I just saw this before going to bed so I shall try it tomorrow morning and get back to you.

Am I right in assuming that this eliminates the need to run maxbuddy? Also, I think I need to run your original script + this script together?

Fingers crossed and huge thanks :D :D :D

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
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 »

blackdog65 wrote:WOW! @ mvzut!!! :shock: :o :shock:
Many thanks for such a fast AND comprehensive reply. I just saw this before going to bed so I shall try it tomorrow morning and get back to you.

Am I right in assuming that this eliminates the need to run maxbuddy? Also, I think I need to run your original script + this script together?

Fingers crossed and huge thanks :D :D :D

Sean
You're welcome Image.
Yes, this eliminates the need for maxbuddy. You should indeed run both scripts as time scripts, I also have it set up that way.

Let me know if it works or not, including any error messages you may get.
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 »

Hi mvzut!

I have both scripts running now.
The max script is reporting

Code: Select all

2016-10-28 11:50:01.930 LUA: Thermostat SittingRoom-Stat Setpoint=20 Temp=19.6 Valve pos=-1
2016-10-28 11:50:01.931 LUA: Thermostat V-Bed-Stat Setpoint=17.5 Temp=20.4 Valve pos=-1
2016-10-28 11:50:01.931 LUA: Valve SittingRoom-Rad Setpoint=20 Temp=0 Valve pos=100
2016-10-28 11:50:01.931 LUA: Valve Z-Bed-Rad Setpoint=17.5 Temp=0 Valve pos=0
2016-10-28 11:50:01.932 Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_time_max2.lua: /home/linaro/domoticz/scripts/lua/script_time_max.lua:131: attempt to concatenate field '?' (a nil value)
2016-10-28 11:50:01.938 EventSystem: Script event triggered: /home/linaro/domoticz/scripts/lua/script_time_max.lua
so it only appears to get part way through the interrogation process.

And the heating script outputs

Code: Select all

2016-10-28 11:50:49.279 LUA: *** Heating Script Output ***
2016-10-28 11:50:49.279 LUA:
2016-10-28 11:50:49.280 LUA:
2016-10-28 11:50:49.281 LUA:
2016-10-28 11:50:49.281 LUA: Number of valves open more than 50% is 0 valves
2016-10-28 11:50:49.281 LUA: Highest valve open value is 0 percent
2016-10-28 11:50:49.281 LUA: Lowest thermostat reading is 100 Centigrade
2016-10-28 11:50:49.281 LUA:
2016-10-28 11:50:49.281 LUA: Current state - Boiler is OFF
2016-10-28 11:50:49.281 LUA: PercentMax (0%) Boiler On value (50%) Boiler Off value (30)%
2016-10-28 11:50:49.281 LUA: Number of valves open more than 50% is 0 valves. Minimum valves setting 2
2016-10-28 11:50:49.281 LUA: Maximum open value 0% Override value 99%
2016-10-28 11:50:49.281 LUA:
2016-10-28 11:50:49.281 LUA: Test passed - Boiler is OFF
2016-10-28 11:50:49.282 LUA: 
So no heat even though 2 valves are actually open 100%

I hope this makes sense to you

Thanks again

Sean

PS. I owe you a BIG beer :D
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
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 »

Ok,
now I have a full read

Code: Select all

 
2016-10-28 12:24:00.878 LUA: Thermostat SittingRoom-Stat Setpoint=20 Temp=19.6 Valve pos=-1
2016-10-28 12:24:00.878 LUA: Thermostat V-Bed-Stat Setpoint=17.5 Temp=20.4 Valve pos=-1
2016-10-28 12:24:00.878 LUA: Valve SittingRoom-Rad Setpoint=20 Temp=0 Valve pos=100
2016-10-28 12:24:00.879 LUA: Valve Z-Bed-Rad Setpoint=17.5 Temp=0 Valve pos=0
2016-10-28 12:24:00.879 LUA: Valve V-Bed-Rad Setpoint=17.5 Temp=0 Valve pos=35
2016-10-28 12:24:00.879 LUA: Valve Kitchen-Rad Setpoint=20 Temp=0 Valve pos=100
2016-10-28 12:24:00.879 LUA: Thermostat Kitchen-Stat Setpoint=20 Temp=19.1 Valve pos=-1
2016-10-28 12:24:00.880 LUA: Thermostat Z-Bed-Stat Setpoint=17.5 Temp=18.5 Valve pos=-1
2016-10-28 12:24:00.892 EventSystem: Script event triggered: /home/linaro/domoticz/scripts/lua/script_time_max.lua
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.906 LUA: *** Heating Script Output ***
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Number of valves open more than 50% is 0 valves
2016-10-28 12:24:00.907 LUA: Highest valve open value is 0 percent
2016-10-28 12:24:00.907 LUA: Lowest thermostat reading is 100 Centigrade
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Current state - Boiler is OFF
2016-10-28 12:24:00.907 LUA: PercentMax (0%) Boiler On value (50%) Boiler Off value (30)%
2016-10-28 12:24:00.907 LUA: Number of valves open more than 50% is 0 valves. Minimum valves setting 2
2016-10-28 12:24:00.907 LUA: Maximum open value 0% Override value 99%
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Test passed - Boiler is OFF 
the max script is seeing 2 valves open but the heating valve script isn't
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
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 »

blackdog65 wrote:Ok,
now I have a full read

Code: Select all

 
2016-10-28 12:24:00.878 LUA: Thermostat SittingRoom-Stat Setpoint=20 Temp=19.6 Valve pos=-1
2016-10-28 12:24:00.878 LUA: Thermostat V-Bed-Stat Setpoint=17.5 Temp=20.4 Valve pos=-1
2016-10-28 12:24:00.878 LUA: Valve SittingRoom-Rad Setpoint=20 Temp=0 Valve pos=100
2016-10-28 12:24:00.879 LUA: Valve Z-Bed-Rad Setpoint=17.5 Temp=0 Valve pos=0
2016-10-28 12:24:00.879 LUA: Valve V-Bed-Rad Setpoint=17.5 Temp=0 Valve pos=35
2016-10-28 12:24:00.879 LUA: Valve Kitchen-Rad Setpoint=20 Temp=0 Valve pos=100
2016-10-28 12:24:00.879 LUA: Thermostat Kitchen-Stat Setpoint=20 Temp=19.1 Valve pos=-1
2016-10-28 12:24:00.880 LUA: Thermostat Z-Bed-Stat Setpoint=17.5 Temp=18.5 Valve pos=-1
2016-10-28 12:24:00.892 EventSystem: Script event triggered: /home/linaro/domoticz/scripts/lua/script_time_max.lua
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.906 LUA: *** Heating Script Output ***
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.906 LUA:
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Number of valves open more than 50% is 0 valves
2016-10-28 12:24:00.907 LUA: Highest valve open value is 0 percent
2016-10-28 12:24:00.907 LUA: Lowest thermostat reading is 100 Centigrade
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Current state - Boiler is OFF
2016-10-28 12:24:00.907 LUA: PercentMax (0%) Boiler On value (50%) Boiler Off value (30)%
2016-10-28 12:24:00.907 LUA: Number of valves open more than 50% is 0 valves. Minimum valves setting 2
2016-10-28 12:24:00.907 LUA: Maximum open value 0% Override value 99%
2016-10-28 12:24:00.907 LUA:
2016-10-28 12:24:00.907 LUA: Test passed - Boiler is OFF 
the max script is seeing 2 valves open but the heating valve script isn't
Do you know why the MAX script gave an error at first, and then suddenly worked later?

I'll see if I can find why the heating valve script doesn't show the correct info, but that will probably be tonight (while enjoying a (your?) beer :))
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 wrote: Do you know why the MAX script gave an error at first, and then suddenly worked later?

I'll see if I can find why the heating valve script doesn't show the correct info, but that will probably be tonight (while enjoying a (your?) beer :))
It seems to be a "feature" :lol: as it will do it for 3 or 4 checks then run perfect for 24hrs. Would it happen if a device wasn't picked up? I have some very thick walls (800mm+) and massive chimney breasts that can be a nuisance at times, causing the EQ3 devices to skip a check occasionally.

However, many thanks so far! I'm sure there are more people watching this and hoping. Full heating automation is something of a "Holy Grail" for me as it will make the wife appreciate Domoticz more... and loosen the purse strings ;)

Sean :D
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
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 »

blackdog65 wrote:
mvzut wrote: Do you know why the MAX script gave an error at first, and then suddenly worked later?

I'll see if I can find why the heating valve script doesn't show the correct info, but that will probably be tonight (while enjoying a (your?) beer :))
It seems to be a "feature" :lol: as it will do it for 3 or 4 checks then run perfect for 24hrs. Would it happen if a device wasn't picked up? I have some very thick walls (800mm+) and massive chimney breasts that can be a nuisance at times, causing the EQ3 devices to skip a check occasionally.

However, many thanks so far! I'm sure there are more people watching this and hoping. Full heating automation is something of a "Holy Grail" for me as it will make the wife appreciate Domoticz more... and loosen the purse strings ;)

Sean :D
Wow, do you live in a castle?

As you probably know, Domoticz doesn't directly communicate with the valves/thermostats but with the Cube, which in turn communicates with the valves. As far as I know, the Cube will always return a value, even if it briefly lost communication with the devices. It will then simply return the last known value. So I don't expect that this is the cause for the missed updates, although I could of course be wrong.

My wife also very much likes the fact that she now can turn on the heat in her study, even if the rest of the house is unheated. She didn't buy me a beer for it (yet), maybe I should show her your post Image.
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 »

Wow, do you live in a castle?
not quite. It's a very big 400 year old farm house... they knew how to build them back then! :D
My wife also very much likes the fact that she now can turn on the heat in her study
My wife has her desk in "The Library" which makes it sound more like the "Cluedo" house than a castle :lol:
But seriously, heating is a very wife friendly thing. Most of what I do looks like either magic or a waste of time to my wife... unless it keeps her warm or saves money... THEN she's interested :roll:
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
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 »

blackdog65 wrote: the max script is seeing 2 valves open but the heating valve script isn't
I think I know what the problem is. There are two typos is the valve script. Please change

Code: Select all

if (v == '-Rad ') then -- are the last four characters "-Rad"? If so we have a Radiator Valve
into

Code: Select all

if (v == '-Rad') then -- are the last four characters "-Rad"? If so we have a Radiator Valve
(i.e. remove the space after -Rad).

Similarly, change

Code: Select all

if (v == '-Stat ') then -- are the last five characters "-Stat "? If so we have an EQ-3 Thermostat
into

Code: Select all

if (v == '-Stat') then -- are the last five characters "-Stat"? If so we have an EQ-3 Thermostat
(i.e. remove the space after -Stat).
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest