1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-19 03:32:20 +01:00

Add generate home assistant config command (#208)

* Add generate home assistant config command

* Lint

* Lint
This commit is contained in:
Otto Winter
2018-11-03 14:08:31 +01:00
committed by GitHub
parent 36da3b85d5
commit 27b86d89b0
80 changed files with 625 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import voluptuous as vol
from esphomeyaml import automation
from esphomeyaml.components import mqtt
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ICON, CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_ON_VALUE, \
CONF_TRIGGER_ID
@@ -58,3 +59,12 @@ def register_text_sensor(var, config):
BUILD_FLAGS = '-DUSE_TEXT_SENSOR'
def core_to_hass_config(data, config):
ret = mqtt.build_hass_config(data, 'sensor', config, include_state=True, include_command=False)
if ret is None:
return None
if CONF_ICON in config:
ret['icon'] = config[CONF_ICON]
return ret

View File

@@ -25,3 +25,7 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MQTT_SUBSCRIBE_TEXT_SENSOR'
def to_hass_config(data, config):
return text_sensor.core_to_hass_config(data, config)

View File

@@ -28,3 +28,7 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_TEMPLATE_TEXT_SENSOR'
def to_hass_config(data, config):
return text_sensor.core_to_hass_config(data, config)

View File

@@ -17,3 +17,7 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_VERSION_TEXT_SENSOR'
def to_hass_config(data, config):
return text_sensor.core_to_hass_config(data, config)