diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fab8c1f..729d669 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" @@ -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, diff --git a/.vscode/settings.json b/.vscode/settings.json index a3d535d..aea87d4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 } \ No newline at end of file diff --git a/LICENSE b/LICENSE index 1e7d3c0..705730d 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/custom_components/knmi/const.py b/custom_components/knmi/const.py index 97372e6..be1c4fa 100644 --- a/custom_components/knmi/const.py +++ b/custom_components/knmi/const.py @@ -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, @@ -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" @@ -72,8 +73,8 @@ "device_class": DEVICE_CLASS_TEMPERATURE, "attributes": [ { - "name": "state_class", - "value": MEASUREMENT, + "name": ATTR_STATE_CLASS, + "value": STATE_CLASS_MEASUREMENT, }, ], }, @@ -85,8 +86,8 @@ "device_class": DEVICE_CLASS_TEMPERATURE, "attributes": [ { - "name": "state_class", - "value": MEASUREMENT, + "name": ATTR_STATE_CLASS, + "value": STATE_CLASS_MEASUREMENT, }, ], }, diff --git a/custom_components/knmi/weather.py b/custom_components/knmi/weather.py index b6ecda1..ba7a49e 100644 --- a/custom_components/knmi/weather.py +++ b/custom_components/knmi/weather.py @@ -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, @@ -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)