Update file header (#21023)
* Update file header * Update file header * Update file header * Update file header * Update file header * Fix lint issues
This commit is contained in:
1 parent
22af9707ad
commit
127c55e0c1
492 files changed
+1015
-3497
No files matched your search
@@ -1,9 +1,4 @@
|
||||
"""
|
||||
Utility meter from sensors providing raw data.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.utility_meter/
|
||||
"""
|
||||
"""Utility meter from sensors providing raw data."""
|
||||
import logging
|
||||
|
||||
from decimal import Decimal, DecimalException
|
||||
@@ -40,8 +35,8 @@ PAUSED = 'paused'
|
||||
COLLECTING = 'collecting'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the utility meter sensor."""
|
||||
if discovery_info is None:
|
||||
_LOGGER.error("This platform is only available through discovery")
|
||||
@@ -56,12 +51,10 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||
conf_meter_tariff_entity = hass.data[DATA_UTILITY][meter].get(
|
||||
CONF_TARIFF_ENTITY)
|
||||
|
||||
meters.append(UtilityMeterSensor(conf_meter_source,
|
||||
conf.get(CONF_NAME),
|
||||
conf_meter_type,
|
||||
conf_meter_offset,
|
||||
conf.get(CONF_TARIFF),
|
||||
conf_meter_tariff_entity))
|
||||
meters.append(UtilityMeterSensor(
|
||||
conf_meter_source, conf.get(CONF_NAME), conf_meter_type,
|
||||
conf_meter_offset, conf.get(CONF_TARIFF),
|
||||
conf_meter_tariff_entity))
|
||||
|
||||
async_add_entities(meters)
|
||||
|
||||
@@ -181,16 +174,16 @@ class UtilityMeterSensor(RestoreEntity):
|
||||
self._last_reset = state.attributes.get(ATTR_LAST_RESET)
|
||||
await self.async_update_ha_state()
|
||||
if state.attributes.get(ATTR_STATUS) == PAUSED:
|
||||
# Fake cancelation function to init the meter paused
|
||||
# Fake cancellation function to init the meter paused
|
||||
self._collecting = lambda: None
|
||||
|
||||
@callback
|
||||
def async_source_tracking(event):
|
||||
"""Wait for source to be ready, then start meter."""
|
||||
if self._tariff_entity is not None:
|
||||
_LOGGER.debug("track %s", self._tariff_entity)
|
||||
async_track_state_change(self.hass, self._tariff_entity,
|
||||
self.async_tariff_change)
|
||||
_LOGGER.debug("Track %s", self._tariff_entity)
|
||||
async_track_state_change(
|
||||
self.hass, self._tariff_entity, self.async_tariff_change)
|
||||
|
||||
tariff_entity_state = self.hass.states.get(self._tariff_entity)
|
||||
if self._tariff != tariff_entity_state.state:
|
||||
|
||||
Reference in new issue
Block a user