mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Upgrade Switchmate lib (#16637)
* new version switchmate lib, fix bug, and enable more logging in lib * new version switchmate lib, fix bug, and enable more logging in lib
This commit is contained in:
parent
9c9df793b4
commit
baeb791d84
@ -13,10 +13,11 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
|
from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
|
||||||
from homeassistant.const import CONF_NAME, CONF_MAC
|
from homeassistant.const import CONF_NAME, CONF_MAC
|
||||||
|
|
||||||
REQUIREMENTS = ['pySwitchmate==0.3']
|
REQUIREMENTS = ['pySwitchmate==0.4.1']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
CONF_FLIP_ON_OFF = 'flip_on_off'
|
||||||
DEFAULT_NAME = 'Switchmate'
|
DEFAULT_NAME = 'Switchmate'
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=30)
|
SCAN_INTERVAL = timedelta(minutes=30)
|
||||||
@ -24,6 +25,7 @@ SCAN_INTERVAL = timedelta(minutes=30)
|
|||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_MAC): cv.string,
|
vol.Required(CONF_MAC): cv.string,
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): 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."""
|
"""Perform the setup for Switchmate devices."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
mac_addr = config[CONF_MAC]
|
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):
|
class Switchmate(SwitchDevice):
|
||||||
"""Representation of a Switchmate."""
|
"""Representation of a Switchmate."""
|
||||||
|
|
||||||
def __init__(self, mac, name) -> None:
|
def __init__(self, mac, name, flip_on_off) -> None:
|
||||||
"""Initialize the Switchmate."""
|
"""Initialize the Switchmate."""
|
||||||
import switchmate
|
import switchmate
|
||||||
self._name = name
|
|
||||||
self._mac = mac
|
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
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
@ -752,7 +752,7 @@ pyHS100==0.3.3
|
|||||||
pyRFXtrx==0.23
|
pyRFXtrx==0.23
|
||||||
|
|
||||||
# homeassistant.components.switch.switchmate
|
# homeassistant.components.switch.switchmate
|
||||||
pySwitchmate==0.3
|
pySwitchmate==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.sensor.tibber
|
# homeassistant.components.sensor.tibber
|
||||||
pyTibber==0.5.0
|
pyTibber==0.5.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user