diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 729d669..876d6c3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ludeeus/container:integration-debian", + "image": "ghcr.io/ludeeus/devcontainer/integration:stable", "name": "HA KNMI development", "context": "..", "appPort": [ @@ -16,7 +16,7 @@ "settings": { "files.eol": "\n", "editor.tabSize": 4, - "terminal.integrated.defaultProfile.linux": "bash", + "terminal.integrated.shell.linux": "/bin/bash", "python.pythonPath": "/usr/bin/python3", "python.analysis.autoSearchPaths": false, "python.linting.pylintEnabled": true, diff --git a/custom_components/knmi/__init__.py b/custom_components/knmi/__init__.py index eaf1ce9..0aa2160 100644 --- a/custom_components/knmi/__init__.py +++ b/custom_components/knmi/__init__.py @@ -59,7 +59,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): hass.config_entries.async_forward_entry_setup(entry, platform) ) - entry.add_update_listener(async_reload_entry) + entry.async_on_unload(entry.add_update_listener(async_reload_entry)) return True diff --git a/custom_components/knmi/sensor.py b/custom_components/knmi/sensor.py index 81b89d5..0511f2b 100644 --- a/custom_components/knmi/sensor.py +++ b/custom_components/knmi/sensor.py @@ -1,5 +1,7 @@ """Sensor platform for knmi.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME + from .const import DEFAULT_NAME, DOMAIN, SENSORS from .entity import KnmiEntity @@ -26,7 +28,7 @@ async def async_setup_entry(hass, entry, async_add_devices): async_add_devices(sensors) -class KnmiSensor(KnmiEntity): +class KnmiSensor(KnmiEntity, SensorEntity): """Knmi Sensor class.""" def __init__( @@ -55,12 +57,12 @@ def name(self): return f"{DEFAULT_NAME} {self.entry_name} {self._name}" @property - def state(self): - """Return the state of the sensor.""" + def native_value(self): + """Return the native_value of the sensor.""" return super().getData(self._data_key) @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement