mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add BeeWi SmartClim BLE sensors (#26174)
* Add BeeWi SmartClim BLE temperature and humidity sensor * Update missing CODEOWNERS and .coveragerc files * Updated requirements file * Update documentation * Fixed requested changes and decoupled IO library * Add unique_id property * Improve unique_id
This commit is contained in:
parent
b5426761f4
commit
1617c2cd64
@ -57,6 +57,7 @@ omit =
|
|||||||
homeassistant/components/avion/light.py
|
homeassistant/components/avion/light.py
|
||||||
homeassistant/components/azure_event_hub/*
|
homeassistant/components/azure_event_hub/*
|
||||||
homeassistant/components/baidu/tts.py
|
homeassistant/components/baidu/tts.py
|
||||||
|
homeassistant/components/beewi_smartclim/sensor.py
|
||||||
homeassistant/components/bbb_gpio/*
|
homeassistant/components/bbb_gpio/*
|
||||||
homeassistant/components/bbox/device_tracker.py
|
homeassistant/components/bbox/device_tracker.py
|
||||||
homeassistant/components/bbox/sensor.py
|
homeassistant/components/bbox/sensor.py
|
||||||
|
@ -37,6 +37,7 @@ homeassistant/components/awair/* @danielsjf
|
|||||||
homeassistant/components/aws/* @awarecan @robbiet480
|
homeassistant/components/aws/* @awarecan @robbiet480
|
||||||
homeassistant/components/axis/* @kane610
|
homeassistant/components/axis/* @kane610
|
||||||
homeassistant/components/azure_event_hub/* @eavanvalkenburg
|
homeassistant/components/azure_event_hub/* @eavanvalkenburg
|
||||||
|
homeassistant/components/beewi_smartclim/* @alemuro
|
||||||
homeassistant/components/bitcoin/* @fabaff
|
homeassistant/components/bitcoin/* @fabaff
|
||||||
homeassistant/components/bizkaibus/* @UgaitzEtxebarria
|
homeassistant/components/bizkaibus/* @UgaitzEtxebarria
|
||||||
homeassistant/components/blink/* @fronzbot
|
homeassistant/components/blink/* @fronzbot
|
||||||
|
1
homeassistant/components/beewi_smartclim/__init__.py
Normal file
1
homeassistant/components/beewi_smartclim/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""The beewi_smartclim component."""
|
12
homeassistant/components/beewi_smartclim/manifest.json
Normal file
12
homeassistant/components/beewi_smartclim/manifest.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"domain": "beewi_smartclim",
|
||||||
|
"name": "BeeWi SmartClim BLE sensor",
|
||||||
|
"documentation": "https://www.home-assistant.io/components/beewi_smartclim",
|
||||||
|
"requirements": [
|
||||||
|
"beewi_smartclim==0.0.7"
|
||||||
|
],
|
||||||
|
"dependencies": [],
|
||||||
|
"codeowners": [
|
||||||
|
"@alemuro"
|
||||||
|
]
|
||||||
|
}
|
108
homeassistant/components/beewi_smartclim/sensor.py
Normal file
108
homeassistant/components/beewi_smartclim/sensor.py
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
"""Platform for beewi_smartclim integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from beewi_smartclim import BeewiSmartClimPoller
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.const import (
|
||||||
|
CONF_NAME,
|
||||||
|
CONF_MAC,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
DEVICE_CLASS_HUMIDITY,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_BATTERY,
|
||||||
|
)
|
||||||
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
DEFAULT_NAME = "BeeWi SmartClim"
|
||||||
|
|
||||||
|
# Sensor config
|
||||||
|
SENSOR_TYPES = [
|
||||||
|
[DEVICE_CLASS_TEMPERATURE, "Temperature", TEMP_CELSIUS],
|
||||||
|
[DEVICE_CLASS_HUMIDITY, "Humidity", "%"],
|
||||||
|
[DEVICE_CLASS_BATTERY, "Battery", "%"],
|
||||||
|
]
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_MAC): cv.string,
|
||||||
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
"""Set up the beewi_smartclim platform."""
|
||||||
|
|
||||||
|
mac = config[CONF_MAC]
|
||||||
|
prefix = config[CONF_NAME]
|
||||||
|
poller = BeewiSmartClimPoller(mac)
|
||||||
|
|
||||||
|
sensors = []
|
||||||
|
|
||||||
|
for sensor_type in SENSOR_TYPES:
|
||||||
|
device = sensor_type[0]
|
||||||
|
name = sensor_type[1]
|
||||||
|
unit = sensor_type[2]
|
||||||
|
# `prefix` is the name configured by the user for the sensor, we're appending
|
||||||
|
# the device type at the end of the name (garden -> garden temperature)
|
||||||
|
if prefix:
|
||||||
|
name = f"{prefix} {name}"
|
||||||
|
|
||||||
|
sensors.append(BeewiSmartclimSensor(poller, name, mac, device, unit))
|
||||||
|
|
||||||
|
add_entities(sensors)
|
||||||
|
|
||||||
|
|
||||||
|
class BeewiSmartclimSensor(Entity):
|
||||||
|
"""Representation of a Sensor."""
|
||||||
|
|
||||||
|
def __init__(self, poller, name, mac, device, unit):
|
||||||
|
"""Initialize the sensor."""
|
||||||
|
self._poller = poller
|
||||||
|
self._name = name
|
||||||
|
self._mac = mac
|
||||||
|
self._device = device
|
||||||
|
self._unit = unit
|
||||||
|
self._state = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the sensor."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return the state of the sensor. State is returned in Celsius."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Device class of this entity."""
|
||||||
|
return self._device
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return a unique, HASS-friendly identifier for this entity."""
|
||||||
|
return f"{self._mac}_{self._device}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit of measurement."""
|
||||||
|
return self._unit
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Fetch new state data from the poller."""
|
||||||
|
self._poller.update_sensor()
|
||||||
|
self._state = None
|
||||||
|
if self._device == DEVICE_CLASS_TEMPERATURE:
|
||||||
|
self._state = self._poller.get_temperature()
|
||||||
|
if self._device == DEVICE_CLASS_HUMIDITY:
|
||||||
|
self._state = self._poller.get_humidity()
|
||||||
|
if self._device == DEVICE_CLASS_BATTERY:
|
||||||
|
self._state = self._poller.get_battery()
|
@ -262,6 +262,9 @@ batinfo==0.4.2
|
|||||||
# homeassistant.components.sytadin
|
# homeassistant.components.sytadin
|
||||||
beautifulsoup4==4.8.0
|
beautifulsoup4==4.8.0
|
||||||
|
|
||||||
|
# homeassistant.components.beewi_smartclim
|
||||||
|
beewi_smartclim==0.0.7
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
bellows-homeassistant==0.9.1
|
bellows-homeassistant==0.9.1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user