Add support for BSBLAN firmware v3 (#82288)

* bump python-bsblan version to 0.5.8

* add static_state

this holds values that only needs retrieving once in a while

* update diagnostics  json with the right info
This commit is contained in:
Willem-Jan van Rootselaar 2022-11-30 16:36:33 +01:00 committed by GitHub
parent cad04bff99
commit 949dede16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 50 deletions

View File

@ -1,7 +1,7 @@
"""The BSB-Lan integration.""" """The BSB-Lan integration."""
import dataclasses import dataclasses
from bsblan import BSBLAN, Device, Info, State from bsblan import BSBLAN, Device, Info, State, StaticState
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -28,6 +28,7 @@ class HomeAssistantBSBLANData:
client: BSBLAN client: BSBLAN
device: Device device: Device
info: Info info: Info
static: StaticState
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
@ -54,11 +55,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
device = await bsblan.device() device = await bsblan.device()
info = await bsblan.info() info = await bsblan.info()
static = await bsblan.static_values()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = HomeAssistantBSBLANData( hass.data.setdefault(DOMAIN, {})[entry.entry_id] = HomeAssistantBSBLANData(
client=bsblan, client=bsblan,
coordinator=coordinator, coordinator=coordinator,
device=device, device=device,
info=info, info=info,
static=static,
) )
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any from typing import Any
from bsblan import BSBLAN, BSBLANError, Device, Info, State from bsblan import BSBLAN, BSBLANError, Device, Info, State, StaticState
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ATTR_HVAC_MODE, ATTR_HVAC_MODE,
@ -15,7 +15,7 @@ from homeassistant.components.climate import (
HVACMode, HVACMode,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -56,6 +56,7 @@ async def async_setup_entry(
data.client, data.client,
data.device, data.device,
data.info, data.info,
data.static,
entry, entry,
) )
], ],
@ -83,20 +84,21 @@ class BSBLANClimate(BSBLANEntity, CoordinatorEntity, ClimateEntity):
client: BSBLAN, client: BSBLAN,
device: Device, device: Device,
info: Info, info: Info,
static: StaticState,
entry: ConfigEntry, entry: ConfigEntry,
) -> None: ) -> None:
"""Initialize BSBLAN climate device.""" """Initialize BSBLAN climate device."""
super().__init__(client, device, info, entry) super().__init__(client, device, info, static, entry)
CoordinatorEntity.__init__(self, coordinator) CoordinatorEntity.__init__(self, coordinator)
self._attr_unique_id = f"{format_mac(device.MAC)}-climate" self._attr_unique_id = f"{format_mac(device.MAC)}-climate"
self._attr_min_temp = float(self.coordinator.data.min_temp.value) self._attr_min_temp = float(static.min_temp.value)
self._attr_max_temp = float(self.coordinator.data.max_temp.value) self._attr_max_temp = float(static.max_temp.value)
self._attr_temperature_unit = ( # check if self.coordinator.data.current_temperature.unit is "°C" or "°C"
TEMP_CELSIUS if self.coordinator.data.current_temperature.unit in ("°C", "°C"):
if self.coordinator.data.current_temperature.unit == "°C" self._attr_temperature_unit = UnitOfTemperature.CELSIUS
else TEMP_FAHRENHEIT else:
) self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
@property @property
def current_temperature(self) -> float | None: def current_temperature(self) -> float | None:

View File

@ -1,7 +1,7 @@
"""Base entity for the BSBLAN integration.""" """Base entity for the BSBLAN integration."""
from __future__ import annotations from __future__ import annotations
from bsblan import BSBLAN, Device, Info from bsblan import BSBLAN, Device, Info, StaticState
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
@ -19,6 +19,7 @@ class BSBLANEntity(Entity):
client: BSBLAN, client: BSBLAN,
device: Device, device: Device,
info: Info, info: Info,
static: StaticState,
entry: ConfigEntry, entry: ConfigEntry,
) -> None: ) -> None:
"""Initialize an BSBLAN entity.""" """Initialize an BSBLAN entity."""

View File

@ -3,7 +3,7 @@
"name": "BSB-Lan", "name": "BSB-Lan",
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/bsblan", "documentation": "https://www.home-assistant.io/integrations/bsblan",
"requirements": ["python-bsblan==0.5.7"], "requirements": ["python-bsblan==0.5.8"],
"codeowners": ["@liudger"], "codeowners": ["@liudger"],
"iot_class": "local_polling", "iot_class": "local_polling",
"loggers": ["bsblan"] "loggers": ["bsblan"]

View File

@ -1970,7 +1970,7 @@ pythinkingcleaner==0.0.3
python-blockchain-api==0.0.2 python-blockchain-api==0.0.2
# homeassistant.components.bsblan # homeassistant.components.bsblan
python-bsblan==0.5.7 python-bsblan==0.5.8
# homeassistant.components.clementine # homeassistant.components.clementine
python-clementine-remote==1.0.1 python-clementine-remote==1.0.1

View File

@ -1390,7 +1390,7 @@ pytankerkoenig==0.0.6
pytautulli==21.11.0 pytautulli==21.11.0
# homeassistant.components.bsblan # homeassistant.components.bsblan
python-bsblan==0.5.7 python-bsblan==0.5.8
# homeassistant.components.ecobee # homeassistant.components.ecobee
python-ecobee-api==0.2.14 python-ecobee-api==0.2.14

View File

@ -50,34 +50,6 @@
"value": "18.5", "value": "18.5",
"dataType": 0 "dataType": 0
}, },
"target_temperature_high": {
"name": "Komfortsollwert Maximum",
"unit": "°C",
"desc": "",
"value": "23.0",
"dataType": 0
},
"target_temperature_low": {
"name": "Room temp reduced setpoint",
"unit": "°C",
"desc": "",
"value": "17.0",
"dataType": 0
},
"min_temp": {
"name": "Room temp frost protection setpoint",
"unit": "°C",
"desc": "",
"value": "8.0",
"dataType": 0
},
"max_temp": {
"name": "Summer/winter changeover temp heat circuit 1",
"unit": "°C",
"desc": "",
"value": "20.0",
"dataType": 0
},
"hvac_action": { "hvac_action": {
"name": "Status heating circuit 1", "name": "Status heating circuit 1",
"unit": "", "unit": "",
@ -98,13 +70,6 @@
"desc": "Kein Bedarf", "desc": "Kein Bedarf",
"value": "0", "value": "0",
"dataType": 1 "dataType": 1
},
"outside_temperature": {
"name": "Outside temp sensor local",
"unit": "°C",
"desc": "",
"value": "6.1",
"dataType": 0
} }
} }
} }