in src/main.py [0:0]
def publish_processor_temp(self):
'''
In this example we publish an unsolicited update message to this components
data topic to the MQTT API so can be viewed in the AWS IoT Core.
The example is sending a random value between 40 and 50 to represent reading
and publishing edge devices processor temperature.
'''
try:
### Create an example data update command and params fields
command = 'processor_temp_update'
status = 200
params = {
"units" : "Celsius",
"value" : random.randint(40,50)
}
# Create the UPDATE message well-formatted object
update_message = self.pubsub_messages.get_pubsub_update(command, status, params)
# Publish the message to this components MQTT Data Topic
# Once deployed, this message will be viewable in the AWS IoT Core
self.publish_message('mqtt', self.mqtt_data_topic, update_message)
except Exception as err:
log.error('EXCEPTION: Exception in publish_processor_temp - ERROR MESSAGE: {}'.format(err))