mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-11 09:39:00 +01:00
add dhcp autodiscovery for levoit-* (#1)
This commit is contained in:
parent
49f05780b9
commit
f36fc12a73
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,3 @@
|
||||
.vscode/**
|
||||
**/__pycache__/**
|
||||
Config/**
|
||||
custom_components/vesync/__pycache__/sensor.cpython-39.pyc
|
||||
|
@ -1,15 +1,20 @@
|
||||
"""Config flow utilities."""
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
from .pyvesync.vesync import VeSync
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow."""
|
||||
@ -56,3 +61,11 @@ class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
title=self._username,
|
||||
data={CONF_USERNAME: self._username, CONF_PASSWORD: self._password},
|
||||
)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle DHCP discovery."""
|
||||
hostname = discovery_info.hostname
|
||||
|
||||
_LOGGER.debug("DHCP discovery detected device %s", hostname)
|
||||
self.context["title_placeholders"] = {"gateway_id": hostname}
|
||||
return await self.async_step_user()
|
||||
|
@ -6,5 +6,11 @@
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_polling",
|
||||
"version": "0.1.2",
|
||||
"issue_tracker": "https://github.com/vlebourl/vesync-bpo"
|
||||
"issue_tracker": "https://github.com/vlebourl/vesync-bpo",
|
||||
"dhcp": [
|
||||
{
|
||||
"hostname": "levoit-*",
|
||||
"macaddress": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
{
|
||||
"config": {
|
||||
"flow_title": "Gateway: {gateway_id}",
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Enter Username and Password",
|
||||
"title": "VeSync Integration for Home Assistant",
|
||||
"description": "Custom component for Home Assistant to interact with smart devices via the VeSync platform.",
|
||||
"data": {
|
||||
"username": "[%key:common::config_flow::data::email%]",
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
|
Loading…
x
Reference in New Issue
Block a user