Skip to content
Snippets Groups Projects
Commit 323992e2 authored by ChristianKuehnel's avatar ChristianKuehnel Committed by Daniel Høyer Iversen
Browse files

MiFlora - use bluepy on linux systems (#11284)

* Updated bluepy to version 1.1.4 as some issues with the native code were fixed there.

* Miflora - Added support for bluepy backend.

* miflora - now using bluepy backend on linux platforms

* fixed pylint findings

* miflora now using bluepy as default bluetooth backend and gatttool as fallback

* fixed hound complaints

* fixed pylint warning

* updated requirements

* Update miflora.py
parent f744467c
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['decora==0.6', 'bluepy==1.1.1']
REQUIREMENTS = ['decora==0.6', 'bluepy==1.1.4']
_LOGGER = logging.getLogger(__name__)
......
......@@ -15,6 +15,7 @@ from homeassistant.const import (
CONF_FORCE_UPDATE, CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_MAC
)
REQUIREMENTS = ['miflora==0.2.0']
_LOGGER = logging.getLogger(__name__)
......@@ -60,12 +61,19 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the MiFlora sensor."""
from miflora import miflora_poller
from miflora.backends.gatttool import GatttoolBackend
try:
import bluepy.btle # noqa: F401 # pylint: disable=unused-variable
from miflora.backends.bluepy import BluepyBackend
backend = BluepyBackend
except ImportError:
from miflora.backends.gatttool import GatttoolBackend
backend = GatttoolBackend
_LOGGER.debug('Miflora is using %s backend.', backend.__name__)
cache = config.get(CONF_CACHE)
poller = miflora_poller.MiFloraPoller(
config.get(CONF_MAC), cache_timeout=cache,
adapter=config.get(CONF_ADAPTER), backend=GatttoolBackend)
adapter=config.get(CONF_ADAPTER), backend=backend)
force_update = config.get(CONF_FORCE_UPDATE)
median = config.get(CONF_MEDIAN)
poller.ble_timeout = config.get(CONF_TIMEOUT)
......@@ -135,7 +143,6 @@ class MiFloraSensor(Entity):
data = self.poller.parameter_value(self.parameter)
except IOError as ioerr:
_LOGGER.info("Polling error %s", ioerr)
data = None
return
if data is not None:
......
......@@ -141,7 +141,7 @@ blinkstick==1.1.8
blockchain==1.4.0
# homeassistant.components.light.decora
# bluepy==1.1.1
# bluepy==1.1.4
# homeassistant.components.notify.aws_lambda
# homeassistant.components.notify.aws_sns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment