Update README.md and sensor_bridge.py to reflect changes in MQTT topic structure. Transitioned from a hierarchical to a flat topic structure for improved organization, simplifying the topic format for each location. Adjusted sensor publishing methods in sensor_bridge.py to align with the new topic structure, ensuring accurate data representation for temperature, humidity, and CO2 sensors.
This commit is contained in:
@ -79,11 +79,8 @@ def read_and_publish_temperature_humidity(mqtt_client, modbus_client, host_info)
|
||||
|
||||
# Publish data
|
||||
location = host_info["location"]
|
||||
sensor_type = "temperature-humidity"
|
||||
current_time = datetime.now(LOCAL_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
base_topic = f"Location/{location}/{sensor_type}"
|
||||
|
||||
base_topic = f"Location/{location}"
|
||||
topics_data = [
|
||||
(f"{base_topic}/Time", current_time),
|
||||
(f"{base_topic}/Status", "online"),
|
||||
@ -141,11 +138,8 @@ def read_and_publish_cwt_co2(mqtt_client, modbus_client, host_info):
|
||||
|
||||
# Publish data
|
||||
location = host_info["location"]
|
||||
sensor_type = "CO2-gas"
|
||||
current_time = datetime.now(LOCAL_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
base_topic = f"Location/{location}/{sensor_type}"
|
||||
|
||||
base_topic = f"Location/{location}"
|
||||
topics_data = [
|
||||
(f"{base_topic}/Time", current_time),
|
||||
(f"{base_topic}/Status", "online"),
|
||||
|
Reference in New Issue
Block a user