port number of MQTT broker can now be changed via YAML file
This commit is contained in:
@@ -14,6 +14,7 @@ TODO:
|
|||||||
- gps3
|
- gps3
|
||||||
- schedule
|
- schedule
|
||||||
- aprslib
|
- aprslib
|
||||||
|
- paho.mqtt
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@@ -91,7 +91,8 @@ class aprs_telemetry_to_mqtt:
|
|||||||
# Publish a single message to the MQTT broker
|
# Publish a single message to the MQTT broker
|
||||||
def publish(self, topic, message):
|
def publish(self, topic, message):
|
||||||
try:
|
try:
|
||||||
publish.single(topic, message, hostname=self.config_file_settings['global']['broker'])
|
#publish.single(topic, message, hostname=self.config_file_settings['global']['broker'])
|
||||||
|
publish.single(topic, message, hostname=self.config_file_settings['global']['broker'], port=self.config_file_settings['global']['port'], client_id=self.mqtt_client_id)
|
||||||
except:
|
except:
|
||||||
logger.debug("Failed to connect to MQTT broker.")
|
logger.debug("Failed to connect to MQTT broker.")
|
||||||
else:
|
else:
|
||||||
@@ -176,7 +177,8 @@ class aprs_telemetry_to_mqtt:
|
|||||||
publish_list.append({"topic": current_topic, "payload": values[index]})
|
publish_list.append({"topic": current_topic, "payload": values[index]})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
publish.multiple(publish_list, hostname=self.config_file_settings['global']['broker'])
|
#publish.multiple(publish_list, hostname=self.config_file_settings['global']['broker'])
|
||||||
|
publish.multiple(publish_list, hostname=self.config_file_settings['global']['broker'], port=self.config_file_settings['global']['port'], client_id=self.mqtt_client_id)
|
||||||
except:
|
except:
|
||||||
logger.debug("Failed to connect to MQTT broker.")
|
logger.debug("Failed to connect to MQTT broker.")
|
||||||
else:
|
else:
|
||||||
|
@@ -487,8 +487,8 @@ def run():
|
|||||||
schedule.every(1).minutes.do(read_weather_station, weather_station)
|
schedule.every(1).minutes.do(read_weather_station, weather_station)
|
||||||
|
|
||||||
# Schedule telemetry transmision
|
# Schedule telemetry transmision
|
||||||
print("Scheduled telemetry transmission.")
|
#print("Scheduled telemetry transmission.")
|
||||||
schedule.every(10).minutes.do(send_telemetry)
|
#schedule.every(10).minutes.do(send_telemetry)
|
||||||
|
|
||||||
print("Schedule mqtt weather publisher.")
|
print("Schedule mqtt weather publisher.")
|
||||||
interval = mqtt_connection.config_file_settings['global']['weather_report_interval']
|
interval = mqtt_connection.config_file_settings['global']['weather_report_interval']
|
||||||
|
Reference in New Issue
Block a user