-
Notifications
You must be signed in to change notification settings - Fork 2
/
evohomepusher.lua
51 lines (49 loc) · 1.72 KB
/
evohomepusher.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
return {
on = {
devices = {
2, -- 2 Living room -- 3 Bedroom -- 4 Bathroom -- 5 Guest room -- 6 Office, --35 Kitching
3,
4,
5,
6,
35
}
},
logging = {
--level = domoticz.LOG_INFO,
marker = "evohome_push"
},
data = {
-- Store temp and setpoints in table
lasttemperature = { initial = {} },
lastsetpoint2 = { initial = {} },
-- Influx database URI, including database name
influxURI = { initial = 'http://localhost:8086/write?db=smarthome&precision=s' }
},
execute = function(dz, dev)
-- if temp or setpoint changed, push to influxdb
if (dev.temperature ~= dz.data.lasttemperature[dev.name] or
dev.setPoint ~= dz.data.lastsetpoint2[dev.name]) then
dz.data.lasttemperature[dev.name] = dev.temperature
dz.data.lastsetpoint2[dev.name] = dev.setPoint
dz.log('Device ' .. dev.name .. ' was changed. Temp: ' .. tostring(dev.temperature) .. ' setpoint: ' .. tostring(dev.setPoint), dz.LOG_INFO)
-- Push new temperature to influxdb, both actual and setpoint. Strip
-- device names from spaces for tags in influxdb.
-- format v1
-- dz.openURL({
-- url = dz.data.influxURI,
-- method = 'POST',
-- postData = "temperature,type=heating,device="..dev.name:gsub("%s+", "")..",subtype=actual value=" .. tonumber(dev.temperature) ..
-- "\ntemperature,type=heating,device="..dev.name:gsub("%s+", "")..",subtype=setpoint value=" .. tonumber(dev.setPoint)
-- })
-- format v2
dz.openURL({
url = dz.data.influxURI,
method = 'POST',
postData = "temperaturev2 "..dev.name:gsub("%s+", "").."=" .. tonumber(dev.temperature) .. ","..dev.name:gsub("%s+", "").."_set=" .. tonumber(dev.setPoint)
})
else
dz.log('Device ' .. dev.name .. ' was not changed.')
end
end
}