Skip to content

Commit

Permalink
fix camera status always online #907 #920
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Jul 22, 2023
1 parent d62067a commit 249f389
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions app/wyzebridge/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ def mqtt_sub_topic(m_topics: list, callback) -> Optional[paho.mqtt.client.Client
return client


def bridge_status(client: Optional[paho.mqtt.client.Client], cams: list):
def bridge_status(client: Optional[paho.mqtt.client.Client]):
"""Set bridge online if MQTT is enabled."""
if not client:
return
client.publish(f"{MQTT_TOPIC}/state", "online")
for cam in cams:
client.publish(f"{MQTT_TOPIC}/{cam}/state", "online")


@mqtt_enabled
Expand Down Expand Up @@ -162,7 +160,7 @@ def _mqtt_discovery(client, cams, msg):
if msg.payload.decode().lower() != "online" or not cams:
return

bridge_status(client, [])
bridge_status(client)
for uri, cam in cams.items():
publish_discovery(uri, cam, False)

Expand Down
2 changes: 1 addition & 1 deletion app/wyzebridge/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def monitor_streams(self, mtx_health: Callable) -> None:
self.snap_all(cams)
if int(time.time()) % 15 == 0:
mtx_health()
bridge_status(mqtt, cams)
bridge_status(mqtt)
if mqtt:
mqtt.loop_stop()
logger.info("Stream monitoring stopped")
Expand Down

0 comments on commit 249f389

Please sign in to comment.