mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Poll econet water heater once an hour (#90961)
This commit is contained in:
parent
669b347ed1
commit
b4553f19a1
@ -1,4 +1,5 @@
|
||||
"""Support for EcoNet products."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
@ -80,14 +81,11 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
await hass.async_add_executor_job(api.unsubscribe)
|
||||
api.subscribe()
|
||||
|
||||
async def fetch_update(now):
|
||||
"""Fetch the latest changes from the API."""
|
||||
# Refresh values
|
||||
await asyncio.sleep(60)
|
||||
await api.refresh_equipment()
|
||||
|
||||
config_entry.async_on_unload(async_track_time_interval(hass, resubscribe, INTERVAL))
|
||||
config_entry.async_on_unload(
|
||||
async_track_time_interval(hass, fetch_update, INTERVAL + timedelta(minutes=1))
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -64,6 +64,7 @@ async def async_setup_entry(
|
||||
class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
||||
"""Define an Econet thermostat."""
|
||||
|
||||
_attr_should_poll = True
|
||||
_attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||
|
||||
def __init__(self, thermostat):
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Support for Rheem EcoNet water heaters."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
@ -17,12 +18,14 @@ from homeassistant.components.water_heater import (
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import EcoNetEntity
|
||||
from .const import DOMAIN, EQUIPMENT
|
||||
|
||||
SCAN_INTERVAL = timedelta(hours=1)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ECONET_STATE_TO_HA = {
|
||||
@ -52,6 +55,7 @@ async def async_setup_entry(
|
||||
EcoNetWaterHeater(water_heater)
|
||||
for water_heater in equipment[EquipmentType.WATER_HEATER]
|
||||
],
|
||||
update_before_add=True,
|
||||
)
|
||||
|
||||
|
||||
@ -64,18 +68,8 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity):
|
||||
def __init__(self, water_heater):
|
||||
"""Initialize."""
|
||||
super().__init__(water_heater)
|
||||
self._running = water_heater.running
|
||||
self.water_heater = water_heater
|
||||
|
||||
@callback
|
||||
def on_update_received(self):
|
||||
"""Update was pushed from the econet API."""
|
||||
if self._running != self.water_heater.running:
|
||||
# Water heater running state has changed so check usage on next update
|
||||
self._attr_should_poll = True
|
||||
self._running = self.water_heater.running
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
"""Return true if away mode is on."""
|
||||
@ -153,8 +147,6 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity):
|
||||
"""Get the latest energy usage."""
|
||||
await self.water_heater.get_energy_usage()
|
||||
await self.water_heater.get_water_usage()
|
||||
self.async_write_ha_state()
|
||||
self._attr_should_poll = False
|
||||
|
||||
def turn_away_mode_on(self) -> None:
|
||||
"""Turn away mode on."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user