esphome/esphomeyaml/components/sensor/wifi_signal.py
Otto Winter 176c712eeb
Disable MQTT if not used (#373)
* Disable MQTT if not used

* Lint
2019-01-29 17:29:21 +01:00

30 lines
1,008 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)