diff --git a/homeassistant/components/switch/switchmate.py b/homeassistant/components/switch/switchmate.py index fddb878b0ba..4955d72c5e3 100644 --- a/homeassistant/components/switch/switchmate.py +++ b/homeassistant/components/switch/switchmate.py @@ -13,10 +13,11 @@ import homeassistant.helpers.config_validation as cv from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA from homeassistant.const import CONF_NAME, CONF_MAC -REQUIREMENTS = ['pySwitchmate==0.3'] +REQUIREMENTS = ['pySwitchmate==0.4.1'] _LOGGER = logging.getLogger(__name__) +CONF_FLIP_ON_OFF = 'flip_on_off' DEFAULT_NAME = 'Switchmate' SCAN_INTERVAL = timedelta(minutes=30) @@ -24,6 +25,7 @@ SCAN_INTERVAL = timedelta(minutes=30) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_MAC): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, + vol.Optional(CONF_FLIP_ON_OFF, default=False): cv.boolean, }) @@ -31,18 +33,19 @@ def setup_platform(hass, config, add_entities, discovery_info=None) -> None: """Perform the setup for Switchmate devices.""" name = config.get(CONF_NAME) mac_addr = config[CONF_MAC] - add_entities([Switchmate(mac_addr, name)], True) + flip_on_off = config[CONF_FLIP_ON_OFF] + add_entities([Switchmate(mac_addr, name, flip_on_off)], True) class Switchmate(SwitchDevice): """Representation of a Switchmate.""" - def __init__(self, mac, name) -> None: + def __init__(self, mac, name, flip_on_off) -> None: """Initialize the Switchmate.""" import switchmate - self._name = name self._mac = mac - self._device = switchmate.Switchmate(mac=mac) + self._name = name + self._device = switchmate.Switchmate(mac=mac, flip_on_off=flip_on_off) @property def unique_id(self) -> str: diff --git a/requirements_all.txt b/requirements_all.txt index 8bcb6faa285..74f5e2605e6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -752,7 +752,7 @@ pyHS100==0.3.3 pyRFXtrx==0.23 # homeassistant.components.switch.switchmate -pySwitchmate==0.3 +pySwitchmate==0.4.1 # homeassistant.components.sensor.tibber pyTibber==0.5.0