Skip to content

Commit

Permalink
Merge pull request #18 from golles/sun_chance+householding
Browse files Browse the repository at this point in the history
Sun chance + householding
  • Loading branch information
golles authored Feb 5, 2022
2 parents debab4c + 47d4a35 commit 9889bda
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"image": "ludeeus/container:integration-debian",
"name": "Blueprint integration development",
"name": "HA KNMI development",
"context": "..",
"appPort": [
"9123:8123"
Expand All @@ -16,7 +16,7 @@
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"terminal.integrated.defaultProfile.linux": "bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"python.pythonPath": "/usr/local/bin/python",
"files.associations": {
"*.yaml": "home-assistant"
}
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 golles
Copyright (c) 2022 golles

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 8 additions & 7 deletions custom_components/knmi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SAFETY,
)
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
ATTR_STATE_CLASS,
)
from homeassistant.components.weather import (
ATTR_CONDITION_CLEAR_NIGHT,
ATTR_CONDITION_CLOUDY,
Expand All @@ -20,9 +24,6 @@
ATTR_CONDITION_SUNNY,
)

# Todo, import next: from homeassistant.components.sensor import SensorStateClass
MEASUREMENT = "measurement"

# Base component constants.
NAME = "KNMI"
DOMAIN = "knmi"
Expand Down Expand Up @@ -72,8 +73,8 @@
"device_class": DEVICE_CLASS_TEMPERATURE,
"attributes": [
{
"name": "state_class",
"value": MEASUREMENT,
"name": ATTR_STATE_CLASS,
"value": STATE_CLASS_MEASUREMENT,
},
],
},
Expand All @@ -85,8 +86,8 @@
"device_class": DEVICE_CLASS_TEMPERATURE,
"attributes": [
{
"name": "state_class",
"value": MEASUREMENT,
"name": ATTR_STATE_CLASS,
"value": STATE_CLASS_MEASUREMENT,
},
],
},
Expand Down
6 changes: 6 additions & 0 deletions custom_components/knmi/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def forecast(self):
if super().getData(f"d{i}windkmh") is not None
else None
)
sun_chance = (
float(super().getData(f"d{i}zon"))
if super().getData(f"d{i}zon") is not None
else None
)
next_day = {
ATTR_FORECAST_TIME: date.isoformat(),
ATTR_FORECAST_CONDITION: condition,
Expand All @@ -137,6 +142,7 @@ def forecast(self):
ATTR_FORECAST_PRECIPITATION: precipitation,
ATTR_FORECAST_WIND_BEARING: wind_bearing,
ATTR_FORECAST_WIND_SPEED: wind_speed,
"sun_chance": sun_chance,
}
forecast.append(next_day)

Expand Down

0 comments on commit 9889bda

Please sign in to comment.