Fix missing value field

This commit is contained in:
Jan Zípek 2025-03-04 21:31:42 +01:00
parent 4f9fcbe7e0
commit 9f65112a82
Signed by: kamen
GPG Key ID: A17882625B33AC31
2 changed files with 7 additions and 2 deletions

View File

@ -260,7 +260,12 @@ func (s *MQTTBrokersService) EnsureListeners() {
// TODO: This is sub-optional
for _, sensor := range brokerSensors {
if sensor.MqttTopic == nil || *sensor.MqttTopic != data[0] || sensor.MqttPath == nil {
if sensor.MqttTopic == nil || sensor.MqttPath == nil {
fmt.Printf("Skipping %s because it's missing topic or path", sensor.Name)
continue
}
if *sensor.MqttTopic != data[0] {
continue
}

View File

@ -13,7 +13,7 @@ type SensorsService struct {
func (s *SensorsService) GetList() ([]models.SensorItem, error) {
sensors := []models.SensorItem{}
err := s.ctx.DB.Select(&sensors, "SELECT id, name, type, mqtt_broker_id, mqtt_topic, auth_key, last_contact_at FROM sensors")
err := s.ctx.DB.Select(&sensors, "SELECT id, name, type, mqtt_broker_id, mqtt_topic, mqtt_path, auth_key, last_contact_at FROM sensors")
if err != nil {
return nil, err