Page 29 of 37
Re: ELV Max! Heating control system
Posted: Tuesday 19 September 2017 20:12
by Westcott
Hi Peggy and Mvzut,
Thanks for the interest!
This is just one module from my Python Domoticz helper.
I wrote the helper to handle all of the network and internet action previously done in Lua.
Now I have 'proper' error handling and retries, no more Lua 10 second time-outs (times-out?).
Read() is called every 5 minutes by a scheduler in the main helper.
SetSetpoint() is called when Domoticz Lua sends the appropriate command to the helper.
'UTILS' is my library of utility functions.
'LOG' is my own logging class.
'mconfig' is the MaxCube section of the helper's config file.
UTILS.UpdateDevice() sends a Json update to Domoticz.
UTILS.SendMessage() sends to the Domoticz log.
LOG.Log() writes to the helper's logfile and console.
Peggy, that definitely looks like the library I used.
There would be no problem adjusting the setpoint either way.
Re: ELV Max! Heating control system
Posted: Wednesday 20 September 2017 1:57
by Peggy
Westcott,
1) Question 1 : would you mind sharing your helper? At least UTILS and the MaxCube section of your helper's config file. The whole helper may be ideal.
I plan to code my script this week end, based on your work. I don't care if half of your code is not appropriate. I'll "clean" it by myself.
2) Question 2 : Why did you comment this : self.UTILS.UpdateDevice(name + ' mode', smode + "|" + str(dmode))
Re: ELV Max! Heating control system
Posted: Wednesday 20 September 2017 11:59
by Westcott
Hi Peggy,
Attached file has the bits you want (I think!)
The commented-out line used to update the valve's 'mode' in Domoticz.
I took it out because I only use 'manual' mode.
Re: ELV Max! Heating control system
Posted: Wednesday 20 September 2017 13:53
by Peggy
Your work is a gold mine, truly. I'll rewrite most of my eventghost scripts in order to use your Domoticz library which looks very well optimized. I wonder why you delete old devices every ten minutes, doing this so often looks overkill. Anyway, it is nice.
I'm curious to know what is physically behind your sonoff and OLED methods. I use 15 sonoff using Tasmota's firmware, which is HTTP and MQTT compatible.
Concerning the oled, did you describe your setup somewhere on internet?
Thank you, sincerely.
Re: ELV Max! Heating control system
Posted: Wednesday 20 September 2017 18:35
by Westcott
Hi Peggy,
Thanks for the kind words (blush)!
The old device delete scheduler in RunDeleted() runs every 30 mins.
The call sch.enter(15, 1, RunDeleted) runs just once, 15 seconds after it is called, so the background processes don't all start at once, but at 5 sec intervals.
My Sonoffs all run ESPeasy 147 and use HTTP directly - no MQTT.
The OLED is a standard .96" I2C module connected to the PRi that runs Domoticz and the helper. It was plug and play using the libraries in OLED.py.
They came with "FreeSans.ttf" but you can use any font you fancy.
Re: ELV Max! Heating control system
Posted: Thursday 21 September 2017 5:09
by Peggy
All right, after a few hours of tuning, mvzut's script seems working, Westcott's too. I can't test much because the cube is running with no device.
The question now is : can I use mvzut's script for the device creation, then Westcott's one for the sync? Does they both use the same ID logic? I can't confirm. The suspens is maximum, as I should get the valve friday or later.
Westcott uses this :
Code: Select all
def UpdateDevice(self, name, val):
if name in self.svalues:
if "|" in str(val):
val, val2 = val.split("|")
else:
val2 = val
if val != self.svalues[name]:
# print("{} {} -> {}".format(name, self.svalues[name], val2))
data = "command¶m=udevice&idx={}&svalue=" + str(val2)
self.SendCommand(name, data)
self.svalues[name] = str(val)
else:
self.SendAll("Unknown device '{}'".format(name))
But I don't understand how the device idx is known.
I could see in checkonline :
Code: Select all
self.UpdateDevice(name, macip)
self.svalues[name] = macip
And somewhere else :
Code: Select all
def SendCommand(self, name, cmd):
if name in self.indexes:
idx = self.indexes[name]
data = cmd.format(idx)
threading.Thread(target=self.DomoticzData, args=(data,)).start()
else:
self.SendAll("No IDX for '{}'".format(name))
To be honnest I don't understand the checkonline method.
Re: ELV Max! Heating control system
Posted: Thursday 21 September 2017 11:17
by Westcott
Hi Peggy,
Yes, it is confusing, isn't it?
My helper is based on Egregius' Pass2php.
The main difference is that my 'script' runs continuously as a service.
Domoticz Lua sends all device data to my helper, including name-to-idx table.
This is held in the Python dictionary 'indexes'
Lua -
Code: Select all
function Utils.SendToPython(device, ddata, force)
--print("Start")
if (otherdevices['Python helper'] == 'On' or (force and force == true)) then
data = {}
if device and ddata then
d = {}
d[device] = ddata
data['changed'] = d
elseif devicechanged then
data['changed'] = devicechanged
end
for deviceName, deviceValue in pairs(data['changed']) do
device = deviceName
val = deviceValue
print("⇒ "..device..' = '..val..' ⇒')
end
data['svalues'] = otherdevices
data['indexes'] = otherdevices_idx
data['lastupdate'] = otherdevices_lastupdate
data['vvalues'] = uservariables
data['vupdate'] = uservariables_lastupdate
PassToPython(data)
else
print("-- Python offline --")
end
end
function PassToPython(data)
if not JSON then
JSON = require "cjson"
end
jdata = JSON.encode(data)
package.loadlib("core.so", "*")
local Socket = require "socket"
local client = Socket.connect('localhost', 8088)
if not client then
print("Python socket connect failed")
return
else
client:settimeout(2)
i, status = client:send(jdata);
if not i then
print("Python send failed - "..status)
else
s, status, partial = client:receive(1024)
reply = JSON.decode(s or partial)
-- print("Status = "..reply['status'])
end
end
client:close()
return reply
end
Re: ELV Max! Heating control system
Posted: Thursday 21 September 2017 11:44
by Peggy
Hum,
Then I'll have to dig more on your stuff. If I understand :
1 - I need to add a new LUA script in domoticz , the one you just published above. This One will open a socket.
2 - I have to un-comment the do-while that was locking my app (eventghost), and launch the helper as a thread so that it keeps persistent.
I start to understand why the "battery" method didn't show anything. Only the "delete" method is functionnal for now.
Re: ELV Max! Heating control system
Posted: Friday 22 September 2017 8:05
by Peggy
I installed your LUA in domoticz as a device script, I get an error saying that UTIL is not defined or something like that. I don't catch this syntax : UTIL.MyMethodName
Re: ELV Max! Heating control system
Posted: Tuesday 24 October 2017 12:03
by kluczus
Hi,
I have, maybe a stupid quiestion. I have a few eq-3 max basic radiatiors and lan cube. I'am quite happy with this configuration except one thing.
They all have internal temp sensors and I have fake temperatures. I have a few esp8266 temp modules and want to use them. Is it possible to change somehow to convince them to use external temperature sensors ?
Re: ELV Max! Heating control system
Posted: Tuesday 24 October 2017 12:37
by Peggy
No, as far as I know it is not possible.
Re: ELV Max! Heating control system
Posted: Tuesday 24 October 2017 12:40
by kluczus
Re: ELV Max! Heating control system
Posted: Tuesday 24 October 2017 12:43
by Peggy
Yes
Re: ELV Max! Heating control system
Posted: Thursday 26 October 2017 20:30
by kluczus
Helo,
I desperatly looking for help with my eq3 max! integration. First, I have started with php scripts from different topic. Everything was ok until I connected wall thermostats. Then everything stoped working. There is a bug with reading data from a cube. Unfortunetly I dont know how to repair it and an author of this was active on forum last time in april
So I switch to lua version from wiki. Devices created, even updates working but I dont know how to send a new setpoint to thermostats
I feel stupid.
I want just simple set a temperture from domoticz
Re: ELV Max! Heating control system
Posted: Thursday 26 October 2017 20:39
by bilbolodz
You can try: MAX! HOME AUTOMATION
http://www.dmitry-kazakov.de/ada/max_ho ... mation.htm
It has GUI, integrated web server and MQTT.
If you want "simple set temperature" you can try to sniff communication between MAX (original) application and Cube and then replay it using netcat (working).
Re: ELV Max! Heating control system
Posted: Thursday 26 October 2017 20:59
by kluczus
Ok, Its looks like this is simpler solution
https://github.com/Juerd/eq3-max
Re: ELV Max! Heating control system
Posted: Friday 27 October 2017 6:56
by Peggy
Starting from this need :
I want just simple set a temperture from domoticz
The simplest and easiest solution is mvzut's lua script. It's been working for 1 month here, so far so good.
Re: ELV Max! Heating control system
Posted: Friday 27 October 2017 9:03
by kluczus
Yes, you are right
I had some problems with this script but now its working without problem. Superb job !!!!
I have only one question. Now every action is sent to cube every 5 minutes. It's ok when we are only reading data from cube but not enought when I want to change valves. Is it possible to change it ??? 5 minutes to read data from cube and immediatelly after I change something from domoticz side ?
Re: ELV Max! Heating control system
Posted: Friday 27 October 2017 9:27
by Peggy
Then you need to trigger the script after any manual change in domoticz. It is doable but Idk how, being under Windows things are a bit different.
Re: ELV Max! Heating control system
Posted: Friday 27 October 2017 16:22
by kluczus
Ok, thank you for tips. Finally I have working system
I have used a max command from previous post. Its triggered as you suggested