mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Landis+Gyr integration: increase timeout and add debug logging (#78025)
This commit is contained in:
parent
29be6d17b0
commit
93b7f604d5
@ -31,9 +31,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
_LOGGER.info("Polling on %s", entry.data[CONF_DEVICE])
|
_LOGGER.info("Polling on %s", entry.data[CONF_DEVICE])
|
||||||
return await hass.async_add_executor_job(api.read)
|
return await hass.async_add_executor_job(api.read)
|
||||||
|
|
||||||
# No automatic polling and no initial refresh of data is being done at this point,
|
# Polling is only daily to prevent battery drain.
|
||||||
# to prevent battery drain. The user will have to do it manually.
|
|
||||||
|
|
||||||
coordinator = DataUpdateCoordinator(
|
coordinator = DataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
@ -14,7 +14,7 @@ from homeassistant import config_entries
|
|||||||
from homeassistant.const import CONF_DEVICE
|
from homeassistant.const import CONF_DEVICE
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN, ULTRAHEAT_TIMEOUT
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
dev_path = await self.hass.async_add_executor_job(
|
dev_path = await self.hass.async_add_executor_job(
|
||||||
get_serial_by_id, user_input[CONF_DEVICE]
|
get_serial_by_id, user_input[CONF_DEVICE]
|
||||||
)
|
)
|
||||||
|
_LOGGER.debug("Using this path : %s", dev_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await self.validate_and_create_entry(dev_path)
|
return await self.validate_and_create_entry(dev_path)
|
||||||
@ -76,6 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Try to connect to the device path and return an entry."""
|
"""Try to connect to the device path and return an entry."""
|
||||||
model, device_number = await self.validate_ultraheat(dev_path)
|
model, device_number = await self.validate_ultraheat(dev_path)
|
||||||
|
|
||||||
|
_LOGGER.debug("Got model %s and device_number %s", model, device_number)
|
||||||
await self.async_set_unique_id(device_number)
|
await self.async_set_unique_id(device_number)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
data = {
|
data = {
|
||||||
@ -94,7 +96,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
reader = UltraheatReader(port)
|
reader = UltraheatReader(port)
|
||||||
heat_meter = HeatMeterService(reader)
|
heat_meter = HeatMeterService(reader)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with async_timeout.timeout(ULTRAHEAT_TIMEOUT):
|
||||||
# validate and retrieve the model and device number for a unique id
|
# validate and retrieve the model and device number for a unique id
|
||||||
data = await self.hass.async_add_executor_job(heat_meter.read)
|
data = await self.hass.async_add_executor_job(heat_meter.read)
|
||||||
_LOGGER.debug("Got data from Ultraheat API: %s", data)
|
_LOGGER.debug("Got data from Ultraheat API: %s", data)
|
||||||
|
@ -11,6 +11,7 @@ from homeassistant.helpers.entity import EntityCategory
|
|||||||
DOMAIN = "landisgyr_heat_meter"
|
DOMAIN = "landisgyr_heat_meter"
|
||||||
|
|
||||||
GJ_TO_MWH = 0.277778 # conversion factor
|
GJ_TO_MWH = 0.277778 # conversion factor
|
||||||
|
ULTRAHEAT_TIMEOUT = 30 # reading the IR port can take some time
|
||||||
|
|
||||||
HEAT_METER_SENSOR_TYPES = (
|
HEAT_METER_SENSOR_TYPES = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user