I think the WiFi version is very similar to the network version, and I’ve already coded the CRC routines (it took a while, but it works fine…). I think the code you need is this -:
-- Heatmiser CRC functions
local CRC16_LookupHigh = {0,16,32,48,64,80,96,112,129,145,161,177,193,209,225,241}
local CRC16_LookupLow = {0,33,66,99,132,165,198,231,8,41,74,107,140,173,206,239}
local CRC16_High
local CRC16_Low
function CRC16(buf, len)
CRC16_High = 255
CRC16_Low = 255
for cnt = 1, len, 2 do
val = tonumber(string.sub(buf, cnt, cnt+1),16)
CRC16_Update(val)
end
return CRC16_Low, CRC16_High
end
function CRC16_Update4Bits(val)
local t
t = bit.band(bit.rshift(CRC16_High, 4), 15)
t = bit.band(bit.bxor(t, val), 15) + 1
CRC16_High = bit.band(bit.bor(bit.lshift(CRC16_High, 4), bit.rshift(CRC16_Low, 4)), 255)
CRC16_Low = bit.band(bit.lshift(CRC16_Low, 4),255)
CRC16_High = bit.band(bit.bxor(CRC16_High, CRC16_LookupHigh[t]), 255)
CRC16_Low = bit.band(bit.bxor(CRC16_Low, CRC16_LookupLow[t]), 255)
end
function CRC16_Update(val)
CRC16_Update4Bits(bit.rshift(val, 4))
CRC16_Update4Bits(bit.band(val, 15))
end
In your init code, you then need to add the line “bit = require(“bit”)”.
I think that should do it, but it’s possible I’ve missed some bits as I wrote all this at the beginning of this year and am only just getting around to installing the heating in the extension now!
My current plugin just does the basics - sets/reads the setpoint and other config data, reads the temperatures, on/off state etc, and allows setting of holiday mode. It also syncs the time on all the thermostats on the system. For the hot water thermostats (PRT-HW) it provides two separate thermostats in Vera - one for the water, and one for the heating… I haven’t (yet anyway) added anything to manipulate the heating schedules as my main driver is to be able to read the temperatures and override the setpoints…
If there’s interest I can look at releasing an “alpha” version… I hope to have a second thermostat installed tomorrow for the underfloor heating and may need to change a few things to support the different thermostat model, but then the basic functionality should be reasonably complete…
Chris