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

running fixes

parent aa1e5255
No related branches found
No related tags found
No related merge requests found
...@@ -75,15 +75,16 @@ class Hauptbahnhof: ...@@ -75,15 +75,16 @@ class Hauptbahnhof:
self.loop.cancel() self.loop.cancel()
raise raise
await self.connected.wait() await self.connected.wait()
self.log.info("Successfully connected to %s", self._config['host'])
self.log.info("Successfully connected to %s", self._config['host'])
for topic in self._subscriptions: for topic in self._subscriptions:
mqtt.subscribe(topic) mqtt.subscribe(topic)
self._mqtt = mqtt
while self._mqtt_queue: while self._mqtt_queue:
topic, msg = self._mqtt_queue.pop(0) topic, msg = self._mqtt_queue.pop(0)
self.log.debug("Topic: %s", topic) self.log.debug("Topic: %s", topic)
await self._mqtt.publish(topic, msg) self._mqtt.publish(topic, msg)
# Now we have mqtt available! # Now we have mqtt available!
self._mqtt = mqtt self._mqtt = mqtt
......
...@@ -34,16 +34,19 @@ class Rupprecht: ...@@ -34,16 +34,19 @@ class Rupprecht:
self.space_is_open = False self.space_is_open = False
try: try:
r = RupprechtInterface("/dev/ttyACM0") self.rupprecht = RupprechtInterface("/dev/ttyACM0")
except serial.SerialException: except serial.SerialException:
r = RupprechtInterface("/tmp/rupprechtemulator") self.rupprecht = RupprechtInterface("/tmp/rupprechtemulator")
r.subscribe_button(self.button_message) self.rupprecht.subscribe_button(self.button_message)
self.imposed_ids = { self.imposed_ids = {
'rupprecht-table': rcswitch.Quigg1000(code=1337, subaddr=1, rupprecht=r), 'rupprecht-table': rcswitch.Quigg1000(code=1337, subaddr=1,
'rupprecht-alarm': rcswitch.Quigg1000(code=1337, subaddr=2, rupprecht=r), rupprecht=self.rupprecht),
'rupprecht-fan': rcswitch.Quigg1000(code=1337, subaddr=3, rupprecht=r) 'rupprecht-alarm': rcswitch.Quigg1000(code=1337, subaddr=2,
rupprecht=self.rupprecht),
'rupprecht-fan': rcswitch.Quigg1000(code=1337, subaddr=3,
rupprecht=self.rupprecht)
} }
async def teardown(self): async def teardown(self):
...@@ -65,9 +68,11 @@ class Rupprecht: ...@@ -65,9 +68,11 @@ class Rupprecht:
if msg['open'] and not self.space_is_open: if msg['open'] and not self.space_is_open:
self.space_is_open = True self.space_is_open = True
await self.hbf.publish('/haspa/status', json.dumps({'haspa':'open'})) await self.hbf.publish('/haspa/status', json.dumps({'haspa':'open'}))
self.rupprecht.text("Status: Open")
elif not msg['open'] and self.space_is_open: elif not msg['open'] and self.space_is_open:
self.space_is_open = False self.space_is_open = False
await self.hbf.publish('/haspa/status', json.dumps({'haspa':'closed'})) await self.hbf.publish('/haspa/status', json.dumps({'haspa':'closed'}))
self.rupprecht.text("Status: Closed")
class RupprechtInterface: class RupprechtInterface:
class SerialProtocol(asyncio.Protocol): 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