Can automations change the scan_interval of sensors?

I’m still pretty new to HA but I didn’t see anything about this in the docs or the cookbook. For an integration like the Aurora sensor, I would like its scan_interval to be something like 4 hours during the day time. Once the sun goes down, the scanning interval should be more like 10 minutes, going back to the long period when the sun goes back up. A followup question to this would be that if an automation can change the scan_interval, when would the new scan occur, after the full old time (4 hours after the last one) or after the new time (10 minutes after the change)?

I don’t believe so. The scan_interval is set in the sensor configuration which can’t be changed on the fly. What you can do is set the scan_interval to the lowest value you require (looks like 4 hours in your case) and then use an automation with homeassistant.update_entity service call that that you turn on at sunset and back off at sunrise to increase the updates at night.

Take note that the initial state of the update automation is set to off.

automation:
  - alias: 'Update Aurora Sensor'
    initial_state: 'off'

    trigger:
      - platform: time_pattern
        minutes: '/10'

    action:
      - service: homeassistant.update_entity
        data:
          entity_id: sensor.my_aurara_sensor

And the automation to turn it on would be something like this

automation:
  - alias: 'Turn On Update Aurora Sensor'

    trigger:
      - platform: sun
        event: sunset

    action:
      - service: automation.turn_on
        entity_id: automation.update_aurora_sensor

And finally an automation to turn it back off.

automation:
  - alias: 'Turn Off Update Aurora Sensor'

    trigger:
      - platform: sun
        event: sunrise

    action:
      - service: automation.turn_off
        entity_id: automation.update_aurora_sensor

C’mon Jason, I know you can combine those two sunrise/sunset automations into one. Go for it!