Solar Flux sensor to detect solar flares

I had some power quality issues (UPS tripping) and 2.4GHz WiFi issues this morning at 10:00am (UTC+10) which turned out to be due to a solar flare, so I hacked together some stuff to pull solar flux data from NOAA into Home Assistant.

I created an API that pulls from NOAA and returns the latest datapoints: https://github.com/chendo/solar-flux-api

I deployed this to Fly.io, which is located at https://solar-flux-api.fly.dev/

Here is the configuration if you want to pull this data into your instance (thanks @tom_l!)

rest:
  - resource: https://solar-flux-api.fly.dev/solar-flux.json
    scan_interval: 60
    sensor:
      - name: Solar Flux Short
        value_template: "{{ value_json.flux_short * 1000000000 }}"
        unit_of_measurement: "nW/m2"
        
      - name: Solar Flux Long
        value_template: "{{ value_json.flux_long * 1000000000 }}"
        unit_of_measurement: "nW/m2"

Screenshot of WiFi issues (UTC+10):

image

Solar flare graph (UTC+0):
image

4 Likes

If you use the rest integration rather than the rest sensor platform you can get both sensors with just the one call to the resource:

rest:
  - resource: https://solar-flux-api.fly.dev/solar-flux.json
    scan_interval: 60
    sensor:
      - name: Solar Flux Short
        value_template: "{{ value_json.flux_short * 1000000000 }}"
        unit_of_measurement: "nW/m2"
        
      - name: Solar Flux Long
        value_template: "{{ value_json.flux_long * 1000000000 }}"
        unit_of_measurement: "nW/m2"
1 Like

Oh neat! Will update the code. Thanks!

Hi @chendo - This is awesome! I have been wanting to configure my own alerts for flares, CMEs, solar wind, etc. with python, but after seeing this I might just add it all to HA!

Any chance you could share your graph card config? I’m not sure how you are getting the current and historical values at the bottom?

And forgive my ignorance, but what’s the reason you deployed your own API on fly.io, rather than using the data directly from the NOAA source?

Thanks so much for sharing this!

That screenshot is from a website that I was using initially to test my theory; it’s not a graph card.

The original data source was unwieldy to get data out into Home Assistant, so the API merely grabs the latest values and exposes them to make it a lot easier

Hi, thanks for the code but how can I know that a Flare just happened with this code?
I would be happy to know is when a Flare occures, know it’s magnitude to classify it as a C, M or X Flare/state.
Can you help @chendo ?

1 Like