* add support for Home Assistants MQTT discovery * add format_topic a flexible separator * add mqtt discovery for miflora * add mqtt discovery for mithermometer * add mqtt discovery for thermostat * add unit to illuminance in miflora * switch to 'away_mode_command_topic' instead of 'away_command_topic' * revert changing the date format * add mac to ientifiers and change the id generation * add mac to ientifiers and change the id generation on thermostat * add mac to ientifiers and change the id generation for mithermometer
19 lines
506 B
Python
19 lines
506 B
Python
class BaseWorker:
|
|
def __init__(self, command_timeout, **args):
|
|
self.command_timeout = command_timeout
|
|
for arg, value in args.items():
|
|
setattr(self, arg, value)
|
|
self._setup()
|
|
|
|
def _setup(self):
|
|
return
|
|
|
|
def format_id(self, *args, separator='/'):
|
|
return separator.join(["bt-mqtt-gateway", repr(self), *args])
|
|
|
|
def format_topic(self, *args, separator='/'):
|
|
return separator.join([self.topic_prefix, *args])
|
|
|
|
def __repr__(self):
|
|
return self.__module__.split(".")[-1]
|