SmartWeather - Get local weather data combined with AI powered Forecast

//Smart Weather

This project is no longer maintained. It has been replaced by WeatherFlow Weather. Please use this Integration going foward.

This project will still work for a while, but it will no longer be updated.

This is a Custom Integration for Home Assistant. It combines real-time weather readings from a Personal Weather station produced by WeatherFlow and Forecast data also from Weatherflow. It uses the public REST API to pull data from Weatherflow.

GitHub release
hacs_badge

There is currently support for the following device types within Home Assistant:

  • Weather
  • Sensor
  • Binary Sensor

Forecast data can be delivered as hourly or daily data. The Forecast API is still under development from WeatherFlow, so it might change over time. As it is right now, it is very stable and uses the same AI driven model as you can see in there own APP. A BIG thank you to @max-rousseau for doing the initial implementation of this.

Note: If you are a version 1.x user, please read the Upgrade section below before you install this.

Installation

HACS installation

This Integration is part of the default HACS store, so go to the HACS page and search for SmartWeather.

Manual Installation

To add SmartWeather to your installation, create this folder structure in your /config directory:

custom_components/smartweather.

Then drop the following files into that folder:

__init__.py
binary_sensor.py
config_flow.py
const.py
entity.py
manifest.json
sensor.py
strings.json
weather.py
translation (Directory with all files)

Upgrade from version 1.x

Please be aware that the old sensor names and the new sensor names might not match. So if you use this in any Automations, Value Templates, Scripts etc. you will have to change those after adding the new component.

The integration has been rewritten, to use Config Flow as configuration option, so if you have a previous version installed, you must first remove that.

To upgrade perform the below steps in that order:

  1. Edit the yaml files that contain references to smartweather and remove them from the file. (configuration.yaml and were ever you store sensor, binary_sensor and weather configuration)
  2. Remove the Integration from HACS
  3. Restart Home Assistant
  4. When HA is back online go to HACS and install the new Version of SmartWeather
  5. Restart Home Assistant
  6. When HA is back online, go to Configuration and then Integrations, click the + sign in the bottom right, and search for SmartWeather.
  7. Fill out the Configuration Options, and click Submit. You should now have all the Devices and Entities configured.

Configuration

To add SmartWeather to your installation, go to the Integration page inside the configuration panel and add a Personal Weather station by providing the API Key and Station ID of yours or a another Weatherflow Weather Station.

During installation you will have the option of selecting if you want to:

  • have Daily or Hourly based Forecast data
  • use mps or km/h as wind unit if you use the Metric unit system
  • set the interval for updating current data and forecast data

These settings can also be changed after you add the Integration, by using the Options link on the Integration widget.

API Key for SmartWeather

The WeatherFlow REST API requires a API Key, but for personal use, you can use a development key, which you can find here. Please note the restrictions applied. WeatherFlow is silently releasing a new Authorization flow, so in the future there will be an option to obtain your own personal key.

Station ID

If you have your own Smart Weather Station, then you know your Station ID. If you don’t have one, there are a lot of public stations available, and you can find one near you on this link. If you click on one of the stations on the map, you will see that the URL changes, locate the number right after /map/ - this is the Station ID

Sensors

For each Station ID you add, the following sensors are being added to Home Assistant:

  • air_density - Air Density.
  • air_temperature - Outside Temperature.
  • brightness - Brightness in Lux
  • dew_point - Outside Dewpoint.
  • feels_like - Outside Feels Like Temp.
  • heat_index - Outside Heat Index.
  • lightning_strike_last_time - the date and time of last strike.
  • lightning_strike_last_distance - the distance away of last strike.
  • lightning_strike_count - the daily strike count.
  • lightning_strike_count_last_3hr - the strike count last 3hr.
  • precip_accum_last_1hr - Precipition for the Last Hour.
  • precip_accum_local_day - Precipition for the Day.
  • precip_accum_local_yesterday - Precipition for Yesterday.
  • precip_rate - current precipitaion rate.
  • precip_minutes_local_day - Precipition Minutes Today.
  • precip_minutes_local_yesterday - Precipition Minutes Yesterday.
  • relative_humidity - relative Humidity.
  • solar_radiation - Solar Radiation.
  • station_pressure - Station Pressure.
  • timestamp - Data Timestamp.
  • station_name - Station Name.
  • uv - UV Index.
  • wind_avg - Wind Speed Average.
  • wind_bearing - Wind Bearing as Degree.
  • wind_chill - Wind Chill Temperature.
  • wind_gust - Wind Gust Speed.
  • wind_direction - Wind Direction Compass Symbol.

