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.pypull/11819/head
parent
f744467c5d
commit
323992e224
|
@ -16,7 +16,7 @@ from homeassistant.components.light import (
|
||||||
PLATFORM_SCHEMA)
|
PLATFORM_SCHEMA)
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.const import (
|
||||||
CONF_FORCE_UPDATE, CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_MAC
|
CONF_FORCE_UPDATE, CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_MAC
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS = ['miflora==0.2.0']
|
REQUIREMENTS = ['miflora==0.2.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -60,12 +61,19 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the MiFlora sensor."""
|
"""Set up the MiFlora sensor."""
|
||||||
from miflora import miflora_poller
|
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)
|
cache = config.get(CONF_CACHE)
|
||||||
poller = miflora_poller.MiFloraPoller(
|
poller = miflora_poller.MiFloraPoller(
|
||||||
config.get(CONF_MAC), cache_timeout=cache,
|
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)
|
force_update = config.get(CONF_FORCE_UPDATE)
|
||||||
median = config.get(CONF_MEDIAN)
|
median = config.get(CONF_MEDIAN)
|
||||||
poller.ble_timeout = config.get(CONF_TIMEOUT)
|
poller.ble_timeout = config.get(CONF_TIMEOUT)
|
||||||
|
@ -135,7 +143,6 @@ class MiFloraSensor(Entity):
|
||||||
data = self.poller.parameter_value(self.parameter)
|
data = self.poller.parameter_value(self.parameter)
|
||||||
except IOError as ioerr:
|
except IOError as ioerr:
|
||||||
_LOGGER.info("Polling error %s", ioerr)
|
_LOGGER.info("Polling error %s", ioerr)
|
||||||
data = None
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
|
|
|
@ -141,7 +141,7 @@ blinkstick==1.1.8
|
||||||
blockchain==1.4.0
|
blockchain==1.4.0
|
||||||
|
|
||||||
# homeassistant.components.light.decora
|
# homeassistant.components.light.decora
|
||||||
# bluepy==1.1.1
|
# bluepy==1.1.4
|
||||||
|
|
||||||
# homeassistant.components.notify.aws_lambda
|
# homeassistant.components.notify.aws_lambda
|
||||||
# homeassistant.components.notify.aws_sns
|
# homeassistant.components.notify.aws_sns
|
||||||
|
|
Loading…
Reference in New Issue