lint ok
This commit is contained in:
parent
dade33187f
commit
a764817ee9
1 changed files with 11 additions and 10 deletions
|
@ -29,17 +29,21 @@ REQUIREMENTS = ['eliqonline==1.0.11']
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
""" Set up the sensors """
|
||||||
|
|
||||||
import eliqonline
|
import eliqonline
|
||||||
|
|
||||||
access_token = config.get(CONF_ACCESS_TOKEN)
|
access_token = config.get(CONF_ACCESS_TOKEN)
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
channel_id = config.get("channel_id")
|
channel_id = config.get("channel_id")
|
||||||
|
|
||||||
if not access_token:
|
if not access_token:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Configuration Error"
|
"Configuration Error"
|
||||||
"Please make sure you have configured your access token which can be aquired from https://my.eliq.se/user/settings/api")
|
"Please make sure you have configured your access token " +
|
||||||
|
"that can be aquired from https://my.eliq.se/user/settings/api")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
api = eliqonline.API(access_token)
|
api = eliqonline.API(access_token)
|
||||||
|
@ -60,26 +64,23 @@ class EliqSensor(Entity):
|
||||||
self.channel_id = channel_id
|
self.channel_id = channel_id
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name. """
|
""" Returns the name. """
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
""" Unit of measurement of this entity, if any. """
|
""" Unit of measurement of this entity, if any. """
|
||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data """
|
""" Gets the latest data """
|
||||||
self._state = int(self.api.get_data_now(channelid=self.channel_id).power)
|
response = self.api.get_data_now(channelid=self.channel_id)
|
||||||
|
self._state = int(response.power)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue