28.11.2017, 09:14
Try this, assuming data variable is a Lua table that you get by decoding JSON response:
Code:
alarms = data['smoke_co_alarms']['sgUHZf.....APJP7e2-z........Y']
co_alarm_ok = alarms['co_alarm_state'] == 'ok'
grp.update('1/1/1', co_alarm_ok, dt.bool)
smoke_alarm_ok = alarms['smoke_alarm_state'] == 'ok'
grp.update('1/1/2', smoke_alarm_ok, dt.bool)
battery_health_ok = alarms['battery_health'] == 'ok'
grp.update('1/1/3', battery_health_ok, dt.bool)