|
3 | 3 | from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
4 | 4 | from homeassistant.config_entries import ConfigEntry
|
5 | 5 | from homeassistant.core import HomeAssistant
|
| 6 | +from homeassistant.helpers.typing import StateType |
6 | 7 | from homeassistant.util import slugify
|
7 |
| - |
8 | 8 | from . import TibberLocalDataUpdateCoordinator, TibberLocalEntity
|
9 | 9 | from .const import (
|
10 | 10 | DOMAIN,
|
@@ -77,14 +77,18 @@ def __init__(
|
77 | 77 | self._attr_suggested_display_precision = 2
|
78 | 78 |
|
79 | 79 | @property
|
80 |
| - def state(self): |
81 |
| - """Return the current state.""" |
82 |
| - value = getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) |
83 |
| - if type(value) != type(False): |
84 |
| - try: |
85 |
| - rounded_value = round(float(value), self._attr_suggested_display_precision) |
86 |
| - return rounded_value |
87 |
| - except (ValueError, TypeError): |
88 |
| - return value |
89 |
| - else: |
90 |
| - return value |
| 80 | + def native_value(self) -> StateType: |
| 81 | + return getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) |
| 82 | + |
| 83 | + # @property |
| 84 | + # def state(self): |
| 85 | + # """Return the current state.""" |
| 86 | + # value = getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) |
| 87 | + # if type(value) != type(False): |
| 88 | + # try: |
| 89 | + # rounded_value = round(float(value), self._attr_suggested_display_precision) |
| 90 | + # return rounded_value |
| 91 | + # except (ValueError, TypeError): |
| 92 | + # return value |
| 93 | + # else: |
| 94 | + # return value |
0 commit comments