Skip to content
Snippets Groups Projects
Commit 6c3b093e authored by Johannes Walcher's avatar Johannes Walcher
Browse files

python i hate you for runtime types

parent 448238be
No related branches found
No related tags found
No related merge requests found
......@@ -22,15 +22,16 @@ class Hackerman:
"""
React to a status change of the hackerspace - switch the lights, ...
"""
del client
try:
if 'haspa' in message:
if message['haspa'] == 'open':
if message['haspa'] in ['open', 'offen', 'auf']:
await self.hbf.publish('/haspa/power', {
'table':1023,
'fan':1023,
'ledstrip':400,
})
elif message['haspa'] == 'closed':
elif message['haspa'] in ['close', 'zu', 'closed']:
await self.hbf.publish('/haspa/power', {
'table':0,
'fan':0,
......
......@@ -49,7 +49,9 @@ class Rupprecht:
async def teardown(self):
await self.hbf.teardown()
async def command_led(self, source, payload, msg):
async def command_led(self, source, payload, mqttmsg):
del source, payload
msg = json.loads(mqttmsg.payload.decode('utf-8'))
for devid, value in msg.items():
try:
if value == 0:
......@@ -62,10 +64,10 @@ class Rupprecht:
async def button_message(self, msg):
if msg['open'] and not self.space_is_open:
self.space_is_open = True
await self.hbf.publish('/haspa/status', 'open')
await self.hbf.publish('/haspa/status', json.dumps({'haspa':'open'}))
elif not msg['open'] and self.space_is_open:
self.space_is_open = False
await self.hbf.publish('/haspa/status', 'closed')
await self.hbf.publish('/haspa/status', json.dumps({'haspa':'closed'}))
class RupprechtInterface:
class SerialProtocol(asyncio.Protocol):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment