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",
|
"name": "Solax Inverter",
|
||||||
"documentation": "https://www.home-assistant.io/components/solax",
|
"documentation": "https://www.home-assistant.io/components/solax",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"solax==0.1.2"
|
"solax==0.2.2"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": ["@squishykid"]
|
"codeowners": ["@squishykid"]
|
||||||
|
|
|
@ -4,9 +4,11 @@ import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from solax import real_time_api
|
||||||
|
from solax.inverter import InverterError
|
||||||
import voluptuous as vol
|
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
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
|
@ -15,24 +17,28 @@ from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Platform setup."""
|
"""Platform setup."""
|
||||||
import solax
|
api = await real_time_api(config[CONF_IP_ADDRESS], config[CONF_PORT])
|
||||||
|
|
||||||
api = solax.RealTimeAPI(config[CONF_IP_ADDRESS])
|
|
||||||
endpoint = RealTimeDataEndpoint(hass, api)
|
endpoint = RealTimeDataEndpoint(hass, api)
|
||||||
resp = await api.get_data()
|
resp = await api.get_data()
|
||||||
serial = resp.serial_number
|
serial = resp.serial_number
|
||||||
hass.async_add_job(endpoint.async_refresh)
|
hass.async_add_job(endpoint.async_refresh)
|
||||||
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
|
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
|
||||||
devices = []
|
devices = []
|
||||||
for sensor in solax.INVERTER_SENSORS:
|
for sensor, (idx, unit) in api.inverter.sensor_map().items():
|
||||||
idx, unit = solax.INVERTER_SENSORS[sensor]
|
|
||||||
if unit == "C":
|
if unit == "C":
|
||||||
unit = TEMP_CELSIUS
|
unit = TEMP_CELSIUS
|
||||||
uid = f"{serial}-{idx}"
|
uid = f"{serial}-{idx}"
|
||||||
|
@ -56,16 +62,14 @@ class RealTimeDataEndpoint:
|
||||||
|
|
||||||
This is the only method that should fetch new data for Home Assistant.
|
This is the only method that should fetch new data for Home Assistant.
|
||||||
"""
|
"""
|
||||||
from solax import SolaxRequestError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api_response = await self.api.get_data()
|
api_response = await self.api.get_data()
|
||||||
self.ready.set()
|
self.ready.set()
|
||||||
except SolaxRequestError:
|
except InverterError:
|
||||||
if now is not None:
|
if now is not None:
|
||||||
self.ready.clear()
|
self.ready.clear()
|
||||||
else:
|
return
|
||||||
raise PlatformNotReady
|
raise PlatformNotReady
|
||||||
data = api_response.data
|
data = api_response.data
|
||||||
for sensor in self.sensors:
|
for sensor in self.sensors:
|
||||||
if sensor.key in data:
|
if sensor.key in data:
|
||||||
|
|
|
@ -1785,7 +1785,7 @@ solaredge-local==0.1.4
|
||||||
solaredge==0.0.2
|
solaredge==0.0.2
|
||||||
|
|
||||||
# homeassistant.components.solax
|
# homeassistant.components.solax
|
||||||
solax==0.1.2
|
solax==0.2.2
|
||||||
|
|
||||||
# homeassistant.components.honeywell
|
# homeassistant.components.honeywell
|
||||||
somecomfort==0.5.2
|
somecomfort==0.5.2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue