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
54 changes: 46 additions & 8 deletions homeassistant/components/ecowitt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import dataclasses
from datetime import datetime
import logging
from typing import Final

from aioecowitt import EcoWittSensor, EcoWittSensorTypes
Expand Down Expand Up @@ -39,6 +40,9 @@
from . import EcowittConfigEntry
from .entity import EcowittEntity

_LOGGER = logging.getLogger(__name__)


_METRIC: Final = (
EcoWittSensorTypes.TEMPERATURE_C,
EcoWittSensorTypes.RAIN_COUNT_MM,
Expand All @@ -57,6 +61,40 @@
)


_RAIN_COUNT_SENSORS_STATE_CLASS_MAPPING: Final = {
"eventrainin": SensorStateClass.TOTAL_INCREASING,
"hourlyrainin": None,
"totalrainin": SensorStateClass.TOTAL_INCREASING,
"dailyrainin": SensorStateClass.TOTAL_INCREASING,
"weeklyrainin": SensorStateClass.TOTAL_INCREASING,
"monthlyrainin": SensorStateClass.TOTAL_INCREASING,
"yearlyrainin": SensorStateClass.TOTAL_INCREASING,
"last24hrainin": None,
"eventrainmm": SensorStateClass.TOTAL_INCREASING,
"hourlyrainmm": None,
"totalrainmm": SensorStateClass.TOTAL_INCREASING,
"dailyrainmm": SensorStateClass.TOTAL_INCREASING,
"weeklyrainmm": SensorStateClass.TOTAL_INCREASING,
"monthlyrainmm": SensorStateClass.TOTAL_INCREASING,
"yearlyrainmm": SensorStateClass.TOTAL_INCREASING,
"last24hrainmm": None,
"erain_piezo": SensorStateClass.TOTAL_INCREASING,
"hrain_piezo": None,
"drain_piezo": SensorStateClass.TOTAL_INCREASING,
"wrain_piezo": SensorStateClass.TOTAL_INCREASING,
"mrain_piezo": SensorStateClass.TOTAL_INCREASING,
"yrain_piezo": SensorStateClass.TOTAL_INCREASING,
"last24hrain_piezo": None,
"erain_piezomm": SensorStateClass.TOTAL_INCREASING,
"hrain_piezomm": None,
"drain_piezomm": SensorStateClass.TOTAL_INCREASING,
"wrain_piezomm": SensorStateClass.TOTAL_INCREASING,
"mrain_piezomm": SensorStateClass.TOTAL_INCREASING,
"yrain_piezomm": SensorStateClass.TOTAL_INCREASING,
"last24hrain_piezomm": None,
}


ECOWITT_SENSORS_MAPPING: Final = {
EcoWittSensorTypes.HUMIDITY: SensorEntityDescription(
key="HUMIDITY",
Expand Down Expand Up @@ -285,15 +323,15 @@ def _new_sensor(sensor: EcoWittSensor) -> None:
name=sensor.name,
)

# Only total rain needs state class for long-term statistics
if sensor.key in (
"totalrainin",
"totalrainmm",
if sensor.stype in (
EcoWittSensorTypes.RAIN_COUNT_INCHES,
EcoWittSensorTypes.RAIN_COUNT_MM,
):
description = dataclasses.replace(
description,
state_class=SensorStateClass.TOTAL_INCREASING,
)
if sensor.key not in _RAIN_COUNT_SENSORS_STATE_CLASS_MAPPING:
_LOGGER.warning("Unknown rain count sensor: %s", sensor.key)
return
state_class = _RAIN_COUNT_SENSORS_STATE_CLASS_MAPPING[sensor.key]
description = dataclasses.replace(description, state_class=state_class)

async_add_entities([EcowittSensorEntity(sensor, description)])

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/eheimdigital/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"iot_class": "local_polling",
"loggers": ["eheimdigital"],
"quality_scale": "platinum",
"requirements": ["eheimdigital==1.4.0"],
"requirements": ["eheimdigital==1.5.0"],
"zeroconf": [
{ "name": "eheimdigital._http._tcp.local.", "type": "_http._tcp.local." }
]
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/hue_ble/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"bluetooth": [
{
"connectable": true,
"service_data_uuid": "0000fe0f-0000-1000-8000-00805f9b34fb"
"service_data_uuid": "0000fe0f-0000-1000-8000-00805f9b34fb",
"service_uuid": "0000fe0f-0000-1000-8000-00805f9b34fb"
}
],
"codeowners": ["@flip-dots"],
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tibber/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
key="range.remaining",
translation_key="range_remaining",
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
native_unit_of_measurement=UnitOfLength.METERS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
Expand Down
35 changes: 28 additions & 7 deletions homeassistant/components/xbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import asyncio
import logging

from httpx import HTTPStatusError, RequestError, TimeoutException
Expand All @@ -19,13 +20,15 @@
)
from homeassistant.helpers.httpx_client import get_async_client

from . import api
from .api import AsyncConfigEntryAuth
from .const import DOMAIN
from .coordinator import (
XboxConfigEntry,
XboxConsolesCoordinator,
XboxConsoleStatusCoordinator,
XboxCoordinators,
XboxUpdateCoordinator,
XboxPresenceCoordinator,
)

_LOGGER = logging.getLogger(__name__)
Expand All @@ -44,12 +47,30 @@
async def async_setup_entry(hass: HomeAssistant, entry: XboxConfigEntry) -> bool:
"""Set up xbox from a config entry."""

coordinator = XboxUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()

consoles = XboxConsolesCoordinator(hass, entry, coordinator)

entry.runtime_data = XboxCoordinators(coordinator, consoles)
try:
implementation = await async_get_config_entry_implementation(hass, entry)
except ImplementationUnavailableError as e:
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="oauth2_implementation_unavailable",
) from e

session = OAuth2Session(hass, entry, implementation)
async_session = get_async_client(hass)
auth = api.AsyncConfigEntryAuth(async_session, session)
client = XboxLiveClient(auth)

consoles = XboxConsolesCoordinator(hass, entry, client)
await consoles.async_config_entry_first_refresh()

status = XboxConsoleStatusCoordinator(hass, entry, client, consoles.data)
presence = XboxPresenceCoordinator(hass, entry, client)
await asyncio.gather(
status.async_config_entry_first_refresh(),
presence.async_config_entry_first_refresh(),
)

entry.runtime_data = XboxCoordinators(consoles, status, presence)

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xbox/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up Xbox Live friends."""
coordinator = entry.runtime_data.status
coordinator = entry.runtime_data.presence

if TYPE_CHECKING:
assert entry.unique_id
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xbox/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def async_step_user(
if config_entry.state is not ConfigEntryState.LOADED:
return self.async_abort(reason="config_entry_not_loaded")

client = config_entry.runtime_data.status.client
client = config_entry.runtime_data.presence.client
friends_list = await client.people.get_friends_own()

if user_input is not None:
Expand Down
Loading
Loading