mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
mill
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
This commit is contained in:
parent
182f8b33f7
commit
29c68f3615
@ -24,7 +24,10 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.entity_platform import (
|
||||
AddEntitiesCallback,
|
||||
async_get_current_platform,
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
@ -53,12 +56,6 @@ SET_ROOM_TEMP_SCHEMA = vol.Schema(
|
||||
vol.Optional(ATTR_SLEEP_TEMP): cv.positive_int,
|
||||
}
|
||||
)
|
||||
LIMIT_HEATING_POWER_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
|
||||
vol.Required(ATTR_MAX_HEATING_POWER): vol.Range(min=0, max=2000),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
@ -93,23 +90,19 @@ async def async_setup_entry(
|
||||
DOMAIN, SERVICE_SET_ROOM_TEMP, set_room_temp, schema=SET_ROOM_TEMP_SCHEMA
|
||||
)
|
||||
|
||||
async def max_heating_power(service: ServiceCall) -> None:
|
||||
async def max_heating_power(entity: MillHeater, service: ServiceCall) -> None:
|
||||
"""Limit heating power."""
|
||||
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||
heating_power = service.data.get(ATTR_MAX_HEATING_POWER)
|
||||
for entity in entities:
|
||||
if entity.entity_id == entity_id:
|
||||
await mill_data_coordinator.mill_data_connection.max_heating_power(
|
||||
entity.heater_id, heating_power
|
||||
)
|
||||
return
|
||||
raise ValueError(f"Entity id {entity_id} not found")
|
||||
await mill_data_coordinator.mill_data_connection.max_heating_power(
|
||||
entity.heater_id, service.data[ATTR_MAX_HEATING_POWER]
|
||||
)
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN,
|
||||
async_get_current_platform().async_register_entity_service(
|
||||
SERVICE_MAX_HEATING_POWER,
|
||||
max_heating_power,
|
||||
schema=LIMIT_HEATING_POWER_SCHEMA,
|
||||
schema={
|
||||
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
|
||||
vol.Required(ATTR_MAX_HEATING_POWER): vol.Range(min=0, max=2000),
|
||||
},
|
||||
func=max_heating_power,
|
||||
)
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ class MillDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
hourly_data = (
|
||||
await self.mill_data_connection.fetch_historic_energy_usage(dev_id)
|
||||
)
|
||||
hourly_data = dict(sorted(hourly_data.items(), key=lambda x: x[0]))
|
||||
_sum = 0.0
|
||||
last_stats_time = None
|
||||
else:
|
||||
@ -84,15 +85,18 @@ class MillDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
last_stats[statistic_id][0]["start"]
|
||||
)
|
||||
).days
|
||||
+ 1,
|
||||
+ 2,
|
||||
)
|
||||
)
|
||||
if not hourly_data:
|
||||
return
|
||||
hourly_data = dict(sorted(hourly_data.items(), key=lambda x: x[0]))
|
||||
start_time = next(iter(hourly_data))
|
||||
|
||||
stats = await get_instance(self.hass).async_add_executor_job(
|
||||
statistics_during_period,
|
||||
self.hass,
|
||||
next(iter(hourly_data)),
|
||||
start_time,
|
||||
None,
|
||||
{statistic_id},
|
||||
"hour",
|
||||
|
@ -7,5 +7,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/mill",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["mill", "mill_local"],
|
||||
"requirements": ["millheater==0.12.0", "mill-local==0.3.0"]
|
||||
"requirements": ["millheater==0.12.1", "mill-local==0.3.0"]
|
||||
}
|
||||
|
@ -1373,7 +1373,7 @@ microBeesPy==0.3.2
|
||||
mill-local==0.3.0
|
||||
|
||||
# homeassistant.components.mill
|
||||
millheater==0.12.0
|
||||
millheater==0.12.1
|
||||
|
||||
# homeassistant.components.minio
|
||||
minio==7.1.12
|
||||
|
@ -1142,7 +1142,7 @@ microBeesPy==0.3.2
|
||||
mill-local==0.3.0
|
||||
|
||||
# homeassistant.components.mill
|
||||
millheater==0.12.0
|
||||
millheater==0.12.1
|
||||
|
||||
# homeassistant.components.minio
|
||||
minio==7.1.12
|
||||
|
Loading…
x
Reference in New Issue
Block a user