diff --git a/custom_components/zcsazzurro/manifest.json b/custom_components/zcsazzurro/manifest.json index e74dc29..54cec4c 100644 --- a/custom_components/zcsazzurro/manifest.json +++ b/custom_components/zcsazzurro/manifest.json @@ -6,5 +6,5 @@ "after_dependencies": ["rest"], "codeowners": ["@sdesalve"], "iot_class": "cloud_polling", - "version": "0.0.2" + "version": "0.0.4" } diff --git a/custom_components/zcsazzurro/sensor.py b/custom_components/zcsazzurro/sensor.py index 45ec8c1..e6eb585 100644 --- a/custom_components/zcsazzurro/sensor.py +++ b/custom_components/zcsazzurro/sensor.py @@ -315,6 +315,69 @@ def extra_state_attributes(self): } except TypeError: _LOGGER.error("Error cannot find all required keys: %s", self.dssoutput) + return { + "lastUpdated": False, + "thing.find": False, + "total": { + "energyGenerating": 0, + "energyCharging": 0, + "energyDischarging": 0, + "energyExporting": 0, + "energyImporting": 0, + "energyConsuming": 0, + "energyAutoconsuming": 0 + }, + "current": { + "energyGenerating": 0, + "powerGenerating": 0, + "batteryCycletime": 0, + "batterySoC": 0, + "powerCharging": 0, + "powerDischarging": 0, + "powerExporting": 0, + "powerImporting": 0, + "powerConsuming": 0, + "powerAutoconsuming": 0, + "energyCharging": 0, + "energyDischarging": 0, + "energyExporting": 0, + "energyImporting": 0, + "energyConsuming": 0, + "energyAutoconsuming": 0, + }, + } + else: + return { + "lastUpdated": False, + "thing.find": False, + "total": { + "energyGenerating": 0, + "energyCharging": 0, + "energyDischarging": 0, + "energyExporting": 0, + "energyImporting": 0, + "energyConsuming": 0, + "energyAutoconsuming": 0 + }, + "current": { + "energyGenerating": 0, + "powerGenerating": 0, + "batteryCycletime": 0, + "batterySoC": 0, + "powerCharging": 0, + "powerDischarging": 0, + "powerExporting": 0, + "powerImporting": 0, + "powerConsuming": 0, + "powerAutoconsuming": 0, + "energyCharging": 0, + "energyDischarging": 0, + "energyExporting": 0, + "energyImporting": 0, + "energyConsuming": 0, + "energyAutoconsuming": 0, + }, + } async def async_update(self): """Get the latest data from the ZCSAzzurro API and updates the state.""" @@ -341,7 +404,8 @@ def _async_update_from_rest_data(self): _LOGGER.debug("Erroneous JSON: %s", json_dict) else: _LOGGER.warning("Empty reply found when expecting JSON data") - + self.dssoutput = None + self._state = False except TypeError: self.dssoutput = None self._state = False