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 version #247

Merged
merged 3 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion custom_components/nordpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


NAME = DOMAIN
VERSION = "0.0.10b"
VERSION = "0.0.10b0"
ISSUEURL = "https://github.com/custom-components/nordpool/issues"

STARTUP = f"""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nordpool/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"requirements": [
"nordpool>=0.2"
],
"version": "0.0.10b"
"version": "0.0.10b0"
}
19 changes: 14 additions & 5 deletions custom_components/nordpool/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_REGION
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.template import Template, attach
from homeassistant.util import dt as dt_utils

# Import sensor entity and classes.
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from jinja2 import pass_context

from . import DOMAIN, EVENT_NEW_DATA
from .misc import extract_attrs, has_junk, is_new, start_of


_LOGGER = logging.getLogger(__name__)

_CENT_MULTIPLIER = 100
Expand Down Expand Up @@ -122,8 +129,10 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
return True


class NordpoolSensor(Entity):
"""Sensor"""
class NordpoolSensor(SensorEntity):
"Sensors data"
_attr_device_class = SensorDeviceClass.MONETARY
_attr_state_class = SensorStateClass.MEASUREMENT

def __init__(
self,
Expand Down Expand Up @@ -333,8 +342,8 @@ def _update(self):
self._min = min(td)
self._max = max(td)
self._off_peak_1 = mean(td[0:8])
self._peak = mean(td[20:])
self._off_peak_2 = mean(td[8:20])
self._off_peak_2 = mean(td[20:])
self._peak = mean(td[8:20])
self._mean = median(td)

@property
Expand Down