Skip to content

Commit fe659e2

Browse files
author
brentru
committed
update
1 parent efce21a commit fe659e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Adafruit_IO_Power_Relay/code_light_sensor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import adafruit_minimqtt.adafruit_minimqtt as MQTT
1212

1313
### Sensor Calibration ###
14+
# Appliance power LED's light level, in Lux
1415
APPLIANCE_ON_LUX = 30.0
1516
# How often the light sensor will be read, in seconds
1617
SENSOR_READ_TIME = 10.0
@@ -135,7 +136,7 @@ def on_relay_msg(client, topic, value):
135136
# Subscribe to all updates on relay feed
136137
client.subscribe(feed_relay)
137138

138-
# Holds state of light sensor
139+
# Holds previous state of light sensor
139140
prv_sensor_value = 0
140141
# Time in seconds since start
141142
start_time = time.monotonic()
@@ -162,6 +163,7 @@ def on_relay_msg(client, topic, value):
162163
print("Appliance OFF, publishing to IO...")
163164
client.publish(feed_status, 2)
164165
print("Published!")
166+
prv_sensor_value = sensor_value
165167
start_time = now
166168
except (ValueError, RuntimeError) as e:
167169
print("Failed to get data, retrying\n", e)

0 commit comments

Comments
 (0)