Add velbus buttons platform (#73323)
This commit is contained in:
parent
9fef1004a2
commit
040ece76ab
7 changed files with 49 additions and 5 deletions
|
@ -1361,6 +1361,7 @@ omit =
|
|||
homeassistant/components/vasttrafik/sensor.py
|
||||
homeassistant/components/velbus/__init__.py
|
||||
homeassistant/components/velbus/binary_sensor.py
|
||||
homeassistant/components/velbus/button.py
|
||||
homeassistant/components/velbus/climate.py
|
||||
homeassistant/components/velbus/const.py
|
||||
homeassistant/components/velbus/cover.py
|
||||
|
|
|
@ -28,6 +28,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.CLIMATE,
|
||||
Platform.COVER,
|
||||
Platform.LIGHT,
|
||||
|
|
42
homeassistant/components/velbus/button.py
Normal file
42
homeassistant/components/velbus/button.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
"""Support for Velbus Buttons."""
|
||||
from __future__ import annotations
|
||||
|
||||
from velbusaio.channels import (
|
||||
Button as VelbusaioButton,
|
||||
ButtonCounter as VelbusaioButtonCounter,
|
||||
)
|
||||
|
||||
from homeassistant.components.button import ButtonEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import VelbusEntity
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Velbus switch based on config_entry."""
|
||||
await hass.data[DOMAIN][entry.entry_id]["tsk"]
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"]
|
||||
entities = []
|
||||
for channel in cntrl.get_all("button"):
|
||||
entities.append(VelbusButton(channel))
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
class VelbusButton(VelbusEntity, ButtonEntity):
|
||||
"""Representation of a Velbus Binary Sensor."""
|
||||
|
||||
_channel: VelbusaioButton | VelbusaioButtonCounter
|
||||
_attr_entity_registry_enabled_default = False
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Handle the button press."""
|
||||
await self._channel.press()
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "velbus",
|
||||
"name": "Velbus",
|
||||
"documentation": "https://www.home-assistant.io/integrations/velbus",
|
||||
"requirements": ["velbus-aio==2022.6.1"],
|
||||
"requirements": ["velbus-aio==2022.6.2"],
|
||||
"config_flow": true,
|
||||
"codeowners": ["@Cereal2nd", "@brefra"],
|
||||
"dependencies": ["usb"],
|
||||
|
|
|
@ -53,9 +53,9 @@ class VelbusSensor(VelbusEntity, SensorEntity):
|
|||
self._attr_name = f"{self._attr_name}-counter"
|
||||
# define the device class
|
||||
if self._is_counter:
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
elif channel.is_counter_channel():
|
||||
self._attr_device_class = SensorDeviceClass.POWER
|
||||
elif channel.is_counter_channel():
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
elif channel.is_temperature():
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
# define the icon
|
||||
|
|
|
@ -2384,7 +2384,7 @@ vallox-websocket-api==2.11.0
|
|||
vehicle==0.4.0
|
||||
|
||||
# homeassistant.components.velbus
|
||||
velbus-aio==2022.6.1
|
||||
velbus-aio==2022.6.2
|
||||
|
||||
# homeassistant.components.venstar
|
||||
venstarcolortouch==0.16
|
||||
|
|
|
@ -1581,7 +1581,7 @@ vallox-websocket-api==2.11.0
|
|||
vehicle==0.4.0
|
||||
|
||||
# homeassistant.components.velbus
|
||||
velbus-aio==2022.6.1
|
||||
velbus-aio==2022.6.2
|
||||
|
||||
# homeassistant.components.venstar
|
||||
venstarcolortouch==0.16
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue