Implement local discovery of Smappee series-2 devices and improvements (#38728)
* prepare local api support for Smappee2-series * Series-2 devices are now supported * remove switch scan_interval
This commit is contained in:
parent
c87e03ee6f
commit
11f121b008
7 changed files with 18 additions and 9 deletions
|
@ -8,7 +8,14 @@ from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS
|
|||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from . import api
|
||||
from .const import CONF_HOSTNAME, CONF_SERIALNUMBER, DOMAIN, ENV_CLOUD, ENV_LOCAL
|
||||
from .const import (
|
||||
CONF_HOSTNAME,
|
||||
CONF_SERIALNUMBER,
|
||||
DOMAIN,
|
||||
ENV_CLOUD,
|
||||
ENV_LOCAL,
|
||||
SUPPORTED_LOCAL_DEVICES,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -35,7 +42,7 @@ class SmappeeFlowHandler(
|
|||
async def async_step_zeroconf(self, discovery_info):
|
||||
"""Handle zeroconf discovery."""
|
||||
|
||||
if not discovery_info[CONF_HOSTNAME].startswith("Smappee1"):
|
||||
if not discovery_info[CONF_HOSTNAME].startswith(SUPPORTED_LOCAL_DEVICES):
|
||||
# We currently only support Energy and Solar models (legacy)
|
||||
return self.async_abort(reason="invalid_mdns")
|
||||
|
||||
|
@ -152,7 +159,9 @@ class SmappeeFlowHandler(
|
|||
if config_item["key"] == "mdnsHostName":
|
||||
serial_number = config_item["value"]
|
||||
|
||||
if serial_number is None or not serial_number.startswith("Smappee1"):
|
||||
if serial_number is None or not serial_number.startswith(
|
||||
SUPPORTED_LOCAL_DEVICES
|
||||
):
|
||||
# We currently only support Energy and Solar models (legacy)
|
||||
return self.async_abort(reason="invalid_mdns")
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ ENV_LOCAL = "local"
|
|||
|
||||
SMAPPEE_PLATFORMS = ["binary_sensor", "sensor", "switch"]
|
||||
|
||||
SUPPORTED_LOCAL_DEVICES = ("Smappee1", "Smappee2")
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=20)
|
||||
|
||||
AUTHORIZE_URL = {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/smappee",
|
||||
"dependencies": ["http"],
|
||||
"requirements": [
|
||||
"pysmappee==0.2.9"
|
||||
"pysmappee==0.2.10"
|
||||
],
|
||||
"codeowners": [
|
||||
"@bsmappee"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for interacting with Smappee Comport Plugs, Switches and Output Modules."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
|
@ -10,7 +9,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
SWITCH_PREFIX = "Switch"
|
||||
ICON = "mdi:toggle-switch"
|
||||
SCAN_INTERVAL = timedelta(seconds=5)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
|
|
@ -1633,7 +1633,7 @@ pyskyqhub==0.1.1
|
|||
pysma==0.3.5
|
||||
|
||||
# homeassistant.components.smappee
|
||||
pysmappee==0.2.9
|
||||
pysmappee==0.2.10
|
||||
|
||||
# homeassistant.components.smartthings
|
||||
pysmartapp==0.3.2
|
||||
|
|
|
@ -771,7 +771,7 @@ pysignalclirestapi==0.3.4
|
|||
pysma==0.3.5
|
||||
|
||||
# homeassistant.components.smappee
|
||||
pysmappee==0.2.9
|
||||
pysmappee==0.2.10
|
||||
|
||||
# homeassistant.components.smartthings
|
||||
pysmartapp==0.3.2
|
||||
|
|
|
@ -119,7 +119,7 @@ async def test_full_user_wrong_mdns(hass):
|
|||
"""Test we abort user flow if unsupported mDNS name got resolved."""
|
||||
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
|
||||
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
|
||||
return_value=[{"key": "mdnsHostName", "value": "Smappee2006000212"}],
|
||||
return_value=[{"key": "mdnsHostName", "value": "Smappee5010000001"}],
|
||||
), patch(
|
||||
"pysmappee.api.SmappeeLocalApi.load_command_control_config", return_value=[]
|
||||
), patch(
|
||||
|
|
Loading…
Add table
Reference in a new issue