X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=influx%2Fburrow-influx.c;h=ce5baf247e4d88ea230f1f07e11a70223db0153c;hb=ef81a4d74227ac8fb82b0d153ae85b25cfc7b18b;hp=611f8da064f4b48a26a804cc8d21d6f782a26c16;hpb=79b8ce624eb72198697c1bb0a7eda4747cf14fb6;p=home-hw.git diff --git a/influx/burrow-influx.c b/influx/burrow-influx.c index 611f8da..ce5baf2 100644 --- a/influx/burrow-influx.c +++ b/influx/burrow-influx.c @@ -35,6 +35,7 @@ struct attr { const char *value_name; const char *topic; uint timeout; + bool is_string; }; static const struct attr attr_table[] = { @@ -59,9 +60,9 @@ static const struct attr attr_table[] = { .topic = "burrow/temp/garage" }, { - .metric = "temp,where=kitchen", + .metric = "temp,where=terarium", .value_name = "t", - .topic = "burrow/temp/kitchen" + .topic = "burrow/temp/terarium" }, { .metric = "rh,where=ursarium", @@ -123,12 +124,11 @@ static const struct attr attr_table[] = { .value_name = "pwm", .topic = "burrow/air/exchanger-fan" }, -#if 0 { .metric = "loft_fan", + .value_name = "on", .topic = "burrow/loft/fan" }, -#endif { .metric = "water_circ", .value_name = "on", @@ -244,6 +244,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 ***/ @@ -420,7 +433,10 @@ int main(int argc UNUSED, char **argv) if (mosquitto_will_set(mosq, "status/influx", 4, "dead", 0, true) != MOSQ_ERR_SUCCESS) die("Mosquitto: unable to set will"); - if (mosquitto_connect_async(mosq, "10.32.184.5", 1883, 60) != MOSQ_ERR_SUCCESS) + if (mosquitto_tls_set(mosq, "/etc/burrow-mqtt/ca.crt", NULL, "/etc/burrow-mqtt/client.crt", "/etc/burrow-mqtt/client.key", NULL) != MOSQ_ERR_SUCCESS) + die("Mosquitto: unable to set TLS parameters"); + + if (mosquitto_connect_async(mosq, "burrow-mqtt", 8883, 60) != MOSQ_ERR_SUCCESS) die("Mosquitto: connect failed"); if (mosquitto_loop_start(mosq)) @@ -452,7 +468,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);