Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sensors to work with Energy Dashboard #41

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions custom_components/greenely/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, name, api, date_format, time_format):
self._icon = "mdi:account-cash"
self._state = 0
self._state_attributes = {}
self._unit_of_measurement = 'kr'
self._unit_of_measurement = 'SEK/kWh'
self._date_format = date_format
self._time_format = time_format
self._api = api
Expand Down Expand Up @@ -228,12 +228,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 @@ -260,6 +261,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 @@ -303,12 +309,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 @@ -335,6 +342,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