Skip to content

Commit

Permalink
Merge branch 'dev' into mqtt-device-based-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh authored Jul 30, 2024
2 parents 3959c27 + da18aae commit 977d014
Show file tree
Hide file tree
Showing 100 changed files with 2,384 additions and 431 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/advantage_air/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ async def async_turn_off(self) -> None:
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the HVAC Mode and State."""
if hvac_mode == HVACMode.OFF:
return await self.async_turn_off()
await self.async_turn_off()
return
if hvac_mode == HVACMode.HEAT_COOL and self.preset_mode != ADVANTAGE_AIR_MYAUTO:
raise ServiceValidationError("Heat/Cool is not supported in this mode")
await self.async_update_ac(
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/airtouch4/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
raise ValueError(f"Unsupported HVAC mode: {hvac_mode}")

if hvac_mode == HVACMode.OFF:
return await self.async_turn_off()
await self.async_turn_off()
return
await self._airtouch.SetCoolingModeForAc(
self._ac_number, HA_STATE_TO_AT[hvac_mode]
)
Expand Down Expand Up @@ -262,7 +263,8 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
raise ValueError(f"Unsupported HVAC mode: {hvac_mode}")

if hvac_mode == HVACMode.OFF:
return await self.async_turn_off()
await self.async_turn_off()
return
if self.hvac_mode == HVACMode.OFF:
await self.async_turn_on()
self._unit = self._airtouch.GetGroups()[self._group_number]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/apsystems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .const import DEFAULT_PORT
from .coordinator import ApSystemsDataCoordinator

PLATFORMS: list[Platform] = [Platform.NUMBER, Platform.SENSOR]
PLATFORMS: list[Platform] = [Platform.NUMBER, Platform.SENSOR, Platform.SWITCH]


@dataclass
Expand Down
45 changes: 35 additions & 10 deletions homeassistant/components/apsystems/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,43 @@
},
"entity": {
"sensor": {
"total_power": { "name": "Total power" },
"total_power_p1": { "name": "Power of P1" },
"total_power_p2": { "name": "Power of P2" },
"lifetime_production": { "name": "Total lifetime production" },
"lifetime_production_p1": { "name": "Lifetime production of P1" },
"lifetime_production_p2": { "name": "Lifetime production of P2" },
"today_production": { "name": "Production of today" },
"today_production_p1": { "name": "Production of today from P1" },
"today_production_p2": { "name": "Production of today from P2" }
"total_power": {
"name": "Total power"
},
"total_power_p1": {
"name": "Power of P1"
},
"total_power_p2": {
"name": "Power of P2"
},
"lifetime_production": {
"name": "Total lifetime production"
},
"lifetime_production_p1": {
"name": "Lifetime production of P1"
},
"lifetime_production_p2": {
"name": "Lifetime production of P2"
},
"today_production": {
"name": "Production of today"
},
"today_production_p1": {
"name": "Production of today from P1"
},
"today_production_p2": {
"name": "Production of today from P2"
}
},
"number": {
"max_output": { "name": "Max output" }
"max_output": {
"name": "Max output"
}
},
"switch": {
"inverter_status": {
"name": "Inverter status"
}
}
}
}
56 changes: 56 additions & 0 deletions homeassistant/components/apsystems/switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""The power switch which can be toggled via the APsystems local API integration."""

from __future__ import annotations

from typing import Any

from aiohttp.client_exceptions import ClientConnectionError
from APsystemsEZ1 import Status

from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ApSystemsConfigEntry, ApSystemsData
from .entity import ApSystemsEntity


async def async_setup_entry(
hass: HomeAssistant,
config_entry: ApSystemsConfigEntry,
add_entities: AddEntitiesCallback,
) -> None:
"""Set up the switch platform."""

add_entities([ApSystemsInverterSwitch(config_entry.runtime_data)], True)


class ApSystemsInverterSwitch(ApSystemsEntity, SwitchEntity):
"""The switch class for APSystems switches."""

_attr_device_class = SwitchDeviceClass.SWITCH
_attr_translation_key = "inverter_status"

def __init__(self, data: ApSystemsData) -> None:
"""Initialize the switch."""
super().__init__(data)
self._api = data.coordinator.api
self._attr_unique_id = f"{data.device_id}_inverter_status"

