From edefcbeedc5a83b98e6520322ab77d4471636800 Mon Sep 17 00:00:00 2001 From: MapoDan <42698485+MapoDan@users.noreply.github.com> Date: Sun, 9 Jun 2019 16:46:06 +0200 Subject: [PATCH] Update __init__.py --- custom_components/file_restore/__init__.py | 58 ++-------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/custom_components/file_restore/__init__.py b/custom_components/file_restore/__init__.py index 50549f2..be4ec60 100644 --- a/custom_components/file_restore/__init__.py +++ b/custom_components/file_restore/__init__.py @@ -1,55 +1,7 @@ """ -Component to interface with various sensors that can be monitored. - -For more details about this component, please refer to the documentation at -https://home-assistant.io/components/sensor/ +This component is an upgraded version of file sensor. +It has the same characteristics but it: + - expect a vecotr of data read from file in order to be able to interpret it. + - vector is 24x7 elements long in order to cover all hours in a week starting from 00:00 of Monday to 23:00 of Sunday. + - It has an additional property that return the whole vector read. """ - -from datetime import timedelta -import logging - -import voluptuous as vol - -from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.config_validation import ( # noqa - PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE) -from homeassistant.const import ( - DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_PRESSURE) - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = 'sensor' - -ENTITY_ID_FORMAT = DOMAIN + '.{}' - -SCAN_INTERVAL = timedelta(seconds=30) -DEVICE_CLASSES = [ - DEVICE_CLASS_BATTERY, # % of battery that is left - DEVICE_CLASS_HUMIDITY, # % of humidity in the air - DEVICE_CLASS_ILLUMINANCE, # current light level (lx/lm) - DEVICE_CLASS_TEMPERATURE, # temperature (C/F) - DEVICE_CLASS_TIMESTAMP, # timestamp (ISO8601) - DEVICE_CLASS_PRESSURE, # pressure (hPa/mbar) -] - -DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(DEVICE_CLASSES)) - - -async def async_setup(hass, config): - """Track states and offer events for sensors.""" - component = hass.data[DOMAIN] = EntityComponent( - _LOGGER, DOMAIN, hass, SCAN_INTERVAL) - - await component.async_setup(config) - return True - - -async def async_setup_entry(hass, entry): - """Set up a config entry.""" - return await hass.data[DOMAIN].async_setup_entry(entry) - - -async def async_unload_entry(hass, entry): - """Unload a config entry.""" - return await hass.data[DOMAIN].async_unload_entry(entry)