Skip to content

Commit 8f9efe3

Browse files
committed
#86 adding humidity sensor
1 parent 959dcf1 commit 8f9efe3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mqtt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def on_message(client, device, msg):
9393

9494
# internal notification
9595
if command == 'temperature' or \
96+
command == 'humidity' or \
9697
command == 'energy' or \
9798
command == 'sensors' or \
9899
command == 'position' or \
@@ -479,6 +480,12 @@ def broadlink_rm_temperature_timer(scheduler, delay, device, mqtt_prefix):
479480
topic = mqtt_prefix + "temperature"
480481
logging.debug("Sending RM temperature " + temperature + " to topic " + topic)
481482
mqttc.publish(topic, temperature, qos=qos, retain=retain)
483+
484+
if device.type == 'RM4':
485+
humidity = str(device.check_humidity())
486+
topic = mqtt_prefix + "humidity"
487+
logging.debug("Sending RM humidity " + humidity + " to topic " + topic)
488+
mqttc.publish(topic, humidity, qos=qos, retain=retain)
482489
except:
483490
logging.exception("Error")
484491

test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ def __init__(self, cf):
88
def auth(self):
99
pass
1010

11+
# RM2/RM4
1112
def check_temperature(self):
1213
return 23.5
1314

15+
# RM4
16+
def check_humidity(self):
17+
return 56
18+
1419
def enter_learning(self):
1520
pass
1621

0 commit comments

Comments
 (0)