Default they are named: sensor.smartweather_SENSORNAME. They all have a Unique ID, so you can rename them to whatever you like afterwards.

7 Likes

This looks very interesting. I am particularly interested in being able to get some reliable local rainfall data for My Garden Irrigation (I don’t have a weather station but it looks like there is one a couple of miles away)

However, I cannot get it to pass the config check,

Invalid config for [smartweather]: expected a dictionary for dictionary value @ data['smartweather']. Got [OrderedDict([('station_id', '1234'), ('api_key', '20c70eae-e62f-4d3b-b3a4-8586e90f3ac8')])]. (See ?, line ?). Please check the docs at https://home-assistant.io/components/smartweather/

Also, (once I have it working!) is there any chance you could add brightness as a monitored condition?

Thanks.

Hi @klogg,
Station ID 1234 is a non existing station, so that might be the cause of your error (and I need to make more checks for that). Could you please try with station id 2777, which is my station, and I know this is available.
Also please show me your configuration, and the environment you are running HA in. I have only tested this on a Docker setup.

And yes, adding brightness can be done for sure.
Bjarne

This is exactly something I was wanting. I’ve got a Weatherflow PWS which I wanted to use the obs for, but obviously it can’t forecast. This is perfect - i’ll be trying this out soon and will provide feedback!

Release V0.0.2

Fixes and new features

  • illuminance (Brightness) has now been added to the component.
  • Reduced decimals to 1 for Precipitation values when using Metric Unitsystem. I am in a Metric region, so for you guys using Imperial Units, please let me know if values are displayed correct.

Please pull the files again from Github

I don’t mean to hijack your thread but have you looked at this? It’s what I use and I use all local sensors (not DarkSky since they are terrible for my location) other than using the DarkSky icons. The card allows you to use sensors from pretty much anywhere and really shouldn’t have ‘DarkSky’ in the name at all but I think that was just a legacy thing. Just figured you might not need to re-invent what is already out there

I know this card, but that alone will not do what I want, as you will still need the data from somewhere. And that is the real purpose of this component - pulling data from my local WeatherFlow station.
As an add-on I then created the weather entity, (More to see if I could do it :grinning:) but when using the card you refer to, you are right, you would only need the sensor entity of this component to get the local data.

If people only want to use the built-in Weather Card, the weather entity of this component will let them get their local current data combined with the DarkSky forecast in a simple way.

I am not using ‘1234’ I just put it here to obscure my location :sunglasses:

Using 2777 gives the same error.
I am using hassio.

Thanks for adding brightness but strangely that gives me an error too:

Invalid config for [sensor.smartweather]: value is not allowed @ data['monitored_conditions'][18]. Got 'illuminance'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.smartweather/

I am using the latest version as I have this line:

'illuminance': ['Illuminance', 'Lx', 'mdi:brightness-5', DEVICE_CLASS_ILLUMINANCE, None]

My config is as follows (I’m not using the card):

smartweather:
  station_id: '2777'
  api_key: 20c70eae-e62f-4d3b-b3a4-8586e90f3ac8  # Free development API key, see https://weatherflow.github.io/SmartWeather/api/#getting-started
sensor:
  - platform: smartweather
    monitored_conditions:
      - temperature
      - feels_like_temperature
      - heat_index
      - wind_chill
      - dewpoint
      - wind_speed
      - wind_gust
      - wind_bearing
      - wind_direction
      - precipitation
      - precipitation_rate
      - precipitation_last_1hr
      - precipitation_last_24hr
      - precipitation_yesterday
      - humidity
      - pressure
      - uv
      - solar_radiation
      - illuminance
binary_sensor:
  - platform: smartweather
    monitored_conditions:
      - raining
      - freezing

image

Hi briis,

Just one thing to change in your installation instructions, change custom_component to custom_components - I’ve got a new install and that tripped me up.

