Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/solax/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Solax Inverter",
"documentation": "https://www.home-assistant.io/components/solax",
"requirements": [
"solax==0.1.2"
"solax==0.2.1"
],
"dependencies": [],
"codeowners": ["@squishykid"]
Expand Down
19 changes: 12 additions & 7 deletions homeassistant/components/solax/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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
Expand All @@ -15,7 +15,12 @@

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_IP_ADDRESS): cv.string})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_IP_ADDRESS): cv.string,
vol.Optional(CONF_PORT, default=80): cv.positive_int,
Comment thread
squishykid marked this conversation as resolved.
Outdated
}
)

SCAN_INTERVAL = timedelta(seconds=30)

Expand All @@ -24,15 +29,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
"""Platform setup."""
import solax

api = solax.RealTimeAPI(config[CONF_IP_ADDRESS])
api = await solax.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}"
Expand All @@ -56,14 +60,15 @@ async def async_refresh(self, now=None):

This is the only method that should fetch new data for Home Assistant.
"""
from solax import SolaxRequestError
from solax.inverter import InverterError
Comment thread
squishykid marked this conversation as resolved.
Outdated

try:
api_response = await self.api.get_data()
self.ready.set()
except SolaxRequestError:
except InverterError:
if now is not None:
self.ready.clear()
return
else:
raise PlatformNotReady
data = api_response.data
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ solaredge-local==0.1.4
solaredge==0.0.2

# homeassistant.components.solax
solax==0.1.2
solax==0.2.1

# homeassistant.components.honeywell
somecomfort==0.5.2
Expand Down