-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Add BeeWi SmartClim BLE sensors #26174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c79a673
Add BeeWi SmartClim BLE temperature and humidity sensor
95c22dc
Update missing CODEOWNERS and .coveragerc files
6e1e615
Updated requirements file
alemuro 3845d62
Update documentation
489b047
Fixed requested changes and decoupled IO library
5698caa
Add unique_id property
8c49583
Improve unique_id
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """The beewi_smartclim component.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.6" | ||
| ], | ||
| "dependencies": [], | ||
| "codeowners": [ | ||
| "@alemuro" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| """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 | ||
|
alemuro marked this conversation as resolved.
|
||
| 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 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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.