Sql integration, scan_interval

Good evening. Now that configuration of sql in configuration.yaml is deprecated and I’m supposed to configure it through an integration, how am I supposed to set scan_interval. I had that set to 1200 in yaml because I only wanted a complex query to burden my database every 20 minutes.

2 Likes

I have a similar problem (I think) where I lost the update of some database sensors (MariaDB). I guess it happened on update to Home Assistant Core 2022.5.0; Home Assistant Supervisor 2022.05.0.

@fluxsmith Jonathon.

Where did you read this ? In any case if the YAML is not taken into account I totally agree that there is NO OBVIOUS WAY to set the scan interval in the Integration Interface.

It’s in the release notes for 2022.5.0, also in the logs after upgrading. I wish they wouldn’t take yaml away, and especially not until the UI can fully replace it.

1 Like

Typically Home Assistant, changing the way something is done without preserving previous functionality.

I got this in my log:

Configuration of the SQL sensor platform in YAML is deprecated and will be removed in Home Assistant 2022.6; Your existing configuration has been imported into the UI automatically and can be safely removed from your configuration.yaml file

I have this in my config.yaml:

  - platform: sql
    scan_interval: 300 
    queries: 
      - name: DB Size Total
        query: "SELECT ROUND(page_count * page_size / 1024 / 1024, 1) as size FROM pragma_page_count(), pragma_page_size()"
        column: "size"
        unit_of_measurement: MB

And guess what, the scan_interval property, that is inherited for all sensor types, and is (was) supported before, no longer exist in the GUI. What is even worse, though, is that when it was automatically imported, the scan_interval setting was NOT imported / preserved, despite warning in the log saying it (i.e. the sensor) was imported.

I had a very expensive SQL query that I previously ran only once per hour. And the value also does not make sense to update more frequently than that anyway. After the automatic migration (that did not mention that it was a breaking change - removing existing functionality) the expensive SQL query was suddenly running once per minut or even more often. Causing a lot of performance issues with Home Assistant.

What I’m saying; it isn’t just the GUI that is missing; the entire functionality was removed.

1 Like

Not sure if you have solved this, but it is most definately back in YAML, but with new structure;

have a looka at my yaml which also adds state_class: measurement, so that there are stored long-term statistics and you can show the longer term data in for example history explorer card :slight_smile: