Why is my TI CC2652 smart lighting control system unable to read light sensor data?

hey guys am creating a smart lighting control system using a TI CC2652 with Embedded Linux. The system should read data from a Thread light sensor, I am using the NCP Thread Border Router Software (Model: OpenThread Border Router, Version: 0.3.0).
But am getting the error

Error reading light level: Device not found

i have verified the Thread network configuration and device commissioning, checked the light sensor status and connection, made sure the OpenThread library is correctly installed and configured

here is my code
import openthread

ot_instance = openthread.Instance()
ot_instance.factory_reset()

try:
    ot_instance.thread_start()
    light_sensor = ot_instance.device_manager.get_device('LightSensor')
    light_level = light_sensor.read_attribute('LightLevel')
except Exception as e:
    print(f"Error reading light level: {e}")
finally:
    ot_instance.thread_stop()

@Middleware & OS
Solution
Thanks @Dark AI it's already been resolved, I updated the code to scan for the correct node and added some initialization checks. Here's the updated version:

import openzwave.option
import openzwave.network
import time

options = openzwave.option.ZWaveOption("/dev/ttyUSB0", config_path="/path/to/openzwave/config", user_path=".", cmd_line="")
options.lock()
network = openzwave.network.ZWaveNetwork(options, log=None)

network.start()

for i in range(0, 300):
    if network.state >= network.STATE_AWAKED:
        break
    time.sleep(1)

print("Network state:", network.state)

door_sensor = None
for node in network.nodes.values():
    print(f"Node {node.node_id}: {node}")
    if node.product_name == "Your Door Sensor Product Name":
        door_sensor = node
        break

if door_sensor:
    try:
        door_status = door_sensor.get_sensor_binary_value()
        print(f"Door Status: {door_status}")
    except Exception as e:
        print(f"Error reading door status: {e}")
else:
    print("Door sensor not found")

network.stop()
Was this page helpful?