11.10.2022, 09:02
Hello.
I saw this post and I had to try this myself, but it did not work.
This is my script that I have copied from here:
And this is the error:
"Nest Protect 11.10.2022 10:58:19
Resident script:1: attempt to index global 'data' (a nil value)
stack traceback:"
This is the API from google nest:
"smoke_co_alarms": {
"RTMTKxsQTCxzVcsy.................s": {
"device_id" :"RTMTKxsQTCxzVcsy.................s",
"locale" :"en-US",
"software_version" :"1.01",
"structure_id" :"VqFabWH21nwVyd4RWgJgNb292wa7hG_.....................w",
"name" :"Hallway (upstairs)",
"name_long" :"Hallway Protect (upstairs)",
"last_connection" :"2016-10-31T23:59:59.000Z",
"is_online" :true,
"battery_health" :"ok",
"co_alarm_state" :"ok",
"smoke_alarm_state" :"ok",
"is_manual_test_active" :true,
"last_manual_test_time" :"2016-10-31T23:59:59.000Z",
"ui_color_state" :"gray",
"where_id" :"UNCBGUnN24...",
"where_name" :"Hallway"
I saw this post and I had to try this myself, but it did not work.
This is my script that I have copied from here:
Code:
alarms = data['smoke_co_alarms']['RTMTKxsQTCxzVcsy.................s']
key, alarms = next(data['smoke_co_alarms'])
co_alarm_ok = alarms['co_alarm_state'] == 'ok'
grp.update('4/4/3', co_alarm_ok, dt.bool)
smoke_alarm_ok = alarms['smoke_alarm_state'] == 'ok'
grp.update('4/4/4', smoke_alarm_ok, dt.bool)
battery_health_ok = alarms['battery_health'] == 'ok'
grp.update('4/4/5', battery_health_ok, dt.bool)
And this is the error:
"Nest Protect 11.10.2022 10:58:19
Resident script:1: attempt to index global 'data' (a nil value)
stack traceback:"
This is the API from google nest:
"smoke_co_alarms": {
"RTMTKxsQTCxzVcsy.................s": {
"device_id" :"RTMTKxsQTCxzVcsy.................s",
"locale" :"en-US",
"software_version" :"1.01",
"structure_id" :"VqFabWH21nwVyd4RWgJgNb292wa7hG_.....................w",
"name" :"Hallway (upstairs)",
"name_long" :"Hallway Protect (upstairs)",
"last_connection" :"2016-10-31T23:59:59.000Z",
"is_online" :true,
"battery_health" :"ok",
"co_alarm_state" :"ok",
"smoke_alarm_state" :"ok",
"is_manual_test_active" :true,
"last_manual_test_time" :"2016-10-31T23:59:59.000Z",
"ui_color_state" :"gray",
"where_id" :"UNCBGUnN24...",
"where_name" :"Hallway"