Compare commits
2 Commits
407bc40219
...
a6707b849b
| Author | SHA1 | Date |
|---|---|---|
|
|
a6707b849b | |
|
|
6a913cf447 |
|
|
@ -1,4 +1,5 @@
|
||||||
"""The Sencor SWS 12500 Weather Station integration."""
|
"""The Sencor SWS 12500 Weather Station integration."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
@ -74,7 +75,9 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
||||||
if sensors := check_disabled(self.hass, remaped_items, self.config):
|
if sensors := check_disabled(self.hass, remaped_items, self.config):
|
||||||
translate_sensors = [
|
translate_sensors = [
|
||||||
await translations(self.hass, DOMAIN, f"sensor.{t_key}", key="name", category="entity")
|
await translations(
|
||||||
|
self.hass, DOMAIN, f"sensor.{t_key}", key="name", category="entity"
|
||||||
|
)
|
||||||
for t_key in sensors
|
for t_key in sensors
|
||||||
]
|
]
|
||||||
human_readable = "\n".join(translate_sensors)
|
human_readable = "\n".join(translate_sensors)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
PURGE_DATA,
|
PURGE_DATA,
|
||||||
|
|
@ -69,6 +68,9 @@ class WindyPush:
|
||||||
) -> WindyNotInserted | WindySuccess | WindyApiKeyError | None:
|
) -> WindyNotInserted | WindySuccess | WindyApiKeyError | None:
|
||||||
"""Verify answer form Windy."""
|
"""Verify answer form Windy."""
|
||||||
|
|
||||||
|
if self.log:
|
||||||
|
_LOGGER.info("Windy response raw response: %s", response)
|
||||||
|
|
||||||
if "NOTICE" in response:
|
if "NOTICE" in response:
|
||||||
raise WindyNotInserted
|
raise WindyNotInserted
|
||||||
|
|
||||||
|
|
@ -78,6 +80,9 @@ class WindyPush:
|
||||||
if "Invalid API key" in response:
|
if "Invalid API key" in response:
|
||||||
raise WindyApiKeyError
|
raise WindyApiKeyError
|
||||||
|
|
||||||
|
if "Unauthorized" in response:
|
||||||
|
raise WindyApiKeyError
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def push_data_to_windy(self, data):
|
async def push_data_to_windy(self, data):
|
||||||
|
|
@ -116,10 +121,7 @@ class WindyPush:
|
||||||
|
|
||||||
if self.log:
|
if self.log:
|
||||||
_LOGGER.info("Dataset for windy: %s", purged_data)
|
_LOGGER.info("Dataset for windy: %s", purged_data)
|
||||||
|
session = async_get_clientsession(self.hass, verify_ssl=False)
|
||||||
async with aiohttp.ClientSession(
|
|
||||||
connector=aiohttp.TCPConnector(ssl=False), trust_env=True
|
|
||||||
) as session: # verify_ssl=False; intended to be False
|
|
||||||
try:
|
try:
|
||||||
async with session.get(request_url, params=purged_data) as resp:
|
async with session.get(request_url, params=purged_data) as resp:
|
||||||
status = await resp.text()
|
status = await resp.text()
|
||||||
|
|
@ -143,7 +145,7 @@ class WindyPush:
|
||||||
_LOGGER.info(WINDY_SUCCESS)
|
_LOGGER.info(WINDY_SUCCESS)
|
||||||
text_for_test = WINDY_SUCCESS
|
text_for_test = WINDY_SUCCESS
|
||||||
|
|
||||||
except aiohttp.ClientConnectionError as ex:
|
except session.ClientError as ex:
|
||||||
_LOGGER.critical("Invalid response from Windy: %s", str(ex))
|
_LOGGER.critical("Invalid response from Windy: %s", str(ex))
|
||||||
self.invalid_response_count += 1
|
self.invalid_response_count += 1
|
||||||
if self.invalid_response_count > 3:
|
if self.invalid_response_count > 3:
|
||||||
|
|
@ -156,6 +158,7 @@ class WindyPush:
|
||||||
|
|
||||||
if self.log:
|
if self.log:
|
||||||
_LOGGER.info("Next update: %s", str(self.next_update))
|
_LOGGER.info("Next update: %s", str(self.next_update))
|
||||||
|
|
||||||
if RESPONSE_FOR_TEST and text_for_test:
|
if RESPONSE_FOR_TEST and text_for_test:
|
||||||
return text_for_test
|
return text_for_test
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue