Closed runningman84 closed 2 years ago
Hello,
Weird. There is nothing wrong with your payload nor your topic.
I've tried a quick test and parsing is working:
topic = "zigbee2mqtt/living_room/tv_left/plug"
payload = '{"current":0.11,"energy":287.04,"last_seen":"2022-05-26T19:58:11.525Z","linkquality":162,"power":17,"state":"ON","voltage":239}'
parsed_topic, parsed_payload = _parse_message(topic, payload)
assert parsed_topic == "zigbee2mqtt_living_room_tv_left_plug"
assert parsed_payload == {
"current": 0.11,
"energy": 287.04,
"last_seen": "2022-05-26T19:58:11.525Z",
"linkquality": 162,
"power": 17,
"state": "ON",
"voltage": 239,
}
_parse_metrics(parsed_payload, parsed_topic, "zigbee2mqtt_")
rich.print(parsed_payload)
rich.print(prom_metrics)
Result :
pytest -vvv -s tests/functional/test_parse_message.py::test_parse_message_issue
tests/functional/test_parse_message.py::test_parse_message_issue {'current': 0.11, 'energy': 287.04, 'last_seen': '2022-05-26T19:58:11.525Z', 'linkquality': 162, 'power': 17, 'state': 'ON', 'voltage': 239}
{
'mqtt_zigbee2mqtt_current': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_current),
'mqtt_zigbee2mqtt_energy': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_energy),
'mqtt_zigbee2mqtt_linkquality': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_linkquality),
'mqtt_zigbee2mqtt_power': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_power),
'mqtt_zigbee2mqtt_state': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_state),
'mqtt_zigbee2mqtt_voltage': prometheus_client.metrics.Gauge(mqtt_zigbee2mqtt_voltage)
}
PASSED
So here my questions for you:
INFO:mqtt-exporter:listening to "zigbee2mqtt"
message looping a little in the logs, or just appearing once? Btw. I have created a helm chart for your project
Nice! thanks
Please try with this commit I pushed in master branch: https://github.com/kpetremann/mqtt-exporter/commit/a652f202c259b3bc5a6207e9ddfa7b76374c4591
It will provide the reason of connection failure if any.
Some additional hints...
I see this log in the mosquitto broker:
mosquitto 1653650049: New client connected from 10.42.0.229 as auto-C07CCC48-4D94-E384-CB31-3F1CFF248452 (p2, c1, k60).
Even in debug mode there is only the single log line:
INFO:mqtt-exporter:listening to "zigbee2mqtt"
Auth is disabled in mosquitto.
I will try your latest image later this afternoon.
oh I did not see you set MQTT_TOPIC to zigbee2mqtt
. With this, you only subscribe to the exact topic zigbee2mqtt
.
It does not match with the different topics from zigbee2mqtt: topic 'zigbee2mqtt/living_room/tv_left/plug', etc...
Try with: MQTT_TOPIC="zigbee2mqtt/#"
perfect, I changed to topic as suggest and it seems to work fine now!
I have tried the exporter in my k8s setup. But it does not produce any device metrics.
This is the zigbee2mqtt log:
This is the container log:
This is the container output:
Btw. I have created a helm chart for your project: https://github.com/k8s-at-home/charts/pull/1584