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
14 changes: 12 additions & 2 deletions homeassistant/components/garadget/cover.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Platform for the Garadget cover component."""
from __future__ import annotations

import logging

import requests
Expand All @@ -15,8 +17,11 @@
STATE_CLOSED,
STATE_OPEN,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import track_utc_time_change
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -55,10 +60,15 @@
)


def setup_platform(hass, config, add_entities, discovery_info=None):
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Garadget covers."""
covers = []
devices = config.get(CONF_COVERS)
devices = config[CONF_COVERS]

for device_id, device_config in devices.items():
args = {
Expand Down
14 changes: 12 additions & 2 deletions homeassistant/components/gc100/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""Support for binary sensor using GC100."""
from __future__ import annotations

import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from . import CONF_PORTS, DATA_GC100

Expand All @@ -14,10 +19,15 @@
)


def setup_platform(hass, config, add_entities, discovery_info=None):
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the GC100 devices."""
binary_sensors = []
ports = config.get(CONF_PORTS)
ports = config[CONF_PORTS]
for port in ports:
for port_addr, port_name in port.items():
binary_sensors.append(
Expand Down
14 changes: 12 additions & 2 deletions homeassistant/components/gc100/switch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""Support for switches using GC100."""
from __future__ import annotations

import voluptuous as vol

from homeassistant.components.switch import PLATFORM_SCHEMA
from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from . import CONF_PORTS, DATA_GC100

Expand All @@ -15,10 +20,15 @@
)


def setup_platform(hass, config, add_entities, discovery_info=None):
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the GC100 devices."""
switches = []
ports = config.get(CONF_PORTS)
ports = config[CONF_PORTS]
for port in ports:
for port_addr, port_name in port.items():
switches.append(GC100Switch(port_name, port_addr, hass.data[DATA_GC100]))
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/goodwe/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
from goodwe import Inverter, InverterError

from homeassistant.components.number import NumberEntity, NumberEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG, PERCENTAGE, POWER_WATT
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER

Expand Down Expand Up @@ -59,7 +62,11 @@ class GoodweNumberEntityDescription(
)


async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the inverter select entities from a config entry."""
inverter = hass.data[DOMAIN][config_entry.entry_id][KEY_INVERTER]
device_info = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE_INFO]
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/goodwe/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
from goodwe import Inverter, InverterError

from homeassistant.components.select import SelectEntity, SelectEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER

Expand All @@ -27,7 +30,11 @@
)


async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the inverter select entities from a config entry."""
inverter = hass.data[DOMAIN][config_entry.entry_id][KEY_INVERTER]
device_info = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE_INFO]
Expand Down
11 changes: 9 additions & 2 deletions homeassistant/components/goodwe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CURRENT,
Expand All @@ -29,7 +30,9 @@
POWER_WATT,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
Expand Down Expand Up @@ -119,9 +122,13 @@ class GoodweSensorEntityDescription(SensorEntityDescription):
)


async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the GoodWe inverter from a config entry."""
entities = []
entities: list[InverterSensor] = []
inverter = hass.data[DOMAIN][config_entry.entry_id][KEY_INVERTER]
coordinator = hass.data[DOMAIN][config_entry.entry_id][KEY_COORDINATOR]
device_info = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE_INFO]
Expand Down
20 changes: 15 additions & 5 deletions homeassistant/components/greenwave/light.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Support for Greenwave Reality (TCP Connected) lights."""
from __future__ import annotations

from datetime import timedelta
import logging
import os
Expand All @@ -13,7 +15,10 @@
LightEntity,
)
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util import Throttle

_LOGGER = logging.getLogger(__name__)
Expand All @@ -29,21 +34,26 @@
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)


def setup_platform(hass, config, add_entities, discovery_info=None):
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Greenwave Reality Platform."""
host = config.get(CONF_HOST)
tokenfile = hass.config.path(".greenwave")
tokenfilename = hass.config.path(".greenwave")
if config.get(CONF_VERSION) == 3:
if os.path.exists(tokenfile):
with open(tokenfile, encoding="utf8") as tokenfile:
if os.path.exists(tokenfilename):
with open(tokenfilename, encoding="utf8") as tokenfile:
token = tokenfile.read()
else:
try:
token = greenwave.grab_token(host, "hass", "homeassistant")
except PermissionError:
_LOGGER.error("The Gateway Is Not In Sync Mode")
raise
with open(tokenfile, "w+", encoding="utf8") as tokenfile:
with open(tokenfilename, "w+", encoding="utf8") as tokenfile:
tokenfile.write(token)
else:
token = None
Expand Down