Update Solax Library to 0.2.2 (#26705)
* bump version and adjust * Address review comments * Fix import order * bump solax version * Trigger Azure * default port
This commit is contained in:
parent
44cde5fb73
commit
0e201fd859
3 changed files with 18 additions and 14 deletions
|
@ -3,7 +3,7 @@
|
|||
"name": "Solax Inverter",
|
||||
"documentation": "https://www.home-assistant.io/components/solax",
|
||||
"requirements": [
|
||||
"solax==0.1.2"
|
||||
"solax==0.2.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@squishykid"]
|
||||
|
|
|
@ -4,9 +4,11 @@ import asyncio
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from solax import real_time_api
|
||||
from solax.inverter import InverterError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import TEMP_CELSIUS, CONF_IP_ADDRESS
|
||||
from homeassistant.const import TEMP_CELSIUS, CONF_IP_ADDRESS, CONF_PORT
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
|
@ -15,24 +17,28 @@ from homeassistant.helpers.event import async_track_time_interval
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_IP_ADDRESS): cv.string})
|
||||
DEFAULT_PORT = 80
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_IP_ADDRESS): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
}
|
||||
)
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Platform setup."""
|
||||
import solax
|
||||
|
||||
api = solax.RealTimeAPI(config[CONF_IP_ADDRESS])
|
||||
api = await real_time_api(config[CONF_IP_ADDRESS], config[CONF_PORT])
|
||||
endpoint = RealTimeDataEndpoint(hass, api)
|
||||
resp = await api.get_data()
|
||||
serial = resp.serial_number
|
||||
hass.async_add_job(endpoint.async_refresh)
|
||||
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
|
||||
devices = []
|
||||
for sensor in solax.INVERTER_SENSORS:
|
||||
idx, unit = solax.INVERTER_SENSORS[sensor]
|
||||
for sensor, (idx, unit) in api.inverter.sensor_map().items():
|
||||
if unit == "C":
|
||||
unit = TEMP_CELSIUS
|
||||
uid = f"{serial}-{idx}"
|
||||
|
@ -56,16 +62,14 @@ class RealTimeDataEndpoint:
|
|||
|
||||
This is the only method that should fetch new data for Home Assistant.
|
||||
"""
|
||||
from solax import SolaxRequestError
|
||||
|
||||
try:
|
||||
api_response = await self.api.get_data()
|
||||
self.ready.set()
|
||||
except SolaxRequestError:
|
||||
except InverterError:
|
||||
if now is not None:
|
||||
self.ready.clear()
|
||||
else:
|
||||
raise PlatformNotReady
|
||||
return
|
||||
raise PlatformNotReady
|
||||
data = api_response.data
|
||||
for sensor in self.sensors:
|
||||
if sensor.key in data:
|
||||
|
|
|
@ -1785,7 +1785,7 @@ solaredge-local==0.1.4
|
|||
solaredge==0.0.2
|
||||
|
||||
# homeassistant.components.solax
|
||||
solax==0.1.2
|
||||
solax==0.2.2
|
||||
|
||||
# homeassistant.components.honeywell
|
||||
somecomfort==0.5.2
|
||||
|
|
Loading…
Add table
Reference in a new issue