home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.62k stars 30.78k forks source link

RESTful sensor update to scan_interval not respected without full restart #101899

Closed jj-csg closed 1 month ago

jj-csg commented 1 year ago

The problem

After updating the scan_interval for a RESTful sensor and performing a YAML reload via the 'Developer tools' UI, it still retains the previous setting (while all other configuration updates to the sensor applies without issue). A full HA restart is necessary for the new scan_interval to apply.

What version of Home Assistant Core has the issue?

core-2023.10.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

rest

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sensor.rest

Diagnostics information

No response

Example YAML snippet

- platform: rest
    name: openai_completion
    resource: https://api.openai.com/v1/chat/completions
    method: POST
    headers:
      Content-Type: application/json
      Authorization: !secret openai_api_auth
    payload: !secret openai_payload
    value_template: "{{ value_json.choices[0].message.content }}"
    scan_interval: 999999999  # switching this to 30 requires full restart to apply
    # scan_interval: 30
  - platform: rest
    resource: http://api.openmetrolinx.com/OpenDataAPI/api/V1/Stop/NextService/UN
    params: 
      key: !secret metrolinx_api_key
    name: Next Return Train
    json_attributes_path: "$.NextService.Lines[?(@.LineCode=='XX')]"
    json_attributes:
      - DirectionName
      - ScheduledDepartureTime
      - ScheduledPlatform
      - UpdateTime
    value_template: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
    scan_interval: 30

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

rest documentation rest source

issue-triage-workflows[bot] commented 10 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

nsuan commented 10 months ago

I am still seeing this as of 2023.12.3

2620:135:5000:beef:7ac7:849d:7fac:5400 - - [15/Jan/2024:02:55:15 -0500] "GET /daily-prc.json HTTP/1.1" 200 76245 "-" "HomeAssistant/2023.12.3 httpx/0.25.0 Python/3.11"
2620:135:5000:beef:7ac7:849d:7fac:5400 - - [15/Jan/2024:02:56:21 -0500] "GET /daily-prc.json HTTP/1.1" 200 76905 "-" "HomeAssistant/2023.12.3 httpx/0.25.0 Python/3.11"
2620:135:5000:beef:7ac7:849d:7fac:5400 - - [15/Jan/2024:02:58:21 -0500] "GET /daily-prc.json HTTP/1.1" 200 78115 "-" "HomeAssistant/2023.12.3 httpx/0.25.0 Python/3.11"
2620:135:5000:beef:7ac7:849d:7fac:5400 - - [15/Jan/2024:03:00:21 -0500] "GET /daily-prc.json HTTP/1.1" 200 79545 "-" "HomeAssistant/2023.12.3 httpx/0.25.0 Python/3.11"
2620:135:5000:beef:7ac7:849d:7fac:5400 - - [15/Jan/2024:03:02:21 -0500] "GET /daily-prc.json HTTP/1.1" 200 80755 "-" "HomeAssistant/2023.12.3 httpx/0.25.0 Python/3.11"

02:56 is when I updated it to poll every 60 seconds:

[core-ssh ~]$ grep -C 5 daily-prc.json  config/configuration.yaml
  - platform: rest
    scan_interval: 60
    unique_id: ercot_status
    icon: mdi:transmission-tower
    name: Ercot Status
    resource: "http://teldoren.int.nonexiste.net/daily-prc.json"
    value_template: "{{value_json.current_condition.state}}"
    json_attributes_path: "$.current_condition"
    json_attributes:
      - energy_level_value
      - title
[core-ssh ~]$ TZ=EST ls -lh  config/configuration.yaml
-rw-r--r--    1 root     root        3.3K Jan 15 02:56 config/configuration.yaml

The only changelog entry i saw related to the RESTful sensor was #105358 and does not look like it changed any code that would solve the issue, so I am adding this comment.

issue-triage-workflows[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

MacDada commented 7 months ago

@nsuan thumb down on bot message does nothing xd

timr49 commented 4 months ago

Reloading of scan_interval is supported by the RESTful integration as opposed to the RESTful Sensor integration i.e. use:

rest:
  resource: ...
  scan_interval: ...
  sensor:
    - name: ...
      value_template: ...

rather than:

sensor:
  - platform: rest
    name: ...
    resource: ...
    value_template: ...
    scan_interval: ...
issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.