diff --git a/homeassistant/components/switchbot/manifest.json b/homeassistant/components/switchbot/manifest.json index 4193a88e3ed..b076b254b9f 100644 --- a/homeassistant/components/switchbot/manifest.json +++ b/homeassistant/components/switchbot/manifest.json @@ -2,7 +2,7 @@ "domain": "switchbot", "name": "SwitchBot", "documentation": "https://www.home-assistant.io/integrations/switchbot", - "requirements": ["PySwitchbot==0.6.2"], + "requirements": ["PySwitchbot==0.8.0"], "dependencies": [], "codeowners": ["@danielhiversen"] } diff --git a/homeassistant/components/switchbot/switch.py b/homeassistant/components/switchbot/switch.py index ed7fba570a8..f0cbecc8968 100644 --- a/homeassistant/components/switchbot/switch.py +++ b/homeassistant/components/switchbot/switch.py @@ -7,7 +7,7 @@ import switchbot import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice -from homeassistant.const import CONF_MAC, CONF_NAME +from homeassistant.const import CONF_MAC, CONF_NAME, CONF_PASSWORD import homeassistant.helpers.config_validation as cv from homeassistant.helpers.restore_state import RestoreEntity @@ -19,6 +19,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MAC): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, + vol.Optional(CONF_PASSWORD): cv.string, } ) @@ -27,20 +28,21 @@ def setup_platform(hass, config, add_entities, discovery_info=None): """Perform the setup for Switchbot devices.""" name = config.get(CONF_NAME) mac_addr = config[CONF_MAC] - add_entities([SwitchBot(mac_addr, name)]) + password = config.get(CONF_PASSWORD) + add_entities([SwitchBot(mac_addr, name, password)]) class SwitchBot(SwitchDevice, RestoreEntity): """Representation of a Switchbot.""" - def __init__(self, mac, name) -> None: + def __init__(self, mac, name, password) -> None: """Initialize the Switchbot.""" self._state = None self._last_run_success = None self._name = name self._mac = mac - self._device = switchbot.Switchbot(mac=mac) + self._device = switchbot.Switchbot(mac=mac, password=password) async def async_added_to_hass(self): """Run when entity about to be added.""" diff --git a/requirements_all.txt b/requirements_all.txt index eb6820b81aa..c70cca86e85 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -72,7 +72,7 @@ PyRMVtransport==0.2.9 PySocks==1.7.1 # homeassistant.components.switchbot -# PySwitchbot==0.6.2 +# PySwitchbot==0.8.0 # homeassistant.components.transport_nsw PyTransportNSW==0.1.1