From 80f7e998ae9585894d30e21835817b4bbb6ccb74 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Thu, 28 Feb 2019 06:30:34 -0600 Subject: [PATCH] resend availability if disconnected --- README.md | 3 ++- detect_objects.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cd9d7dbe7..b85a34274 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ Access the mjpeg stream at http://localhost:5000 - [x] Add last will and availability for MQTT - [ ] Build tensorflow from source for CPU optimizations - [ ] Add ability to turn detection on and off via MQTT -- [ ] MQTT reconnect if disconnected (and resend availability message) +- [x] MQTT reconnect if disconnected (and resend availability message) - [ ] MQTT motion occasionally gets stuck ON - [ ] Output movie clips of people for notifications, etc. +- [ ] Integrate with homeassistant push camera - [x] Store highest scoring person frame from most recent event - [x] Add a max size for motion and objects (height/width > 1.5, total area > 1500 and < 100,000) - [x] Make motion less sensitive to rain diff --git a/detect_objects.py b/detect_objects.py index d01dd3eb0..d774b0ae5 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -139,12 +139,15 @@ def main(): object_cleaner.start() # connect to mqtt and setup last will + def on_connect(client, userdata, flags, rc): + print("On connect called") + # publish a message to signal that the service is running + client.publish(MQTT_TOPIC_PREFIX+'/available', 'online', retain=True) client = mqtt.Client() + client.on_connect = on_connect client.will_set(MQTT_TOPIC_PREFIX+'/available', payload='offline', qos=1, retain=True) client.connect(MQTT_HOST, 1883, 60) client.loop_start() - # publish a message to signal that the service is running - client.publish(MQTT_TOPIC_PREFIX+'/available', 'online', retain=True) # start a thread to publish object scores (currently only person) mqtt_publisher = MqttObjectPublisher(client, MQTT_TOPIC_PREFIX, objects_parsed,