Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
domoticz2influxdb/evohomepusher.lua
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (49 sloc)
1.72 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |