]> mj.ucw.cz Git - home-hw.git/commitdiff
InfluxDB: New attributes for boiler status and clock
authorMartin Mares <mj@ucw.cz>
Mon, 27 Jul 2020 11:02:09 +0000 (13:02 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 27 Jul 2020 11:02:09 +0000 (13:02 +0200)
influx/burrow-influx.c

index 611f8da064f4b48a26a804cc8d21d6f782a26c16..3105d45a691470c798352ecaa545aae9f74759a2 100644 (file)
@@ -35,6 +35,7 @@ struct attr {
        const char *value_name;
        const char *topic;
        uint timeout;
+       bool is_string;
 };
 
 static const struct attr attr_table[] = {
@@ -244,6 +245,19 @@ static const struct attr attr_table[] = {
                .topic = "burrow/heating/water/active",
                .timeout = 660,
        },
+       {
+               .metric = "heating_error",
+               .value_name = "err",
+               .topic = "burrow/heating/error",
+               .timeout = 300,
+       },
+       {
+               .metric = "heating_clock",
+               .value_name = "t",
+               .topic = "burrow/heating/clock",
+               .timeout = 660,
+               .is_string = true,
+       },
 };
 
 /*** MQTT ***/
@@ -452,7 +466,10 @@ int main(int argc UNUSED, char **argv)
                                        continue;
                        }
 
-                       bprintf(f, "%s %s=%s\n", a->metric, a->value_name, val);
+                       if (!a->is_string)
+                               bprintf(f, "%s %s=%s\n", a->metric, a->value_name, val);
+                       else
+                               bprintf(f, "%s %s=\"%s\"\n", a->metric, a->value_name, val);
                }
                influx_write_flush();
                sleep(INFLUX_INTERVAL);