diff --git a/packages/modules/devices/shelly/shelly/bat.py b/packages/modules/devices/shelly/shelly/bat.py index c340d0a370..abbcb15ab3 100644 --- a/packages/modules/devices/shelly/shelly/bat.py +++ b/packages/modules/devices/shelly/shelly/bat.py @@ -71,9 +71,10 @@ def update(self) -> None: bat_state = BatState( power=power, imported=imported, - exported=exported, - currents=currents + exported=exported ) + if 'currents' in locals(): + bat_state.currents = currents self.store.set(bat_state) except KeyError: log.exception("unsupported shelly device.") diff --git a/packages/modules/devices/shelly/shelly/inverter.py b/packages/modules/devices/shelly/shelly/inverter.py index d59443652e..cc57a0959f 100644 --- a/packages/modules/devices/shelly/shelly/inverter.py +++ b/packages/modules/devices/shelly/shelly/inverter.py @@ -68,9 +68,10 @@ def update(self) -> None: _, exported = self.sim_counter.sim_count(power) inverter_state = InverterState( power=power, - exported=exported, - currents=currents + exported=exported ) + if 'currents' in locals(): + inverter_state.currents = currents self.store.set(inverter_state) except KeyError: log.exception("unsupported shelly device.")