From 1bc7b1f92bcd44b370109365859162ff43fe86c7 Mon Sep 17 00:00:00 2001 From: zewelor Date: Wed, 29 Nov 2017 09:39:32 +0100 Subject: [PATCH] Fix thermostat commands --- config.yaml.example | 4 ++-- workers/thermostat.py | 5 +---- workers_manager.py | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index d44e7f4..690c978 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -7,6 +7,6 @@ workers: args: devices: bedroom: 00:11:22:33:44:55 - topic_prefix: thermostat - topic_subscription: thermostat + topic_prefix: thermostat + topic_subscription: thermostat/+/+/set update_interval: 60 diff --git a/workers/thermostat.py b/workers/thermostat.py index ab6b93f..fb8142c 100644 --- a/workers/thermostat.py +++ b/workers/thermostat.py @@ -64,7 +64,7 @@ class ThermostatWorker(BaseWorker): return ret def on_command(self, topic, value): - _, device_name, method = topic.split('/') + _, device_name, method, _ = topic.split('/') thermostat = self.devices[device_name] if method == STATE_AWAY: @@ -94,6 +94,3 @@ class ThermostatWorker(BaseWorker): def device_for(self, mac): return eq3bt.Thermostat(mac) - - def format_topic(self, device, attr): - return '/'.join([device, attr]) diff --git a/workers_manager.py b/workers_manager.py index a6c1c88..308ab29 100644 --- a/workers_manager.py +++ b/workers_manager.py @@ -44,9 +44,9 @@ class WorkersManager: ) if 'topic_subscription' in worker_config: - _LOGGER.debug("Subscribing to: %s" % worker_config['topic_subscription'] + '/#') + _LOGGER.debug("Subscribing to: %s" % worker_config['topic_subscription']) mqtt_callbacks.append(( - worker_config['topic_subscription'] + '/#', + worker_config['topic_subscription'], lambda client, _ , c: _WORKERS_QUEUE.put(cls.Command(worker_obj.on_command, [c.topic, c.payload])) ))