|
57 | 57 | _ENDPOINT_OA_DOMAIN = "https://www.foxesscloud.com" |
58 | 58 | _ENDPOINT_OA_BATTERY_SETTINGS = "/op/v0/device/battery/soc/get?sn=" |
59 | 59 | _ENDPOINT_OA_REPORT = "/op/v0/device/report/query" |
60 | | -_ENDPOINT_OA_DEVICE_DETAIL = "/op/v0/device/detail?sn=" |
| 60 | +_ENDPOINT_OA_DEVICE_DETAIL = "/op/v0/device/detail" |
| 61 | +_ENDPOINT_OA_DEVICE_DETAIL_V1 = "/op/v1/device/detail" |
61 | 62 | _ENDPOINT_OA_DEVICE_VARIABLES = "/op/v0/device/real/query" |
62 | 63 | _ENDPOINT_OA_DEVICE_VARIABLES_V1 = "/op/v1/device/real/query" |
63 | 64 | _ENDPOINT_OA_DAILY_GENERATION = "/op/v0/device/generation?sn=" |
@@ -136,21 +137,24 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= |
136 | 137 | _LOGGER.debug("Device ID: %s", deviceID) |
137 | 138 | _LOGGER.debug("FoxESS Scan Interval: %s minutes", SCAN_MINUTES) |
138 | 139 | _LOGGER.debug("Cross Time Zone: %s", xtzone) |
| 140 | + _LOGGER.debug("Restrict Variables: %s", RestrictGetVar) |
139 | 141 | _LOGGER.debug("Extended PV: %s", ExtPV) |
140 | | - _LOGGER.debug("V1 Api Calls: %s", V1_Api) |
| 142 | + _LOGGER.debug("v1 Api Calls: %s", V1_Api) |
141 | 143 | _LOGGER.debug("EVO: %s", Evo) |
142 | | - if V1_Api is not True: |
143 | | - V1_Api = False |
| 144 | + if V1_Api is not False: |
| 145 | + V1_Api = True |
| 146 | + _LOGGER.debug("v1 Api Calls Enabled") |
| 147 | + else: |
| 148 | + _LOGGER.warning("v1 Api Calls Disabled, using v0") |
144 | 149 | if ExtPV is not True: |
145 | 150 | ExtPV = False |
| 151 | + _LOGGER.debug("Extended PV Disabled") |
146 | 152 | else: |
147 | | - ExtPV = True |
148 | 153 | _LOGGER.warning("Extended PV 1-18 strings enabled") |
149 | | - _LOGGER.debug("Restrict Variables: %s", RestrictGetVar) |
150 | 154 | if RestrictGetVar is not True: |
151 | 155 | RestrictGetVar = False |
| 156 | + _LOGGER.debug("Get Variables is full variable mode") |
152 | 157 | else: |
153 | | - RestrictGetVar = True |
154 | 158 | _LOGGER.warning("Get Variables is in restricted mode") |
155 | 159 | timeslice = {} |
156 | 160 | timeslice[devicesn] = RETRY_NEXT_SLOT |
@@ -513,6 +517,8 @@ async def async_update_data(): |
513 | 517 | FoxESSPVEnergyTotal(coordinator, name, deviceID), |
514 | 518 | FoxESSResidualEnergy(coordinator, name, deviceID), |
515 | 519 | FoxESSResponseTime(coordinator, name, deviceID), |
| 520 | + FoxESSMaxBatChargeCurrent(coordinator, name, deviceID), |
| 521 | + FoxESSMaxBatDischargeCurrent(coordinator, name, deviceID), |
516 | 522 | FoxESSRunningState( |
517 | 523 | coordinator, |
518 | 524 | name, |
@@ -752,10 +758,15 @@ async def waitforAPI(): |
752 | 758 | async def getOADeviceDetail(hass, allData, devicesn, apiKey): |
753 | 759 | await waitforAPI() |
754 | 760 |
|
755 | | - path = "/op/v0/device/detail" |
| 761 | + if V1_Api: |
| 762 | + path = _ENDPOINT_OA_DEVICE_DETAIL_V1 |
| 763 | + _LOGGER.debug("Device Detail using V1 API") |
| 764 | + else: |
| 765 | + path = _ENDPOINT_OA_DEVICE_DETAIL |
| 766 | + |
756 | 767 | headerData = GetAuth().get_signature(token=apiKey, path=path) |
757 | 768 |
|
758 | | - path = _ENDPOINT_OA_DOMAIN + _ENDPOINT_OA_DEVICE_DETAIL |
| 769 | + path = _ENDPOINT_OA_DOMAIN + path + "?sn=" |
759 | 770 | _LOGGER.debug("OADevice Detail fetch %s%s", path, devicesn) |
760 | 771 | timestamp = round(time.time() * 1000) |
761 | 772 |
|
@@ -1697,6 +1708,66 @@ def native_value(self) -> str | None: |
1697 | 1708 | return energycharge |
1698 | 1709 | return None |
1699 | 1710 |
|
| 1711 | +class FoxESSMaxBatChargeCurrent(CoordinatorEntity, SensorEntity): |
| 1712 | + _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT |
| 1713 | + _attr_device_class = SensorDeviceClass.CURRENT |
| 1714 | + _attr_native_unit_of_measurement = UnitOfElectricCurrent.AMPERE |
| 1715 | + |
| 1716 | + def __init__(self, coordinator, name, deviceID): |
| 1717 | + super().__init__(coordinator=coordinator) |
| 1718 | + _LOGGER.debug("Initiating Entity - Max Bat Charge Current") |
| 1719 | + self._attr_name = name + " - Max Bat Charge Current" |
| 1720 | + self._attr_unique_id = deviceID + "max-bat-charge-charge" |
| 1721 | + self.status = namedtuple( |
| 1722 | + "status", |
| 1723 | + [ |
| 1724 | + ATTR_DATE, |
| 1725 | + ATTR_TIME, |
| 1726 | + ], |
| 1727 | + ) |
| 1728 | + |
| 1729 | + @property |
| 1730 | + def native_value(self) -> str | None: |
| 1731 | + if "maxChargeCurrent" not in self.coordinator.data["raw"]: |
| 1732 | + _LOGGER.debug("report maxChargeCurrent None") |
| 1733 | + else: |
| 1734 | + if self.coordinator.data["raw"]["maxChargeCurrent"] == 0: |
| 1735 | + charge = 0 |
| 1736 | + else: |
| 1737 | + charge = self.coordinator.data["raw"]["maxChargeCurrent"] |
| 1738 | + return charge |
| 1739 | + return None |
| 1740 | + |
| 1741 | +class FoxESSMaxBatDischargeCurrent(CoordinatorEntity, SensorEntity): |
| 1742 | + _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT |
| 1743 | + _attr_device_class = SensorDeviceClass.CURRENT |
| 1744 | + _attr_native_unit_of_measurement = UnitOfElectricCurrent.AMPERE |
| 1745 | + |
| 1746 | + def __init__(self, coordinator, name, deviceID): |
| 1747 | + super().__init__(coordinator=coordinator) |
| 1748 | + _LOGGER.debug("Initiating Entity - Max Bat Discharge Current") |
| 1749 | + self._attr_name = name + " - Max Bat Discharge Current" |
| 1750 | + self._attr_unique_id = deviceID + "max-bat-discharge-charge" |
| 1751 | + self.status = namedtuple( |
| 1752 | + "status", |
| 1753 | + [ |
| 1754 | + ATTR_DATE, |
| 1755 | + ATTR_TIME, |
| 1756 | + ], |
| 1757 | + ) |
| 1758 | + |
| 1759 | + @property |
| 1760 | + def native_value(self) -> str | None: |
| 1761 | + if "maxDischargeCurrent" not in self.coordinator.data["raw"]: |
| 1762 | + _LOGGER.debug("report maxDischargeCurrent None") |
| 1763 | + else: |
| 1764 | + if self.coordinator.data["raw"]["maxDischargeCurrent"] == 0: |
| 1765 | + charge = 0 |
| 1766 | + else: |
| 1767 | + charge = self.coordinator.data["raw"]["maxDischargeCurrent"] |
| 1768 | + return charge |
| 1769 | + return None |
| 1770 | + |
1700 | 1771 |
|
1701 | 1772 | class FoxESSEnergyBatDischarge(CoordinatorEntity, SensorEntity): |
1702 | 1773 | _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING |
|
0 commit comments