Dark AI
Dark AI
DIIDevHeads IoT Integration Server
Created by Boss lady on 7/11/2024 in #middleware-and-os
Why is my TI CC2652 smart lighting control system unable to read light sensor data?
it looks like the code assumes the door sensor is always node 1, have you confirmed the node ID of the door sensor? Nodes might not always be in a sequential order. You might need to scan the network for the correct node ID. Also, openzwave.network.ZWaveNetwork and openzwave.options.ZWaveOption might require proper initialization parameters. Make sure to configure the Z-Wave options correctly. Here’s a bit more detailed setup:
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)

for node in network.nodes:
print(f"Node {node.node_id}: {node}")

door_sensor = None
for node in network.nodes:
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()
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)

for node in network.nodes:
print(f"Node {node.node_id}: {node}")

door_sensor = None
for node in network.nodes:
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()
8 replies