diff --git a/custom_components/solarman/api.py b/custom_components/solarman/api.py index 7d89b10..8994606 100644 --- a/custom_components/solarman/api.py +++ b/custom_components/solarman/api.py @@ -42,9 +42,9 @@ class Inverter(PySolarmanV5AsyncWrapper): def __init__(self, address, serial, port, mb_slave_id, passthrough): super().__init__(address, serial, port, mb_slave_id, passthrough) self._is_reading = 0 - self.status_updated = datetime.now() - self.status_interval = 0 - self.status = -1 + self.state_updated = datetime.now() + self.state_interval = 0 + self.state = -1 self.auto_reconnect = AUTO_RECONNECT self.manufacturer = "Solarman" self.model = None @@ -84,14 +84,14 @@ async def load(self, name, mac, path, file): _LOGGER.debug(self.device_info) def available(self): - return self.status > -1 + return self.state > -1 async def async_connect(self, loud = True) -> None: if not self.reader_task: if loud: _LOGGER.info(f"Connecting to {self.address}:{self.port}") await self.connect() - elif not self.status > 0: + elif not self.state > 0: await self.reconnect() async def async_disconnect(self, loud = True) -> None: @@ -106,7 +106,7 @@ async def async_disconnect(self, loud = True) -> None: async def async_shutdown(self, loud = True) -> None: self._is_reading = 0 - self.status = -1 + self.state = -1 await self.async_disconnect(loud) async def async_read(self, params, code, start, end) -> None: @@ -128,8 +128,8 @@ def get_sensors(self): return params.get_sensors() return [] - def get_connection_status(self): - if self.status > 0: + def get_connection_state(self): + if self.state > 0: return "Connected" return "Disconnected" @@ -139,21 +139,21 @@ def get_result(self, middleware = None): result = middleware.get_result() if middleware else {} if len(result) > 0: - _LOGGER.debug(f"Returning new values to the Coordinator. [Previous State: {self.get_connection_status()} ({self.status})]") + _LOGGER.debug(f"Returning new values to the Coordinator. [Previous State: {self.get_connection_state()} ({self.state})]") now = datetime.now() - self.status_interval = now - self.status_updated - self.status_updated = now - self.status = 1 + self.state_interval = now - self.state_updated + self.state_updated = now + self.state = 1 return result async def async_get_failed(self, message = None): - _LOGGER.debug(f"Request failed. [Previous State: {self.get_connection_status()} ({self.status})]") - self.status = 0 if self.status == 1 else -1 + _LOGGER.debug(f"Request failed. [Previous State: {self.get_connection_state()} ({self.state})]") + self.state = 0 if self.state == 1 else -1 await self.async_disconnect() - if message and self.status == -1: + if message and self.state == -1: raise UpdateFailed(message) async def async_get(self, runtime = 0): @@ -201,7 +201,7 @@ async def async_get(self, runtime = 0): await self.async_get_failed(f"Querying {self.serial} at {self.address}:{self.port} failed.") except TimeoutError: - last_state = self.status + last_state = self.state await self.async_get_failed() if last_state < 1: raise diff --git a/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml b/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml index 1aea499..4508b62 100644 --- a/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml +++ b/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml @@ -1699,7 +1699,7 @@ parameters: uom: "" scale: 1 rule: 0 - options: ["charging", "standby", "discharging"] + options: ["charging", "idle", "discharging"] icon: "mdi:battery" # Battery - The current of battery 1 is S16bit (low 16 bits) diff --git a/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml b/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml index b9857fb..9ea754b 100644 --- a/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml +++ b/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml @@ -1707,7 +1707,7 @@ parameters: uom: "" scale: 1 rule: 0 - options: ["charging", "standby", "discharging"] + options: ["charging", "idle", "discharging"] icon: "mdi:battery" # Battery - The current of battery 1 is S16bit (low 16 bits) diff --git a/custom_components/solarman/sensor.py b/custom_components/solarman/sensor.py index d7baeb8..a83b6cf 100644 --- a/custom_components/solarman/sensor.py +++ b/custom_components/solarman/sensor.py @@ -83,8 +83,8 @@ def available(self) -> bool: return True def update(self): - self._attr_state = self.coordinator.inverter.get_connection_status() - self._attr_extra_state_attributes["updated"] = self.coordinator.inverter.status_updated.strftime("%m/%d/%Y, %H:%M:%S") + self._attr_state = self.coordinator.inverter.get_connection_state() + self._attr_extra_state_attributes["updated"] = self.coordinator.inverter.state_updated.strftime("%m/%d/%Y, %H:%M:%S") class SolarmanInterval(SolarmanDiagnosticEntity): def __init__(self, coordinator, sensor): @@ -96,7 +96,7 @@ def available(self) -> bool: return self._attr_state > 0 def update(self): - self._attr_state = self.coordinator.inverter.status_interval.total_seconds() + self._attr_state = self.coordinator.inverter.state_interval.total_seconds() class SolarmanSensor(SolarmanEntity): def __init__(self, coordinator, sensor, battery_nominal_voltage, battery_life_cycle_rating): @@ -165,7 +165,7 @@ def update(self): case "Battery State": battery_power = self.get_data("Battery Power", None) if battery_power: - self._attr_state = "discharging" if battery_power > 50 else "charging" if battery_power < -50 else "standby" + self._attr_state = "discharging" if battery_power > 50 else "charging" if battery_power < -50 else "idle" case "Today Battery Life Cycles": today_battery_charge = self.get_data("Today Battery Charge", None) if today_battery_charge == 0: