Skip to content

Commit 9889bda

Browse files
authored
Merge pull request #18 from golles/sun_chance+householding
Sun chance + householding
2 parents debab4c + 47d4a35 commit 9889bda

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
22
{
33
"image": "ludeeus/container:integration-debian",
4-
"name": "Blueprint integration development",
4+
"name": "HA KNMI development",
55
"context": "..",
66
"appPort": [
77
"9123:8123"
@@ -16,7 +16,7 @@
1616
"settings": {
1717
"files.eol": "\n",
1818
"editor.tabSize": 4,
19-
"terminal.integrated.shell.linux": "/bin/bash",
19+
"terminal.integrated.defaultProfile.linux": "bash",
2020
"python.pythonPath": "/usr/bin/python3",
2121
"python.analysis.autoSearchPaths": false,
2222
"python.linting.pylintEnabled": true,

.vscode/settings.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
"python.pythonPath": "/usr/local/bin/python",
55
"files.associations": {
66
"*.yaml": "home-assistant"
7-
}
7+
},
8+
"python.testing.pytestArgs": [
9+
"tests"
10+
],
11+
"python.testing.unittestEnabled": false,
12+
"python.testing.pytestEnabled": true
813
}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 golles
3+
Copyright (c) 2022 golles
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

custom_components/knmi/const.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from homeassistant.components.binary_sensor import (
88
DEVICE_CLASS_SAFETY,
99
)
10+
from homeassistant.components.sensor import (
11+
STATE_CLASS_MEASUREMENT,
12+
ATTR_STATE_CLASS,
13+
)
1014
from homeassistant.components.weather import (
1115
ATTR_CONDITION_CLEAR_NIGHT,
1216
ATTR_CONDITION_CLOUDY,
@@ -20,9 +24,6 @@
2024
ATTR_CONDITION_SUNNY,
2125
)
2226

23-
# Todo, import next: from homeassistant.components.sensor import SensorStateClass
24-
MEASUREMENT = "measurement"
25-
2627
# Base component constants.
2728
NAME = "KNMI"
2829
DOMAIN = "knmi"
@@ -72,8 +73,8 @@
7273
"device_class": DEVICE_CLASS_TEMPERATURE,
7374
"attributes": [
7475
{
75-
"name": "state_class",
76-
"value": MEASUREMENT,
76+
"name": ATTR_STATE_CLASS,
77+
"value": STATE_CLASS_MEASUREMENT,
7778
},
7879
],
7980
},
@@ -85,8 +86,8 @@
8586
"device_class": DEVICE_CLASS_TEMPERATURE,
8687
"attributes": [
8788
{
88-
"name": "state_class",
89-
"value": MEASUREMENT,
89+
"name": ATTR_STATE_CLASS,
90+
"value": STATE_CLASS_MEASUREMENT,
9091
},
9192
],
9293
},

custom_components/knmi/weather.py

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ def forecast(self):
129129
if super().getData(f"d{i}windkmh") is not None
130130
else None
131131
)
132+
sun_chance = (
133+
float(super().getData(f"d{i}zon"))
134+
if super().getData(f"d{i}zon") is not None
135+
else None
136+
)
132137
next_day = {
133138
ATTR_FORECAST_TIME: date.isoformat(),
134139
ATTR_FORECAST_CONDITION: condition,
@@ -137,6 +142,7 @@ def forecast(self):
137142
ATTR_FORECAST_PRECIPITATION: precipitation,
138143
ATTR_FORECAST_WIND_BEARING: wind_bearing,
139144
ATTR_FORECAST_WIND_SPEED: wind_speed,
145+
"sun_chance": sun_chance,
140146
}
141147
forecast.append(next_day)
142148

0 commit comments

Comments
 (0)