Skip to content
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

add optional iface parameter to btle #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ More options are:
- name (string)(Optional)
The name displayed in the frontend.

- iface (integer)(Optional)
Parameter allows select of connection Bluetooth interface.
On Linux, 0 means */dev/hci0*, 1 means */dev/hci1* and so on.

Even more options regarding caching and intervals are comming in the future.

For advanced debugging set:
Expand Down
5 changes: 4 additions & 1 deletion custom_components/mikettle/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
_LOGGER = logging.getLogger(__name__)

CONF_PRODUCT_ID = "product_id"
CONF_IFACE = "iface"

DEFAULT_PRODUCT_ID = 275
DEFAULT_FORCE_UPDATE = False
DEFAULT_NAME = "Mi Kettle"
DEFAULT_SCAN_INTERVAL = timedelta(seconds=60)
DEFAULT_IFACE = 0

# Sensor types are defined like: Name, units, icon
SENSOR_TYPES = {
Expand All @@ -54,14 +56,15 @@
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PRODUCT_ID, default=DEFAULT_PRODUCT_ID): cv.positive_int,
vol.Optional(CONF_FORCE_UPDATE, default=DEFAULT_FORCE_UPDATE): cv.boolean,
vol.Optional(CONF_IFACE, default=DEFAULT_IFACE): cv.positive_int,
}
)


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the MiKettle sensor."""
cache = config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL).total_seconds()
poller = MiKettle(config.get(CONF_MAC), config.get(CONF_PRODUCT_ID))
poller = MiKettle(mac=config.get(CONF_MAC), product_id=config.get(CONF_PRODUCT_ID), iface=config.get(CONF_IFACE))

force_update = config.get(CONF_FORCE_UPDATE)

Expand Down