Afficher horaires de bus

Montre moi tes logs, si t’as bien ajouté les debug il devrait avoir des références… J’ai fait des erreurs par expres pour te montre

desolé mais je ne trouve aucune erreur relative à ca =/

Dans ce cas à t’as pas bien ajouté le sensor rest ou t’as pas bien ajouté le debug dans logger… il faut que tu essaie avec des sensors plus simple, je ne peux pas t’aider plus que ça.

p.e. l’exemple avec http://ip.jsontest.com
RESTful Sensor - Home Assistant (home-assistant.io)

2023-04-10 17:12:59.776 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 17:13:54.673 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

Mieux, et les détails des logs?
Qu’est ce que sensor bus_c18a… montre?



aucune entité trouvé

Encore… les LOGS détaillées ??

Je ne peut pas copier coller le log car il est trop long

Juste les lignes avec ‹ rest › suffisent… avec et sans (!) erreurs

2023-04-10 18:24:39.902 INFO (MainThread) [homeassistant.setup] Setting up rest

2023-04-10 18:24:39.903 INFO (MainThread) [homeassistant.setup] Setup of domain rest took 0.0 seconds

2023-04-10 18:24:39.963 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:24:39.965 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:24:42.741 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet: Server disconnected without sending a response.; Retrying in background in 30 seconds

2023-04-10 18:24:49.019 INFO (MainThread) [custom_components.hacs] Restore started

2023-04-10 18:24:50.815 INFO (MainThread) [custom_components.hacs] Restore done

2023-04-10 18:25:00.507 INFO (MainThread) [custom_components.versatile_thermostat.climate] VersatileThermostat-Salon VersaTherm - restored state is target_temp=21.0, preset_mode=none, hvac_mode=off

2023-04-10 18:25:00.706 INFO (MainThread) [custom_components.versatile_thermostat.climate] VersatileThermostat-Chambre VersaTherm - restored state is target_temp=22.5, preset_mode=none, hvac_mode=off

2023-04-10 18:25:45.031 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:25:45.155 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:26:46.840 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:26:46.847 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:28:16.870 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:28:16.877 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:30:16.920 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:30:16.938 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

await proto.restore()

File « /usr/local/lib/python3.10/asyncio/base_events.py », line 268, in restore

await proto.restore()

File « /usr/local/lib/python3.10/asyncio/base_events.py », line 268, in restore

2023-04-10 18:32:46.974 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:32:46.981 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:35:47.006 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:35:47.015 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:38:47.039 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:38:47.046 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:40:53.594 INFO (SyncWorker_9) [homeassistant.loader] Loaded rainforest_eagle from homeassistant.components.rainforest_eagle

2023-04-10 18:41:47.074 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:41:47.092 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

2023-04-10 18:44:47.133 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

2023-04-10 18:44:47.143 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.69:8123/local/lyon_c18A_2384.json

await proto.restore()

File « /usr/local/lib/python3.10/asyncio/base_events.py », line 268, in restore

OK, je pense qu’il ne peut pas acceder le fichier correctement
normalement j’attend ça

2023-04-10 18:04:52.371 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.20:8124/local/lyon_c18A_2384.json
2023-04-10 18:04:52.396 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: [
{
"coursetheorique": "C18A-0377M:2:1:20",
"delaipassage": "19h04",
"direction": "Hôtel de Ville L. Pradel",
...
...
...

J’ai pas des lignes avec ‹ setting up ›…comme:

2023-04-10 18:44:47.133 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest

Donc j’ai l’impression que le sensor n’est pas bien composé mais ça ne doit pas être si compliqué et je ne voix rien de curieux dans ton copie/colle si-dessus … c’est :scream: :scream: :scream:

Est-ce que tu peux m’envoyer ton configuration.yaml ? (session privé)

EDIT: de ma part, pas de pression, … j’ai plus de temps jusq’a le w/e … des voyages a faire

oui parfaitement joignable

Petite MAJ
Chez ZOU MaregionSud, le gtfs_rt (temps reeel) n’est plus via fichier json. Leur format à changé pour protobuf (de-facto standard). Je suis en train d’analyser des solutions déjà dispo pour HA

Hello,

Merci pour ton partage, cela fonctionne parfaitement chez moi.
J’aurai aimé aller plus loin en allant chercher le bus suivant, mais je ne vois pas comment faire :frowning:
As-tu une idée ? Ou est-ce que tu l’a déjà implémenté ?

Merci

J’ai finalement pu trouver une solution :

- platform: rest
  name: bus_1er
  scan_interval: 60
  resource: "http://192.168.xx.xx:8123/local/lyon.json"
  value_template: >
       {% if value_json is defined %}
          {% set y = value_json | count %}
          {% set ns = namespace(val="--:--") %}
            {% if y == 6 %}
              {% for x in range(0,6) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 5 %}
              {% for x in range(0,5) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 4 %}
              {% for x in range(0,4) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 3 %}
              {% for x in range(0,3) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 3 %}
              {% for x in range(0,2) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX%}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 2 %}
              {% for x in range(0,2) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 1 %}
              {% for x in range(0,1) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
          {% else %}
           --:--
          {% endif %}

- platform: rest
  name: bus_2eme
  scan_interval: 60
  resource: "http://192.168.XX.XX:8123/local/lyon.json"
  value_template: >
       {% if value_json is defined %}
          {% set y = value_json | count %}
          {% set ns = namespace(val="--:--") %}
            {% if y == 6 %}
              {% for x in range(0,5) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 5 %}
              {% for x in range(0,4) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 4 %}
              {% for x in range(0,3) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 3 %}
              {% for x in range(0,2) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == 2080 %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 2 %}
              {% for x in range(0,1) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
          {% else %}
           --:--
          {% endif %}
- platform: rest
  name: bus_3eme
  scan_interval: 60
  resource: "http://192.168.XX.XX:8123/local/lyon.json"
  value_template: >
       {% if value_json is defined %}
          {% set y = value_json | count %}
          {% set ns = namespace(val="--:--") %}
            {% if y == 6 %}
              {% for x in range(0,4) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 5 %}
              {% for x in range(0,3) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 4 %}
              {% for x in range(0,2) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
            {% if y == 3 %}
              {% for x in range(0,1) %} 
              {% if value_json[x]["ligne"] == "XX" and value_json[x]["id"] == XX %}
                  {% set ns.val = as_local(as_datetime(value_json[x]["heurepassage"])).strftime("%H:%M") %}
              {% endif %}
              {% endfor %}
              {{ns.val}}
            {% endif %}
          {% else %}
           --:--
          {% endif %}

Il y a surement un travail afin de le rendre plus dynamique en fonction du nombre d’entrée présente dans le fichier .json mais pour le moment j’en ai compté 6 max.

Essayer comme ça pour rendre la première groupe dans le fichier

  - platform: rest
    name: bus_c18a_2384_1
    scan_interval: 180
    resource: http://192.168.1.20:8124/local/lyon_c18A_2384.json
    device_class: timestamp
    value_template: >
        {{ as_local(as_datetime(value_json.0.heurepassage)) }}

Merci, c’est presque sa, sauf qu’il prend la 1er ligne qui correspond à l’horaire du départ au plus tard et non celui au plus tôt qui lui est en bas de la liste

Le point déntrée est peut-être tri différent (reverse ?)

Surement, malheureusement je ne connais pas la syntaxe :frowning:

C’est dans un de mes posts dessus, enleve le " | reverse " et le tri est par ordre de temps