Skip to content

Commit

Permalink
Rebuild the updating of the sensors
Browse files Browse the repository at this point in the history
The sensors are now updated using a UpdateCoordinator.

This function determines if the sensors need updating based on if there is any new information available.
  • Loading branch information
ProudElm committed Jan 10, 2023
1 parent 30ed864 commit 7ea6b24
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 472 deletions.
2 changes: 1 addition & 1 deletion custom_components/solaredgeoptimizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .solaredgeoptimizers import solaredgeoptimizers
from solaredgeoptimizers import solaredgeoptimizers
from .const import CONF_SITE_ID, DOMAIN, LOGGER, DATA_API_CLIENT, PANEEL_DATA

PLATFORMS: list[Platform] = [Platform.SENSOR]
Expand Down
8 changes: 3 additions & 5 deletions custom_components/solaredgeoptimizers/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from homeassistant.exceptions import HomeAssistantError

from .const import DOMAIN
from .solaredgeoptimizers import solaredgeoptimizers

from solaredgeoptimizers import solaredgeoptimizers

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -42,11 +43,8 @@ async def authenticate(
# http_result_code = api.check_login()
http_result_code = await hass.async_add_executor_job(api.check_login)
if http_result_code == 200:
# All is well
# print("All is well")
return True
else:
# print("All is NOT well")
return False


Expand All @@ -61,7 +59,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
raise InvalidAuth

# Return info that you want to store in the config entry.
return {"title": "SolarEdge Transformer"}
return {"title": "SolarEdge Site {}".format(data["siteid"])}


class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down
6 changes: 2 additions & 4 deletions custom_components/solaredgeoptimizers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from datetime import timedelta
import logging

# from datetime import timedelta


DOMAIN = "solaredgeoptimizers"
CONF_SITE_ID = "siteid"
DATA_API_CLIENT = "api_client"
Expand All @@ -15,16 +12,17 @@

UPDATE_DELAY = timedelta(minutes=15)

# SENSOR_TYPE = ["current", "optimizer_voltage", "power", "voltage"]
SENSOR_TYPE_CURRENT = "Current"
SENSOR_TYPE_OPT_VOLTAGE = "Optimizer_voltage"
SENSOR_TYPE_POWER = "Power"
SENSOR_TYPE_VOLTAGE = "Voltage"
SENSOR_TYPE_ENERGY = "Lifetime_energy"
SENSOR_TYPE_LASTMEASUREMENT = "Last_Measurement"
SENSOR_TYPE = [
SENSOR_TYPE_CURRENT,
SENSOR_TYPE_OPT_VOLTAGE,
SENSOR_TYPE_POWER,
SENSOR_TYPE_VOLTAGE,
SENSOR_TYPE_ENERGY,
SENSOR_TYPE_LASTMEASUREMENT,
]
12 changes: 7 additions & 5 deletions custom_components/solaredgeoptimizers/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"domain": "solaredgeoptimizers",
"name": "SolarEdge Optimizers Data",
"config_flow": true,
"documentation": "https://github.com/ProudElm/solaredgeoptimizers",
"issue_tracker": "https://github.com/ProudElm/solaredgeoptimizers/issues",
"requirements": ["jsonfinder==0.4.2"],
"documentation": "https://www.home-assistant.io/integrations/solaredgeoptimizers",
"requirements": [
"solaredgeoptimizers==1.0.8",
"jsonfinder==0.4.2"
],
"ssdp": [],
"zeroconf": [],
"homekit": {},
Expand All @@ -13,5 +15,5 @@
"@proudelm"
],
"iot_class": "cloud_polling",
"version": "1.1.4"
}
"version": "1.1.9"
}
Loading

0 comments on commit 7ea6b24

Please sign in to comment.