Rest using request for status of a given sensor

Hey guys!!! I really need your help. I have a Rest in my project with a scan interval of 1800 sec. I use an API that is paid for each request I make, so every 1800 sec, it charges me. I would like to know if there is any possibility of changing the scan interval per request, that is, every time a certain sensor changes status, it requests it?

Set the scan interval to a very large number.

Create an automation to call the homeassistant.update_entity service to update your sensor when you want to. This could be an interval or even an input boolean that would set itself off and update the entity.

I appreciate the help. The problem is that the information is extracted externally, that is, it searches from an external website through a JSON page. I have the frigate, and with it an automation that records a vehicle’s license plate. With the license plate number I access the API that provides me with complete information about the vehicle. I would like it to only provide it to me once for each plate change. Otherwise, I would have to set a short scan interval to check all the time and it would cost me more.

The service update_entity will update the REST when called which would update the sensor. I do not understand the problem.

Now I understand, I’m going to do the tests to see if it works. Thank you very much for the tip @kbrown01

In this case, I have 10 sensors, would it be 10 requests?

I do not see your sensors. If you have 10 Rest sensors calling the same API to get 10 different things … then possibly you have not thought it through especially if they are call the same URL.

Then you have one, and you extract the data you want for attributes of the sensor. And you put all the data into a JSON/YAML object in the sensor.

For example. I have a sensor that records the Strength of Schedule for the NHL. One REST query gets the data, and all things underneath that draw data from the sensor.

I do not have a sensor for every team or every day (or worse, every team and every day). It changes once a week, it is called at one specific time on Monday am. It updates and that data is for the week. But I use a time trigger, yours could use any trigger it likes.

This is exactly what I need, but I’m not able to materialize it.

my rest.yaml

- scan_interval: 99999
resource_template: https://wdapi2.com.br/consulta/{{ states(‘sensor.placa_t’) }}/mytoken
sensor:
- name: dados_veiculo
value_template: ‘OK’
json_attributes:
- MARCA
- MODELO
- ano
- anoModelo
- cor
- chassi
- cilindradas
- combustivel
- uf_placa
- municipio
- restricao_1
- restricao_2
- restricao_3
- restricao_4
- situacao
from this information I would extract the values ​​for the sensors

PLease use the code icon to post the information. It should look like this:

- platform: rest
  scan_interval: 36000
  name: NHL Standings
  unique_id: sensor.nhl_standings
  resource: https://site.web.api.espn.com/apis/v2/sports/hockey/nhl/standings?seasontype=2&type=0&level=3
  value_template: "{{ now() }}"
  json_attributes:
      - children

Otherwise we are all guessing at what you have done.

What error are you getting?

Thanks @kbrown01 , it worked. Now update the sensor based on status. I appreciate your help…