diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | mqtt-client/mqtt-client.py | 9 | ||||
-rw-r--r-- | prometheus/prometheus.yml | 5 |
3 files changed, 19 insertions, 3 deletions
@@ -27,3 +27,11 @@ Looking for the Mikrotik POE usage monitor/exporter? That's in [`mikrotik.py`](/ You must enable SNMP in the Omada controller with the community string `tplink`:  + +Moreover mikrotik switches must be set up with an appropriate SSH key pair so they can be polled through SSH + +## MQTT setup + +We are using a [Tasmota-flashed zigbee coordinator](https://www.aliexpress.com/item/1005005254486268.html) to transmit zigbee messages to our MQTT castor, and [Tasmota-flashed plugs](https://www.aliexpress.com/item/1005008427641332.htm) for logging power from the wall over MQTT. Both must be configured with an appropriate friendlyname and told access the MQTT castor. + +  diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index f81d1d6..602774b 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -98,8 +98,6 @@ class MQTTClient: friendlyname = fields.pop("Name") del fields["Device"] print("Zigbee device '%s' reported: %s" % (friendlyname, str(fields))) - if "Read" not in fields.keys(): - self.append_influxdb(fields, "zigbee", {"friendlyname": friendlyname, "id": zigbee_id}) if zigbee_id == "0x7327" and friendlyname == "TVButton" and "Power" in fields.keys(): if fields["Power"] == 2: @@ -113,9 +111,11 @@ class MQTTClient: self.toggle_plug("TasmotaHarveyPC") if "Humidity" in fields.keys(): + fields["Humidity"] = float(fields["Humidity"]) self.humidity_prom.labels(location = friendlyname).set(fields["Humidity"]) elif "Temperature" in fields.keys(): - self.temperature_prom.labels(location = friendlyname).set(fields["Temperature"]) + fields["Temperature"] = float(fields["Temperature"]) + self.temperature_prom.labels(location = friendlyname).set(fields["Temperature"]) elif "ZoneStatus" in fields.keys() and "Contact" in fields.keys(): if fields["ZoneStatus"] == 1 and fields["Contact"] == 1: self.doorsensor_prom.labels(location = friendlyname).state("opened") @@ -123,6 +123,9 @@ class MQTTClient: elif fields["ZoneStatus"] == 0 and fields["Contact"] == 0: self.doorsensor_prom.labels(location = friendlyname).state("closed") + if "Read" not in fields.keys(): + self.append_influxdb(fields, "zigbee", {"friendlyname": friendlyname, "id": zigbee_id}) + def set_plug(self, friendlyname, payload): t = "cmnd/TasmotaPlug/%s/Power" % friendlyname self.mqttc.publish(t, payload = payload) diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index efa9871..ff25a9b 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -13,3 +13,8 @@ scrape_configs: static_configs: - targets: - mqtt_client:8000 + - job_name: pfsense-node-exporter + static_configs: + - targets: + - 192.169.69.1:9100 + |