Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 custom_components/foxess_export_control/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"domain":"foxess_export_control","name":"FoxESS Export Control","codeowners":["@MrHC1983"],"config_flow":true,"documentation":"https://github.com/MrHC1983/FoxESS-Export-Control","iot_class":"cloud_polling","issue_tracker":"https://github.com/MrHC1983/FoxESS-Export-Control/issues","requirements":[],"version":"0.1.0"}
{"domain":"foxess_export_control","name":"FoxESS Export Control","codeowners":["@MrHC1983"],"config_flow":true,"documentation":"https://github.com/MrHC1983/FoxESS-Export-Control","iot_class":"cloud_polling","issue_tracker":"https://github.com/MrHC1983/FoxESS-Export-Control/issues","requirements":[],"version":"0.1.1"}
7 changes: 5 additions & 2 deletions custom_components/foxess_export_control/number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from datetime import timedelta
from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfPower
Expand All @@ -14,7 +15,7 @@ async def async_setup_entry(hass:HomeAssistant,entry:ConfigEntry,async_add_entit
async def update():
try:return await api.get_export_limit()
except FoxESSApiError as e:raise UpdateFailed(str(e)) from e
coordinator=DataUpdateCoordinator(hass,_LOGGER,name=f"FoxESS Export Limit {entry.data[CONF_DEVICE_SN]}",update_method=update,update_interval=None)
coordinator=DataUpdateCoordinator(hass,_LOGGER,name=f"FoxESS Export Limit {entry.data[CONF_DEVICE_SN]}",update_method=update,update_interval=timedelta(minutes=5))
await coordinator.async_config_entry_first_refresh()
async_add_entities([FoxESSExportLimitNumber(coordinator,api,entry)])
class FoxESSExportLimitNumber(CoordinatorEntity,NumberEntity):
Expand All @@ -31,4 +32,6 @@ def __init__(self,coordinator,api,entry):
def native_value(self): return self.coordinator.data
async def async_set_native_value(self,value:float):
value=max(MIN_EXPORT_LIMIT,min(MAX_EXPORT_LIMIT,int(round(value/EXPORT_STEP)*EXPORT_STEP)))
await self._api.set_export_limit(value); self.coordinator.async_set_updated_data(value)
await self._api.set_export_limit(value)
# Read the authoritative cloud setting instead of assuming the write stuck.
await self.coordinator.async_refresh()
Loading