Skip to content
Merged
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
2 changes: 1 addition & 1 deletion homeassistant/components/switchbot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
10 changes: 6 additions & 4 deletions homeassistant/components/switchbot/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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

Expand All @@ -19,6 +19,7 @@
{
vol.Required(CONF_MAC): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PASSWORD): cv.string,
}
)

Expand All @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down