sensor fix, readme configuration examples
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor
|
||||
name: Empty sensor
|
||||
```
|
||||
@@ -1,17 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
|
||||
empty_sensor_ns = cg.esphome_ns.namespace('empty_sensor')
|
||||
|
||||
EmptySensor = empty_sensor_ns.class_('EmptySensor', cg.PollingComponent)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptySensor)
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
Reference in New Issue
Block a user