Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MapoDan authored Jun 9, 2019
1 parent f79a4ae commit edefcbe
Showing 1 changed file with 5 additions and 53 deletions.
58 changes: 5 additions & 53 deletions custom_components/file_restore/__init__.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit edefcbe

Please sign in to comment.