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.

Read Data from Table
#9
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:

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"
Reply


Messages In This Thread
Read Data from Table - by Alphaplasti - 28.11.2017, 08:12
RE: Read Data from Table - by admin - 28.11.2017, 09:14
RE: Read Data from Table - by Alphaplasti - 28.11.2017, 10:53
RE: Read Data from Table - by admin - 28.11.2017, 11:45
RE: Read Data from Table - by Alphaplasti - 28.11.2017, 13:58
RE: Read Data from Table - by admin - 28.11.2017, 14:28
RE: Read Data from Table - by Alphaplasti - 28.11.2017, 15:10
RE: Read Data from Table - by toujour - 14.02.2020, 07:47
RE: Read Data from Table - by AlexD - 11.10.2022, 09:02
RE: Read Data from Table - by admin - 11.10.2022, 09:24

Forum Jump: