Open Microfi opened 6 months ago
Hi, can you see the output when you listen to mqtt topic homeassistant/# ? If you should see something like:
{
"command_topic": "homeassistant/sensor/stib5152545152/set",
"device": {
"identifiers": [
"stib5152545152"
],
"name": "STIB SAINT-DENIS - BUS 54 - 5152"
},
"device_class": "duration",
"icon": "mdi:bus",
"json_attributes_template": "{{value_json | default('') | to_json}}",
"json_attributes_topic": "homeassistant/sensor/stib5152545152/attribute",
"state_topic": "homeassistant/sensor/stib5152545152/state",
"unique_id": "stib5152545152",
"unit_of_measurement": "min",
"value_template": "{{value_json.arrival}}"
}
Also, check your config.yaml file. It seems that I missed a trailing '/' after mqtt_topic: 'homeassistant/sensor/'
Hi Danito,
I just tried running your script in a LXC in Proxmox. It seems to be working fine and it's connecting to my MQTT broker, but my sensors don't seem to get autodiscovered in HA ...
This is the output of your script:
{'13': {'pointid': '1303', 'lineid': '13', 'passingtimes': [{'destination': {'fr': 'UZ-VUB', 'nl': 'UZ-VUB'}, 'expectedArrivalTime': '2024-05-01T15:46:00+02:00', 'lineId': '13'}, {'destination': {'fr': 'UZ-VUB', 'nl': 'UZ-VUB'}, 'expectedArrivalTime': '2024-05-01T16:07:00+02:00', 'lineId': '13'}]}, '87': {'pointid': '1303', 'lineid': '87', 'passingtimes': [{'destination': {'fr': 'BEEKKANT', 'nl': 'BEEKKANT'}, 'expectedArrivalTime': '2024-05-01T15:44:00+02:00', 'lineId': '87'}, {'destination': {'fr': 'BEEKKANT', 'nl': 'BEEKKANT'}, 'expectedArrivalTime': '2024-05-01T15:54:00+02:00', 'lineId': '87'}]}} {'13': {'pointid': '2519', 'lineid': '13', 'passingtimes': [{'destination': {'fr': 'ETANGS NOIRS', 'nl': 'ZWARTE VIJVERS'}, 'expectedArrivalTime': '2024-05-01T15:47:00+02:00', 'lineId': '13'}, {'destination': {'fr': 'ETANGS NOIRS', 'nl': 'ZWARTE VIJVERS'}, 'expectedArrivalTime': '2024-05-01T15:53:00+02:00', 'lineId': '13'}]}, '87': {'pointid': '2519', 'lineid': '87', 'passingtimes': [{'destination': {'fr': 'SIMONIS', 'nl': 'SIMONIS'}, 'expectedArrivalTime': '2024-05-01T15:54:00+02:00', 'lineId': '87'}, {'destination': {'fr': 'SIMONIS', 'nl': 'SIMONIS'}, 'expectedArrivalTime': '2024-05-01T16:08:00+02:00', 'lineId': '87'}]}} {'53': {'pointid': '2508', 'lineid': '53', 'passingtimes': [{'destination': {'fr': 'WESTLAND SHOP.', 'nl': 'WESTLAND SHOP.'}, 'expectedArrivalTime': '2024-05-01T15:44:00+02:00', 'lineId': '53'}, {'destination': {'fr': 'WESTLAND SHOP.', 'nl': 'WESTLAND SHOP.'}, 'expectedArrivalTime': '2024-05-01T15:53:00+02:00', 'lineId': '53'}]}} {'53': {'pointid': '2571', 'lineid': '53', 'passingtimes': [{'destination': {'fr': 'HOP. MILITAIRE', 'nl': 'MILITAIR HOSP.'}, 'expectedArrivalTime': '2024-05-01T15:47:00+02:00', 'lineId': '53'}, {'destination': {'fr': 'HOP. MILITAIRE', 'nl': 'MILITAIR HOSP.'}, 'expectedArrivalTime': '2024-05-01T15:57:00+02:00', 'lineId': '53'}]}} Retrieving STIB-MIVB realtime data {"line_ids": ["53", "87", "13"], "waiting_times": {"2571": {"53": {"pointid": "2571", "lineid": "53", "passingtimes": [{"destination": {"fr": "HOP. MILITAIRE", "nl": "MILITAIR HOSP."}, "expectedArrivalTime": "2024-05-01T15:47:00+02:00", "lineId": "53"}, {"destination": {"fr": "HOP. MILITAIRE", "nl": "MILITAIR HOSP."}, "expectedArrivalTime": "2024-05-01T15:57:00+02:00", "lineId": "53"}]}}, "1303": {"87": {"pointid": "1303", "lineid": "87", "passingtimes": [{"destination": {"fr": "BEEKKANT", "nl": "BEEKKANT"}, "expectedArrivalTime": "2024-05-01T15:44:00+02:00", "lineId": "87"}, {"destination": {"fr": "BEEKKANT", "nl": "BEEKKANT"}, "expectedArrivalTime": "2024-05-01T15:54:00+02:00", "lineId": "87"}]}, "13": {"pointid": "1303", "lineid": "13", "passingtimes": [{"destination": {"fr": "UZ-VUB", "nl": "UZ-VUB"}, "expectedArrivalTime": "2024-05-01T15:46:00+02:00", "lineId": "13"}, {"destination": {"fr": "UZ-VUB", "nl": "UZ-VUB"}, "expectedArrivalTime": "2024-05-01T16:07:00+02:00", "lineId": "13"}]}}, "2519": {"87": {"pointid": "2519", "lineid": "87", "passingtimes": [{"destination": {"fr": "SIMONIS", "nl": "SIMONIS"}, "expectedArrivalTime": "2024-05-01T15:54:00+02:00", "lineId": "87"}, {"destination": {"fr": "SIMONIS", "nl": "SIMONIS"}, "expectedArrivalTime": "2024-05-01T16:08:00+02:00", "lineId": "87"}]}, "13": {"pointid": "2519", "lineid": "13", "passingtimes": [{"destination": {"fr": "ETANGS NOIRS", "nl": "ZWARTE VIJVERS"}, "expectedArrivalTime": "2024-05-01T15:47:00+02:00", "lineId": "13"}, {"destination": {"fr": "ETANGS NOIRS", "nl": "ZWARTE VIJVERS"}, "expectedArrivalTime": "2024-05-01T15:53:00+02:00", "lineId": "13"}]}}, "2508": {"53": {"pointid": "2508", "lineid": "53", "passingtimes": [{"destination": {"fr": "WESTLAND SHOP.", "nl": "WESTLAND SHOP."}, "expectedArrivalTime": "2024-05-01T15:44:00+02:00", "lineId": "53"}, {"destination": {"fr": "WESTLAND SHOP.", "nl": "WESTLAND SHOP."}, "expectedArrivalTime": "2024-05-01T15:53:00+02:00", "lineId": "53"}]}}}} Sending data for STIB RIETHUISEN - BUS 13 - 1303: 1 stib1303131303 Sending data for STIB RIETHUISEN - BUS 87 - 1303: -1 stib1303871303 Sending data for STIB RIETHUISEN - BUS 13 - 2519: 2 stib2519132519 Sending data for STIB RIETHUISEN - BUS 87 - 2519: 9 stib2519872519 Sending data for STIB RIETHUISEN - BUS 53 - 2508: -1 stib2508532508 Sending data for STIB RIETHUISEN - BUS 53 - 2571: 2 stib2571532571 1
I also notice that your script seems to be opening/closing the MQTT connection at regular intervals, but maybe this is the expected behaviour:
1714571869: New client connected from 192.168.2.103:45445 as stib-mqtt-192 (p2, c1, k60, u'homeassistant'). 1714571869: New connection from 192.168.2.103:51255 on port 1883. 1714571869: New connection from 192.168.2.103:45181 on port 1883. 1714571869: Client stib-mqtt-192 closed its connection. 1714571869: New client connected from 192.168.2.103:51255 as stib-mqtt-192 (p2, c1, k60, u'homeassistant'). 1714571869: Client stib-mqtt-192 already connected, closing old connection. 1714571869: New client connected from 192.168.2.103:45181 as stib-mqtt-192 (p2, c1, k60, u'homeassistant'). 1714571869: Client stib-mqtt-192 closed its connection.
Could you maybe point me in the correct direction in order to solve my issue? Thank you in advance!