Skip to content

Commit

Permalink
fix: use currency from HA config
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 committed Sep 3, 2021
1 parent f0d9c93 commit ac27586
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/openei/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ async def async_setup_entry(hass, entry, async_add_devices):

sensors = []
for sensor in SENSOR_TYPES:
sensors.append(OpenEISensor(sensor, unique_id, coordinator))
sensors.append(OpenEISensor(hass, sensor, unique_id, coordinator))

async_add_devices(sensors, False)


class OpenEISensor(CoordinatorEntity, SensorEntity):
"""OpenEI Sensor class."""

def __init__(self, sensor_type, unique_id, coordinator) -> None:
def __init__(self, hass, sensor_type, unique_id, coordinator) -> None:
"""Initialize the sensor."""
super().__init__(coordinator)
self.hass = hass
self._name = sensor_type
self._unique_id = unique_id
self.coordinator = coordinator
self._attr_native_unit_of_measurement = f"{SENSOR_TYPES[self._name][2]}/kWh"
self._attr_native_unit_of_measurement = f"{self.hass.config.currency}/kWh"
self._device_class = SENSOR_TYPES[self._name][3]
self._attr_native_value = self.coordinator.data.get(self._name)

Expand Down

0 comments on commit ac27586

Please sign in to comment.