handling of changing ids of sensors

This commit is contained in:
2025-12-21 16:04:25 +00:00
parent 1d1036cf2a
commit 09c003964d
4 changed files with 210 additions and 79 deletions

View File

@@ -10,13 +10,15 @@ Base = declarative_base()
class Sensor(Base):
__tablename__ = 'sensors'
id = Column(Integer, primary_key=True)
mqtt_name = Column(String(50), unique=True)
mqtt_name = Column(String(50)) # Removed unique=True to allow multiple pool sensors with same name
mqtt_id = Column(String(50))
position = Column(String(50))
room = Column(String(50))
battery = Column(Float)
rain_offset = Column(Float, default=0.0) # Cumulative offset for rain sensor resets
last_rain_value = Column(Float, default=0.0) # Last reported rain value (for reset detection)
node_id = Column(Integer, nullable=True) # For pool sensors: the nodeId (1, 2, etc.) that generates mqtt_id
sensor_type = Column(String(50), nullable=True) # Sensor type: 'BME280', 'DS18B20', 'Bresser-6in1', etc.
# Define the TemperatureInside table
class TemperatureInside(Base):