old_contents: import logging
  
  from ds18b20 import DS18B20 as Sensor
  from src.MQTT.Message.Message import Message
  from src.MQTT.Message.Formatters.JsonFormatter import JsonFormatter
  
  
  class DS18B20:
  
      def __init__(self, address):
          self._sensor = Sensor(sensor_id=address)
  
      def get_temperature(self, mqtt_client, event_dispatcher, metric_details):
          logging.debug('Initialising DS18B20 sensor')
          temperature = self._sensor.get_temperature()
  
          message = Message()
          message_formatter = JsonFormatter()
          message.add_key_value(key='temperature', value=temperature)
          message.add_key_value(key='success', value=True)
  
          logging.info('Publishing message for DS18B20 _get_temperature to MQTT broker')
          mqtt_client.publish(metric_details['mqtt']['topic'], message_formatter.format(message=message.get_message()))
  
  
  
new_contents: import logging
  
  from blinker import signal
  from ds18b20 import DS18B20 as Sensor
  
  
  class DS18B20:
  
      def __init__(self, address):
          logging.info('Initialising DS18B20 sensor with address {}'.format(address))
          self._sensor = Sensor(sensor_id=address)
  
      def get_temperature(self, mqtt_details):
          """
          Return measured temperature from the sensor.
  
          :param dict mqtt_details: Relevant details for publishing to the MQTT broker
          :return:
          """
          logging.debug('Measuring temperature')
          temperature = self._sensor.get_temperature()
          logging.info('Broadcasting temperature: {}'.format(temperature))
  
          temperature_signal = signal('temperature')
          temperature_signal.send(self, temperature=temperature, mqtt_topic=mqtt_details['topic'])
  
  
  
subject: Use signals for DS18B20