async def async_update(self) -> None:
"""Update switch status and availability."""
try:
status = await self._api.get_device_power_status()
except (TimeoutError, ClientConnectionError):
self._attr_available = False
else:
self._attr_available = True
self._attr_is_on = status == Status.normal

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
await self._api.set_device_power_status(0)

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the switch off."""
await self._api.set_device_power_status(1)
5 changes: 2 additions & 3 deletions homeassistant/components/command_line/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any, cast
from typing import Any, cast

from homeassistant.components.cover import CoverEntity
from homeassistant.const import (
Expand Down Expand Up @@ -145,8 +145,7 @@ async def _async_query_state(self) -> str | None:
if self._command_state:
LOGGER.info("Running state value command: %s", self._command_state)
return await async_check_output_or_log(self._command_state, self._timeout)
if TYPE_CHECKING:
return None
return None

async def _update_entity_state(self, now: datetime | None = None) -> None:
"""Update the state of the entity."""
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/command_line/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any, cast
from typing import Any, cast

from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
from homeassistant.const import (
Expand Down Expand Up @@ -147,8 +147,7 @@ async def _async_query_state(self) -> str | int | None:
if self._value_template:
return await self._async_query_state_value(self._command_state)
return await self._async_query_state_code(self._command_state)
if TYPE_CHECKING:
return None
return None

async def _update_entity_state(self, now: datetime | None = None) -> None:
"""Update the state of the entity."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/conversation",
"integration_type": "system",
"quality_scale": "internal",
"requirements": ["hassil==1.7.4", "home-assistant-intents==2024.7.10"]
"requirements": ["hassil==1.7.4", "home-assistant-intents==2024.7.29"]
}
1 change: 1 addition & 0 deletions homeassistant/components/ddwrt/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def get_ddwrt_data(self, url):
)
return None
_LOGGER.error("Invalid response from DD-WRT: %s", response)
return None


def _parse_ddwrt_response(data_str):
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/deconz/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def async_update_callback(self) -> None:
async def async_set_percentage(self, percentage: int) -> None:
"""Set the speed percentage of the fan."""
if percentage == 0:
return await self.async_turn_off()
await self.async_turn_off()
return
await self.hub.api.lights.lights.set_state(
id=self._device.resource_id,
fan_speed=percentage_to_ordered_list_item(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/denon/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,12 @@ def supported_features(self) -> MediaPlayerEntityFeature:
return SUPPORT_DENON

@property
def source(self):
def source(self) -> str | None:
"""Return the current input source."""
for pretty_name, name in self._source_list.items():
if self._mediasource == name:
return pretty_name
return None

def turn_off(self) -> None:
"""Turn off media player."""
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from .const import CONNECTED_PLC_DEVICES, CONNECTED_TO_ROUTER
from .entity import DevoloCoordinatorEntity

PARALLEL_UPDATES = 1


def _is_connected_to_router(entity: DevoloBinarySensorEntity) -> bool:
"""Check, if device is attached to the router."""
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from .const import DOMAIN, IDENTIFY, PAIRING, RESTART, START_WPS
from .entity import DevoloEntity

PARALLEL_UPDATES = 1


@dataclass(frozen=True, kw_only=True)
class DevoloButtonEntityDescription(ButtonEntityDescription):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from . import DevoloHomeNetworkConfigEntry
from .const import CONNECTED_WIFI_CLIENTS, DOMAIN, WIFI_APTYPE, WIFI_BANDS

PARALLEL_UPDATES = 1


async def async_setup_entry(
hass: HomeAssistant,
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from .const import IMAGE_GUEST_WIFI, SWITCH_GUEST_WIFI
from .entity import DevoloCoordinatorEntity

PARALLEL_UPDATES = 1


@dataclass(frozen=True, kw_only=True)
class DevoloImageEntityDescription(ImageEntityDescription):
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
)
from .entity import DevoloCoordinatorEntity

PARALLEL_UPDATES = 1

_CoordinatorDataT = TypeVar(
"_CoordinatorDataT",
bound=LogicalNetwork | DataRate | list[ConnectedStationInfo] | list[NeighborAPInfo],
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from .const import DOMAIN, SWITCH_GUEST_WIFI, SWITCH_LEDS
from .entity import DevoloCoordinatorEntity

PARALLEL_UPDATES = 1

_DataT = TypeVar("_DataT", bound=WifiGuestAccessGet | bool)


Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/devolo_home_network/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from .const import DOMAIN, REGULAR_FIRMWARE
from .entity import DevoloCoordinatorEntity

PARALLEL_UPDATES = 1


@dataclass(frozen=True, kw_only=True)
class DevoloUpdateEntityDescription(UpdateEntityDescription):
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/dialogflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def get_api_version(message):
if message.get("responseId") is not None:
return V2

raise ValueError(f"Unable to extract API version from message: {message}")


async def async_handle_message(hass, message):
"""Handle a DialogFlow message."""
Expand Down Expand Up @@ -173,3 +175,5 @@ def as_dict(self):

if self.api_version is V2:
return {"fulfillmentText": self.speech, "source": SOURCE}

raise ValueError(f"Invalid API version: {self.api_version}")
2 changes: 1 addition & 1 deletion homeassistant/components/dsmr/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"integration_type": "hub",
"iot_class": "local_push",
"loggers": ["dsmr_parser"],
"requirements": ["dsmr-parser==1.3.1"]
"requirements": ["dsmr-parser==1.4.2"]
}
Loading

0 comments on commit 977d014

Please sign in to comment.