Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
linsvensson committed Dec 19, 2022
2 parents 2ec4079 + 6718a6e commit fe81b8f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions custom_components/greenely/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, name, api, date_format, time_format, homekit_compatible):
self._icon = "mdi:account-cash"
self._state = 0
self._state_attributes = {}
self._unit_of_measurement = 'kr' if homekit_compatible != True else '°C'
self._unit_of_measurement = 'SEK/kWh' if homekit_compatible != True else '°C'
self._date_format = date_format
self._time_format = time_format
self._homekit_compatible = homekit_compatible
Expand Down Expand Up @@ -238,12 +238,13 @@ def __init__(self, name, api, usage_days, date_format, time_format):
self._name = name
self._icon = "mdi:power-socket-eu"
self._state = 0
self._state_attributes = {}
self._state_attributes = {'state_class':'measurement','last_reset':'1970-01-01T00:00:00+00:00'}
self._unit_of_measurement = 'kWh'
self._usage_days = usage_days
self._date_format = date_format
self._time_format = time_format
self._api = api
self._device_class = 'energy'

@property
def name(self):
Expand All @@ -270,6 +271,11 @@ def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit_of_measurement

@property
def device_class(self):
"""Return the class of the sensor."""
return self._device_class

def update(self):
_LOGGER.debug('Checking jwt validity...')
if self._api.check_auth():
Expand Down Expand Up @@ -313,12 +319,13 @@ def __init__(self, name, api, hourly_offset_days, date_format,
self._name = name
self._icon = "mdi:power-socket-eu"
self._state = 0
self._state_attributes = {}
self._state_attributes = {'state_class':'measurement','last_reset':'1970-01-01T00:00:00+00:00'}
self._unit_of_measurement = 'kWh'
self._date_format = date_format
self._time_format = time_format
self._hourly_offset_days = hourly_offset_days
self._api = api
self._device_class = 'energy'

@property
def name(self):
Expand All @@ -345,6 +352,11 @@ def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit_of_measurement

@property
def device_class(self):
"""Return the class of the sensor."""
return self._device_class

def update(self):
_LOGGER.debug('Checking jwt validity...')
if self._api.check_auth():
Expand Down

0 comments on commit fe81b8f

Please sign in to comment.