Skip to content

Commit

Permalink
fix: unit of measurement (#1)
Browse files Browse the repository at this point in the history
* fix: unit of mesurement

* Change to 'native_value' and 'native_unit_of_measurement'

* chore: version bump
  • Loading branch information
firstof9 authored Sep 3, 2021
1 parent ac9dd19 commit f0d9c93
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/openei/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"config_flow": true,
"codeowners": ["@firstof9"],
"requirements": ["python-openei==0.1.3"],
"version": "0.0.1"
"version": "0.0.2"
}
8 changes: 2 additions & 6 deletions custom_components/openei/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ def __init__(self, sensor_type, unique_id, coordinator) -> None:
self._name = sensor_type
self._unique_id = unique_id
self.coordinator = coordinator
self._attr_unit_of_measurement = SENSOR_TYPES[self._name][2]
self._attr_native_unit_of_measurement = f"{SENSOR_TYPES[self._name][2]}/kWh"
self._device_class = SENSOR_TYPES[self._name][3]
self._attr_native_value = self.coordinator.data.get(self._name)

@property
def unique_id(self) -> str:
Expand All @@ -42,11 +43,6 @@ def name(self):
"""Return the name of the sensor."""
return f"{SENSOR_TYPES[self._name][0]}"

@property
def state(self):
"""Return the state of the sensor."""
return self.coordinator.data.get(self._name)

@property
def icon(self) -> str:
"""Return the icon of the sensor."""
Expand Down

0 comments on commit f0d9c93

Please sign in to comment.