Example Sensor Platform
This is a minimum implementation of a platform for the sensor component.
Installation
Copy the code below and create it as a file in <config_dir>/custom_components/sensor/example.py
.
Add the following to your configuration.yaml:
# Example configuration.yaml entry sensor: platform: example
Code
from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.entity import Entity def setup_platform(hass, config, add_devices, discovery_info=None): add_devices([ExampleSensor()]) class ExampleSensor(Entity): @property def name(self): return 'Temperature' @property def state(self): return 23 @property def unit_of_measurement(self): return TEMP_CELSIUS