This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Zigbee integration
#21
I’m not finished yet. How can I use this script as an event-based script and write the retrieved value to a group address?
Reply
#22
Hi, use a scheduled script that polls the data as often as needed
Code:
local zb = require('applibs.zigbee')

local ieee = 'f4ce36e12b9esa24'
local res, err = zb.cmdsync('getnamedattributes', ieee, 'HaElectricalMeasurement', {'RmsVoltage'})
log(res)
log(err)
if res then
  local rmsVoltage = res.RmsVoltage
  grp.checkwrite('37/1/3', rmsVoltage) -- 37/1/3 your group address
end

res, err = zb.cmdsync('getrawattribute', ieee, 0xFEE7, 0x0010)
log(res)
log(err)

local total_active_energy = res

if total_active_energy then
  total_active_energy = total_active_energy / 1000 -- to get kWh
  grp.checkwrite('37/1/4', total_active_energy) -- float value
end
Reply
#23
(Yesterday, 08:44)RomansP Wrote: Hi, use a scheduled script that polls the data as often as needed
Code:
local zb = require('applibs.zigbee')

local ieee = 'f4ce36e12b9esa24'
local res, err = zb.cmdsync('getnamedattributes', ieee, 'HaElectricalMeasurement', {'RmsVoltage'})
log(res)
log(err)
if res then
  local rmsVoltage = res.RmsVoltage
  grp.checkwrite('37/1/3', rmsVoltage) -- 37/1/3 your group address
end

res, err = zb.cmdsync('getrawattribute', ieee, 0xFEE7, 0x0010)
log(res)
log(err)

local total_active_energy = res

if total_active_energy then
  total_active_energy = total_active_energy / 1000 -- to get kWh
  grp.checkwrite('37/1/4', total_active_energy) -- float value
end

Thanks again!
Reply


Forum Jump: