Forgot that I did change the code a while ago. The main reason was to get the temperatures in real or rather floating numbers. I am comparing the beer target and is temperatures with PLEG, then I use VeraAlerts to send me notifications to my cell phone in case anything is not OK. Here is my current code (I am no programmer!!):
--SETUP
local ipAddress = "10.0.0.71"
local port = 80
--READING DATA FROM BREWPI
json = require('json-dm')
curlcommand = "curl --data \"messageType=lcd\" http://" .. ipAddress .. ":" .. port .. "/socketmessage.php"
local handle = io.popen(curlcommand)
local result = handle:read("*a")
handle:close()
--EXTRACTING TEMPERATURES / WRITING DATA TO TABLE
temperatures = {}
for temperature in string.gmatch(result, "[%d+]+[%.]+[%d+]") do table.insert(temperatures, temperature) end
words = {}
for word in string.gmatch(result, "%w+") do table.insert(words, word) end
--WRITTING TO DUMMY DEVICE
setVCvar(104,1,"" .. words[14] .. " " .. words[15] .. " " ..words[16])
setVCvar(104,2,temperatures[1])
setVCvar(104,3,temperatures[2])
setVCvar(104,4,temperatures[3])
setVCvar(104,5,"" .. words[1] .. " " .. words[2] .. " " ..words[3])
So if I read your log correctly this happens on the vera itself, propably since PLEG tries to compare a string to a number. But I have to check this at home, I can not put my BrewPi in Off-Mode from work. An since the vera itself is programed so bad, it blocks everything once it has an error like this.
The version above also writes the mode and the current state of the BrewPi into a variable. Basically I parse all the information into tables, but then I only send the information I care about to the dummy device. If you need further information you can use the following debug version, this will show you all the information of what I get from vera:
--SETUP
local ipAddress = "10.0.0.71"
local port = 80
local DEBUG_MODE = true
--BASIC FUNCTIONS
local function log(stuff, level)
luup.log("BrewPi: " .. stuff, (level or 50))
end
local function debug(stuff)
if (DEBUG_MODE) then
log("debug " .. stuff, 1)
end
end
--READING DATA FROM BREWPI
json = require('json-dm')
curlcommand = "curl --data \"messageType=lcd\" http://" .. ipAddress .. ":" .. port .. "/socketmessage.php"
local handle = io.popen(curlcommand)
local result = handle:read("*a")
handle:close()
debug("Reading from BrewPi SECOND: " .. result)
--EXTRACTING TEMPERATURES / WRITING DATA TO TABLE
temperatures = {}
for temperature in string.gmatch(result, "[%d+]+[%.]+[%d+]") do table.insert(temperatures, temperature) end
words = {}
for word in string.gmatch(result, "%w+") do table.insert(words, word) end
--WRITTING TO DUMMY DEVICE
setVCvar(104,1,"" .. words[14] .. " " .. words[15] .. " " ..words[16])
setVCvar(104,2,temperatures[1])
setVCvar(104,3,temperatures[2])
setVCvar(104,4,temperatures[3])
setVCvar(104,5,"" .. words[1] .. " " .. words[2] .. " " ..words[3])
debug("Tabelle 1: " .. temperatures[1])
debug("Tabelle 2: " .. temperatures[2])
debug("Tabelle 3: " .. temperatures[3])
debug("Tabelle 3: " .. words[1])
debug("Tabelle 3: " .. words[2])
debug("Tabelle 3: " .. words[3])
debug("Tabelle 3: " .. words[4])
debug("Tabelle 3: " .. words[5])
debug("Tabelle 3: " .. words[6])
debug("Tabelle 3: " .. words[7])
debug("Tabelle 3: " .. words[8])
debug("Tabelle 3: " .. words[9])
debug("Tabelle 3: " .. words[10])
debug("Tabelle 3: " .. words[11])
debug("Tabelle 3: " .. words[12])
debug("Tabelle 3: " .. words[13])
debug("Tabelle 3: " .. words[14])
debug("Tabelle 3: " .. words[15])
debug("Tabelle 3: " .. words[16])
But there are diffculties. The first one is that BrewPi alters the room-temperature and the fridge temperature on one variable, so you will never reall know what you get since it depends on the moment you ask for it. Another one is that it is difficult to seperate that string into different parts (at least for me…).