Minor fixes

- onewire is not hardcoded to busmaster 1
- try to catch exception while sending data to WS and WS has closed connection
This commit is contained in:
avollkopf 2022-01-25 07:47:40 +01:00
parent 7ad3fd252e
commit 8320853399
3 changed files with 8 additions and 5 deletions

View file

@ -1,2 +1 @@
__version__ = "4.0.1.3"
__version__ = "4.0.1.4"

View file

@ -41,7 +41,7 @@ class ReadThread (threading.Thread):
try:
if self.sensor_name is None:
return
with open('/sys/bus/w1/devices/w1_bus_master1/%s/w1_slave' % self.sensor_name, 'r') as content_file:
with open('/sys/bus/w1/devices/%s/w1_slave' % self.sensor_name, 'r') as content_file:
content = content_file.read()
if (content.split('\n')[0].split(' ')[11] == "YES"):
temp = float(content.split("=")[-1]) / 1000 # temp in Celcius

View file

@ -32,7 +32,11 @@ class CBPiWebSocket:
self.logger.debug("broadcast to ws clients. Data: %s" % data)
for ws in self._clients:
async def send_data(ws, data):
await ws.send_json(data=data, dumps=json_dumps)
try:
await ws.send_json(data=data, dumps=json_dumps)
except Exception as e:
self.logger.error("Error with client %s: %s" % (ws, str(e)))
self.cbpi.app.loop.create_task(send_data(ws, data))
async def websocket_handler(self, request):
@ -85,4 +89,4 @@ class CBPiWebSocket:
self.logger.info("Web Socket Close")
return ws