Home Assistant Community

SmartWeather - Get local weather data combined with Dark Sky Forecast

#1

Smart Weather for Home Assistant

weatherflow
This a custom component for Home Assistant. It combines real-time weather readings from a Smart Weather weather station produced by WeatherFlow and Forecast data from Dark Sky.

GitHub release
Find all the files on Github: https://github.com/briis/smartweather

It can create several sensor entities for each weather reading like Temperature, Precipitation, Rain etc. and it can create two binary_sensor, one indicating if it freezes outside and one indicating if it is raining. Finally it can also create a weather component, that then combines the real-time readings from the Weather Station and the Forecast data from Dark Sky, in to a standard weathercomponent.

The smartweather component uses the WeatherFlow REST API to retrieve current data for a local WeatherStation, and it uses Dark Sky to retrieve Forecast data if the weather component is activated.

Installation

  1. If you don’t already have a custom_components directory in your config directory, create it, and then create a directory called smartweatherunder that.
  2. Copy all the files from this repository in to the smartweather folder. Remember to maintain the directory structure.

Configuration

Start by configuring the core platform. No matter which of the entities you activate, this has to be configured. The core platform by itself does nothing else than fetch the current data from WeatherFlow, so by activating this you will not see any entities being created in Home Assistant.

Edit your configuration.yaml file and add the smartweather component to the file:

# Example configuration.yaml entry
smartweather:
  station_id: <your station id>
  api_key: <Your WeatherFlow API Key>

station_id:

(string)(Required) 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

api_key

(string)(Required) 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.

name

(string)(Optional) Additional name for the platform.

Default value: SmartWeather

Binary Sensor

binary_sensor
In order to use the Binary Sensors, add the following to your configuration.yaml file:

# Example configuration.yaml entry
binary_sensor:
  - platform: smartweather
    monitored_conditions:
      - raining
      - freezing

Configuration Variables

name

(string)(Optional) Additional name for the sensors.

Default value: SmartWeather

monitored_conditions

(list)(optional) Sensors to display in the frontend.

Default: All Sensors are displayed

  • raining - A sensor indicating if it is currently raining
  • freezing - A sensor indicating if it is currently freezing outside.

Sensor

sensor
In order to use the Sensors, add the following to your configuration.yaml file:

# Example configuration.yaml entry
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

Configuration Variables

name

(string)(Optional) Additional name for the sensors.

Default value: SmartWeather

monitored_conditions

(list)(optional) Sensors to display in the frontend.

Default: All Sensors are displayed

  • temperature - Current temperature
  • feels_like_temperature - How the temperature Feels Like. A combination of Heat Index and Wind Chill
  • heat_index - A temperature measurement combining Humidity and temperature. How hot does it feel. Only used when temperature is above 26.67°C (80°F)
  • wind_chill - How cold does it feel. Only used if temperature is below 10°C (50°F)
  • dewpoint - Dewpoint. The atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form
  • wind_speed - Current Wind Speed
  • wind_gust - Current Wind Gust
  • wind_bearing - Wind bearing in degrees (Example: 287°)
  • wind_direction - Wind bearing as directional text (Example: NNW)
  • precipitation - Precipitation since midnight
  • precipitation_rate - The current precipitation rate - 0 if it is not raining
  • precipitation_last_1hr - Precipitation in the last hour
  • precipitation_last_24hr - Precipitation in the last 24 hours.
  • precipitation_yesterday - Precipitation yesterday
  • humidity - Current humidity in %
  • pressure - Current barometric pressure, taking in to account the position of the station
  • uv - The UV index
  • solar_radiation - The current Solar Radiation measured in W/m2
  • illuminance - The current brightness in Lux

Weather

weather
The Weather Entity uses Dark Sky for forecast data. So in order to use this Entity you must obtain a API Key from Dark Sky. The API key is free but requires registration. You can make up to 1000 calls per day for free which means that you could make one approximately every 86 seconds.

On top of the standard attributes that a weather entity has available, the following additional attributes have been added to this Weather Entity: Wind Gust, Dewpoint, Feels Like Temperature, Precipitation and Precipitation Rate

In order to use the Weather component, add the following to your configuration.yaml file:

# Example configuration.yaml entry
weather:
  - platform: smartweather
    api_key: <Your Dark Sky API key>

Configuration Variables

api_key

(string)(Required) Your API key.

name

(string)(Optional) Additional name for the sensors.

Default value: SmartWeather

mode

(string)(Optional) hourly for hour based forecast, and daily for day based forecast

Default value: hourly

5 Likes

WeatherFlow Smart Weather Station via UDP
My Garden Irrigation
#2

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.

0 Likes

#3

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

0 Likes

#4

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!

0 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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.

0 Likes

#8

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

0 Likes

#9

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/
0 Likes

#10

@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.

0 Likes

#11

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.

0 Likes

#12

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…

0 Likes

#13

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.

0 Likes

#14

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

0 Likes

#15

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

0 Likes

#16

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.

0 Likes

#17

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.

0 Likes

#18

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/
0 Likes

#19

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)

0 Likes

#20

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
0 Likes