Skip to content

Commit

Permalink
Removing camelcase scullery remnants
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dunn committed Nov 21, 2023
1 parent 450d437 commit b65e5ae
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 3,257 deletions.
2,734 changes: 0 additions & 2,734 deletions docs/iot_devices/device.html

This file was deleted.

361 changes: 0 additions & 361 deletions docs/iot_devices/host.html

This file was deleted.

76 changes: 0 additions & 76 deletions docs/iot_devices/index.html

This file was deleted.

40 changes: 21 additions & 19 deletions iot_devices/devices/RTL433/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import uuid
import json
from mako.lookup import TemplateLookup
import iot_devices.host as host
import iot_devices.device as devices
from scullery import mqtt, messagebus
import logging
import time
import threading
Expand All @@ -7,17 +13,15 @@
from weakref import WeakValueDictionary
lock = threading.Lock()

from scullery import mqtt, messagebus

all_devs = weakref.WeakValueDictionary()


mqttlock = threading.Lock()

import iot_devices.device as devices
import iot_devices.host as host
stopFlag = [0]


def scan():
while 1:
if stopFlag[0]:
Expand All @@ -28,7 +32,8 @@ def scan():
for i in all_devs:
# If the last signal was very strong, we don't need to wait as long before considering
# it gone, because packet loss will be less
m = 3 if (all_devs[i].datapoints['rssi'] or -80) > -65 else 7
m = 3 if (all_devs[i].datapoints['rssi']
or -80) > -65 else 7

if all_devs[i].lastseen < time.monotonic() - (float(
all_devs[i].config.get('interval', 300) or 300) * m):
Expand All @@ -44,13 +49,13 @@ def scan():
t = threading.Thread(target=scan, name="RTL433Task", daemon=True)
t.start()


def stop():
stopFlag[0]= 1
stopFlag[0] = 1

host.app_exit_register(stop)

host.app_exit_register(stop)

from mako.lookup import TemplateLookup

templateGetter = TemplateLookup(os.path.dirname(__file__))

Expand All @@ -59,9 +64,6 @@ class CustomDeviceType(DeviceType):
pass
"""

import json
import uuid


class RTL433Client(devices.Device):
device_type = 'RTL433Client'
Expand All @@ -86,8 +88,7 @@ def __init__(self, name, data, **kw):
min=-180,
max=12,
interval=float(self.config["device.interval"]),
description=
"-75 if recetly seen, otherwise -180, we don't have real RSSI data",
description="-75 if recetly seen, otherwise -180, we don't have real RSSI data",
writable=False)

self.set_alarm("No Signal", 'rssi', "value<-110")
Expand All @@ -106,18 +107,18 @@ def __init__(self, name, data, **kw):
# This connection is actually possibly shared
# Scullery does the deduplication for us


self.connection = mqtt.getConnection(
self.connection = mqtt.get_connection(
self.config["device.server"],
int(self.config["device.port"].strip() or 1883),
password=self.config["device.password"].strip(),
connectionID=str("RTL433Connection"))
connection_id=str("RTL433Connection"))

self.numeric_data_point("mqttStatus", writable=False)
self.connection.subscribeToStatus(self.onConnectionChange)
self.connection.subscribe_to_status(self.onConnectionChange)
self.set_data_point("mqttStatus",
1 if self.connection.isConnected else 0)
self.set_alarm("MQTT Lost","mqttStatus", "value < 0.5", auto_ack=True, trip_delay=10)
1 if self.connection.is_connected else 0)
self.set_alarm("MQTT Lost", "mqttStatus",
"value < 0.5", auto_ack=True, trip_delay=10)

topic = data.get("device.mqtttopic", "home/rtl_433")

Expand Down Expand Up @@ -243,7 +244,8 @@ def onJSON(t, m):

# No real RSSI, we just use -75 to mean good and -180 to mean bad.
self.set_data_point("rssi", -75)
self.set_alarm("Signal Lost","rssi", "value < -98", auto_ack=True)
self.set_alarm("Signal Lost", "rssi",
"value < -98", auto_ack=True)

self.lastSeen = time.monotonic()

Expand Down
Loading

0 comments on commit b65e5ae

Please sign in to comment.