Anyway, I’m getting the following error when checking the config on a Hassio install:

Configuration invalid
Invalid config for [smartweather]: required key not provided @ data['platform'].
Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/smartweather/

@klogg: The new error you are getting is most likely due to a caching error. Try deleting the __pycache__ directory on both the smartweather directory and the smartweatherio directory, and then restart again.

@efleming: Thanks for the tip on the installation instructions - I’ll fix that. Have you supplied the station_id: and the api_key:? It seems to complain about a missing key.

If the missing keys is not the issue, I am a bit in the dark why this will not start up. I cannot replicate the problem.
The difference between your setup, and mine is that you both run on Hassio - My setup runs from a Docker Container. I wonder if there is a component I am calling, that is not installed pr. default in Hassio -
I would be surprised as I am only importing requests, sys, and datetime from standard Python. But if anyone with better Python skills than me, could help figure out why this does not wotk on Hassio, I would very much appreciate it.

In the meantime I will setup some better debugging, and release that - should give me more detailed info on where it fails. Stay tuned…

And if anyone else has downloaded this, and got it working, I would appreciate if you would post a reply here, with the Environment you are running HA in.

Here’s my configuration.yaml:

# Weather
smartweather:
  station_id: 4602
  api_key: 20c70eae-e62f-4d3b-b3a4-8586e90f3ac8
weather:
  - platform: smartweather
    api_key: 6f0ca9d3148c19081be5ef45b007e0fe
binary_sensor:
  - platform: smartweather
    monitored_conditions:
      - raining
      - freezing

Could it be the public API key for Weatherflow causing an issue? I might request a personal one just in case.

Thanks but that was a secondary problem, I’ve simply removed that monitored condition until I can get it working. I still can’t get past the config check as per my first post (even using your station_id)

I’ll wait for the new version with extra debugging…

Just copied your config setting in to my system, and it loads without problems. So as stated before, it must be the difference in Docker and Hassio, that is causing the issue. As said I am working on a more debugging, and will revert as soon as this is done.

It might take a day or two, as I need to do other stuff right now.

Best of luck, looking forward to seeing it soon :slight_smile:

I also get same error when checking the configuration on Home Assistant in venv.

Invalid config for [smartweather]: required key not provided @ data['platform']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/smartweather/

smartweather:
  station_id: 5723
  api_key: 20c70eae-e62f-4d3b-b3a4-8586e90f3ac8

sensor:
  - platform: smartweather
    monitored_conditions:
      - illuminance

The component loads and the sensor gets the value.

Ok, so something seems to work. Could you try to do a few things, to help me find where I need to look for the error:

First only add the smartweather platform, no sensor, binary_sensor or weather. And let me know if you get errors.

If no errors, load the entities one at a time, and let me know which entity gives the error.

I tried my hassio config with only:

smartweather:
  station_id: '2777'
  api_key: 20c70eae-e62f-4d3b-b3a4-8586e90f3ac8  # Free development API key, see https://weatherflow.github.io/SmartWeather/api/#getting-started

It failed the config check with this

Invalid config for [smartweather]: expected a dictionary for dictionary value @ data['smartweather']. Got [OrderedDict([('station_id', '2777'), ('api_key', '20c70eae-e62f-4d3b-b3a4-8586e90f3ac8')])]. (See ?, line ?). Please check the docs at https://home-assistant.io/components/smartweather/

Thanks. Could you then try to add the following:

sensor:
  - platform: smartweather

And then check if you got any sensors that starts with sensor.smartweather_

Normally an error like that relates to wrong formatting of the yaml file, so please also ensure that your indentation is right in the configuration.yaml (2 spaces)

GitHub release
Changes:

  • Updated README.md and corrected wrong directory in the installation section
  • Wind Bearing was wrongly converted to a string, and has to be an Integer
  • Cleaned up the smartweatherio module, and removed unused code
  • Added DEBUG entries

For those of you that get errors during startup, please add the following to the Logger component, and post the output from the log:

logger:
  default: error
  logs:
    custom_components.smartweather: debug
    custom_components.smartweather.sensor: debug
    custom_components.smartweather.binary_sensor: debug
    custom_components.smartweather.weather_sensor: debug