Discover Switchbot MAC in config flow (#56616)

* Update config_flow.py

* Switchbot Config_flow discover mac instead of needing to type it.

* Do not show already configured devices in config flow, abort if no unconfigured devices.

* Apply suggestions from code review

Co-authored-by: J. Nick Koston <nick@koston.org>

* Move MAC to top of config flow form dict.

* Update homeassistant/components/switchbot/config_flow.py

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
RenierM26 2021-09-27 22:12:40 +02:00 committed by GitHub
parent b40d229369
commit b15f11f46a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 125 deletions

View file

@ -12,18 +12,35 @@ class MocGetSwitchbotDevices:
"""Get switchbot devices class constructor."""
self._interface = interface
self._all_services_data = {
"mac_address": "e7:89:43:99:99:99",
"Flags": "06",
"Manufacturer": "5900e78943d9fe7c",
"Complete 128b Services": "cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"data": {
"switchMode": "true",
"isOn": "true",
"battery": 91,
"rssi": -71,
"e78943999999": {
"mac_address": "e7:89:43:99:99:99",
"Flags": "06",
"Manufacturer": "5900e78943d9fe7c",
"Complete 128b Services": "cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"data": {
"switchMode": "true",
"isOn": "true",
"battery": 91,
"rssi": -71,
},
"model": "H",
"modelName": "WoHand",
},
"e78943909090": {
"mac_address": "e7:89:43:90:90:90",
"Flags": "06",
"Manufacturer": "5900e78943d9fe7c",
"Complete 128b Services": "cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"data": {
"calibration": True,
"battery": 74,
"position": 100,
"lightLevel": 2,
"rssi": -73,
},
"model": "c",
"modelName": "WoCurtain",
},
"model": "H",
"modelName": "WoHand",
}
self._curtain_all_services_data = {
"mac_address": "e7:89:43:90:90:90",
@ -90,6 +107,5 @@ def switchbot_config_flow(hass):
instance = mock_switchbot.return_value
instance.discover = MagicMock(return_value=True)
instance.get_device_data = MagicMock(return_value=True)
yield mock_switchbot