Skip to content

Commit 9e64f18

Browse files
authored
Fix bug with the wrong temperature scale on new router firmware (asuswrt) (#151011)
1 parent e8a6f2f commit 9e64f18

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

homeassistant/components/asuswrt/bridge.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from aioasuswrt.asuswrt import AsusWrt as AsusWrtLegacy
1313
from aiohttp import ClientSession
1414
from asusrouter import AsusRouter, AsusRouterError
15+
from asusrouter.config import ARConfigKey
1516
from asusrouter.modules.client import AsusClient
1617
from asusrouter.modules.data import AsusData
1718
from asusrouter.modules.homeassistant import convert_to_ha_data, convert_to_ha_sensors
@@ -314,10 +315,14 @@ class AsusWrtHttpBridge(AsusWrtBridge):
314315
def __init__(self, conf: dict[str, Any], session: ClientSession) -> None:
315316
"""Initialize Bridge that use HTTP library."""
316317
super().__init__(conf[CONF_HOST])
317-
self._api = self._get_api(conf, session)
318+
# Get API configuration
319+
config = self._get_api_config()
320+
self._api = self._get_api(conf, session, config)
318321

319322
@staticmethod
320-
def _get_api(conf: dict[str, Any], session: ClientSession) -> AsusRouter:
323+
def _get_api(
324+
conf: dict[str, Any], session: ClientSession, config: dict[ARConfigKey, Any]
325+
) -> AsusRouter:
321326
"""Get the AsusRouter API."""
322327
return AsusRouter(
323328
hostname=conf[CONF_HOST],
@@ -326,8 +331,19 @@ def _get_api(conf: dict[str, Any], session: ClientSession) -> AsusRouter:
326331
use_ssl=conf[CONF_PROTOCOL] == PROTOCOL_HTTPS,
327332
port=conf.get(CONF_PORT),
328333
session=session,
334+
config=config,
329335
)
330336

337+
def _get_api_config(self) -> dict[ARConfigKey, Any]:
338+
"""Get configuration for the API."""
339+
return {
340+
# Enable automatic temperature data correction in the library
341+
ARConfigKey.OPTIMISTIC_TEMPERATURE: True,
342+
# Disable `warning`-level log message when temperature
343+
# is corrected by setting it to already notified.
344+
ARConfigKey.NOTIFIED_OPTIMISTIC_TEMPERATURE: True,
345+
}
346+
331347
@property
332348
def is_connected(self) -> bool:
333349
"""Get connected status."""

0 commit comments

Comments
 (0)