Skip to content

Commit

Permalink
用内部变量形式作判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Hu committed Aug 26, 2024
1 parent 7836383 commit 3078956
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/airtub_udp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def state(self, value):
self._state = value

# 仅在 device_class 为 gas 并且值为 0 时触发 last_reset
if self.device_class == SensorDeviceClass.GAS and self._state == 0:
if self._attr_device_class == SensorDeviceClass.GAS and self._state == 0:
self._attr_last_reset = datetime.now()

@property
def last_reset(self):
if self.device_class == SensorDeviceClass.GAS:
if self._attr_device_class == SensorDeviceClass.GAS:
return self._attr_last_reset
return None

Expand Down

0 comments on commit 3078956

Please sign in to comment.