mirror of
https://github.com/esphome/esphome.git
synced 2024-12-20 16:18:49 +01:00
176c712eeb
* Disable MQTT if not used * Lint
31 lines
1008 B
Python
31 lines
1008 B
Python
import voluptuous as vol
|
|
|
|
from esphomeyaml.components import sensor
|
|
import esphomeyaml.config_validation as cv
|
|
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
|
from esphomeyaml.cpp_generator import Pvariable
|
|
from esphomeyaml.cpp_helpers import setup_component
|
|
from esphomeyaml.cpp_types import App
|
|
|
|
WiFiSignalSensor = sensor.sensor_ns.class_('WiFiSignalSensor', sensor.PollingSensorComponent)
|
|
|
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_variable_id(WiFiSignalSensor),
|
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
|
}).extend(cv.COMPONENT_SCHEMA.schema))
|
|
|
|
|
|
def to_code(config):
|
|
rhs = App.make_wifi_signal_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
|
|
wifi = Pvariable(config[CONF_ID], rhs)
|
|
|
|
sensor.setup_sensor(wifi, config)
|
|
setup_component(wifi, config)
|
|
|
|
|
|
BUILD_FLAGS = '-DUSE_WIFI_SIGNAL_SENSOR'
|
|
|
|
|
|
def to_hass_config(data, config):
|
|
return sensor.core_to_hass_config(data, config)
|