core: Scrape imports scan_interval timedelta which leads to JSON serialize errors
The problem
2022.7 beta0 throws errors on migrated scrape sensors. Funny enough, the sensor do seem to get setup correctly.
What version of Home Assistant Core has the issue?
core-2022.7.0b0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Scrape
Link to integration documentation on our website
https://www.home-assistant.io/integrations/scrape/
Diagnostics information
No response
Example YAML snippet
# Yaml config that was imported:
- platform: scrape
resource: !secret scrape_url_u
name: "Diesel"
select: ".field--name-field-station-prices .taxonomy-term-Diesel .field--name-field-prices-price-pump"
value_template: "{{ value | replace('€', '') | replace('EUR/L', '') | float | round(3) }}"
unit_of_measurement: €
scan_interval: 3600
- platform: scrape
resource: !secret scrape_url_u
name: "Benzine"
select: ".field--name-field-station-prices .taxonomy-term-Euro95 .field--name-field-prices-price-pump"
value_template: "{{ value | replace('€', '') | replace('EUR/L', '') | float | round(3) }}"
unit_of_measurement: €
scan_interval: 3600
Anything in the logs that might be useful for us?
2022-06-30 13:45:01 ERROR (SyncWorker_0) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[33].options.scan_interval=1:00:00(<class 'datetime.timedelta'>, $.data.entries[34].options.scan_interval=1:00:00(<class 'datetime.timedelta'>
2022-06-30 13:45:01 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.config_entries: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[33].options.scan_interval=1:00:00(<class 'datetime.timedelta'>, $.data.entries[34].options.scan_interval=1:00:00(<class 'datetime.timedelta'>
2022-06-30 13:45:01 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: sensor.scrape, sensor.scrape_2
2022-06-30 13:48:10 ERROR (SyncWorker_3) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[32].options.scan_interval=1:00:00(<class 'datetime.timedelta'>, $.data.entries[33].options.scan_interval=1:00:00(<class 'datetime.timedelta'>
2022-06-30 13:48:10 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.config_entries: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[32].options.scan_interval=1:00:00(<class 'datetime.timedelta'>, $.data.entries[33].options.scan_interval=1:00:00(<class 'datetime.timedelta'>
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (14 by maintainers)
Commits related to this issue
- Filter out CONF_SCAN_INTERVAL from scrape import Fixes #74237 — committed to bdraco/home-assistant by bdraco 2 years ago
already have a PR prepared
I think its coming in via the import
https://github.com/home-assistant/core/blob/f5c6a6be3a0c085c016c3be31985f6bbfd185fc8/homeassistant/components/scrape/sensor.py#L93
The default can be overridden by defining a
SCAN_INTERVAL
in the sensor platform. We should do that and set it to 5 minutes.30 seconds
Correct, disable polling + automation rules is the way to go.
Confirmed fixed in b1, both scrape sensors now also show in core.config_entries
I don’t see a scan_interval in the schema for scrape
https://github.com/home-assistant/core/blob/f5c6a6be3a0c085c016c3be31985f6bbfd185fc8/homeassistant/components/scrape/config_flow.py#L60