Command_line sensor - Update only on HA reload

Hello,

I have a command_line sensor which is used to retrieve information from a Meteo France API using curl. The objective is to retrieve the content and push it as json to two attributes as you can see below.
I then use these attributes for some other sensors and automations.

Here is the command_line sensor code :

command_line:
  - sensor:
      name: niveaux_vigilances
      unique_id: niveaux_vigilancesa
      scan_interval: 1800
      command: >
        curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours" -H "accept: */*" -H "apikey: xxxxx==" |  jq '{ "today": .product.periods[0].timelaps.domain_ids, "tomorrow": .product.periods[1].timelaps.domain_ids }'
      json_attributes:
        - today
        - tomorrow

My issue is that this command_line sensor only updates at HA reload.
It does not update at periodic intervall as I would like using the scan_interval.

I just verfied when writing this post, and the current content of this sensor does not fit the reality returned by the API ; it stills contains the value from yesterday when I restarted HA.

Thank you for your help

You could always set up an automation to call it at the required frequency if no-one can explain why it’s stopped working.

There is a large post on the French forum on alerts a.o. covering this one, from that you can see that it does not only update at HA start (else your setup is wrong) but it is very (!) flaky in availability. Mine seems to drop a few times a day

Use a trigger-based sensor template with a time_pattern trigger. You can execute the command in the action: block and reference the output in the state: definition via a variable.