1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-04 09:01:49 +00:00

Compare commits

...

10 Commits

Author SHA1 Message Date
Otto Winter
6ccab2bef9 Bump version to v1.12.1 2019-03-20 13:11:55 +01:00
Otto Winter
475aa4879c Fix IPAddress in validate (#488)
Fixes https://github.com/esphome/issues/issues/141
2019-03-20 13:11:48 +01:00
Otto Winter
4452473735 Fix filter_out: nan filer (#486)
* Fix filter_out nan filter

Fixes https://github.com/esphome/issues/issues/138

* Add test
2019-03-20 13:11:48 +01:00
Otto Winter
948adfd28c Bump version to v1.12.0 2019-03-17 21:12:17 +01:00
Otto Winter
aebbd7673b Bump version to v1.12.0b4 2019-03-17 20:46:35 +01:00
Otto Winter
3baaf6b7c4 Update Hassio base image to 1.4.1 (#484)
* Update Hassio base image to 1.4.1

* Fix rotary encoder typo

Fixes https://github.com/esphome/issues/issues/136
2019-03-17 20:46:32 +01:00
Otto Winter
4a14221e2b Bump version to v1.12.0b3 2019-03-17 16:06:00 +01:00
Otto Winter
114ebf9fe1 More changes for 1.12 (#483)
* Print error when ESP32 BLE tracker used together with beacon

* Update

* Enable PSRAM

* Fix test
2019-03-17 16:05:55 +01:00
Otto Winter
92a4ee5652 Bump version to v1.12.0b2 2019-03-16 22:27:51 +01:00
Otto Winter
9fea094b4e Changes for 1.12 (#482)
* Update setup scripts

* Add delete action, remove Hass config command

* Update esphome.js

* Lint
2019-03-16 22:27:45 +01:00
124 changed files with 228 additions and 901 deletions

View File

@@ -41,11 +41,11 @@ stages:
- |
if [[ "${IS_HASSIO}" == "YES" ]]; then
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.3.0
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.1
BUILD_TO=esphome/esphome-hassio-${BUILD_ARCH}
DOCKERFILE=docker/Dockerfile.hassio
else
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.3.0
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.1
if [[ "${BUILD_ARCH}" == "amd64" ]]; then
BUILD_TO=esphome/esphome
else
@@ -126,7 +126,7 @@ test3:
- pip install -e .
- pip install twine
script:
- python setup.py sdist
- python setup.py sdist bdist_wheel
- twine upload dist/*
tags:
- docker

View File

@@ -1,17 +1,6 @@
include LICENSE
include README.md
include esphome/dashboard/templates/index.html
include esphome/dashboard/templates/login.html
include esphome/dashboard/static/ace.js
include esphome/dashboard/static/esphome.css
include esphome/dashboard/static/esphome.js
include esphome/dashboard/static/favicon.ico
include esphome/dashboard/static/jquery.min.js
include esphome/dashboard/static/jquery.validate.min.js
include esphome/dashboard/static/jquery-ui.min.js
include esphome/dashboard/static/materialize.min.css
include esphome/dashboard/static/materialize.min.js
include esphome/dashboard/static/materialize-stepper.min.css
include esphome/dashboard/static/materialize-stepper.min.js
include esphome/dashboard/static/mode-yaml.js
include esphome/dashboard/static/theme-dreamweaver.js
include esphome/dashboard/static/ext-searchbox.js
include esphome/dashboard/templates/*.html
include esphome/dashboard/static/*.js
include esphome/dashboard/static/*.css
include esphome/dashboard/static/*.ico

View File

@@ -1,4 +1,4 @@
ARG BUILD_FROM=esphome/esphome-base-amd64:1.3.0
ARG BUILD_FROM=esphome/esphome-base-amd64:1.4.1
FROM ${BUILD_FROM}
COPY . .

View File

@@ -1,4 +1,4 @@
ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.3.0
ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.4.1
FROM ${BUILD_FROM}
# Copy root filesystem

View File

@@ -16,11 +16,11 @@ echo "PWD: $PWD"
if [[ ${IS_HASSIO} = "YES" ]]; then
docker build \
--build-arg "BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.3.0" \
--build-arg "BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.4.1" \
--build-arg "BUILD_VERSION=${CACHE_TAG}" \
-t "${IMAGE_NAME}" -f ../docker/Dockerfile.hassio ..
else
docker build \
--build-arg "BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.3.0" \
--build-arg "BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.4.1" \
-t "${IMAGE_NAME}" -f ../docker/Dockerfile ..
fi

View File

@@ -1,35 +1,41 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# This files check if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL requirements, if enabled
if hass.config.true 'ssl'; then
if ! hass.config.has_value 'certfile'; then
hass.die 'SSL is enabled, but no certfile was specified.'
if bashio::config.true 'ssl'; then
if ! bashio::config.has_value 'certfile'; then
bashio::fatal 'SSL is enabled, but no certfile was specified.'
bashio::exit.nok
fi
if ! hass.config.has_value 'keyfile'; then
hass.die 'SSL is enabled, but no keyfile was specified'
if ! bashio::config.has_value 'keyfile'; then
bashio::fatal 'SSL is enabled, but no keyfile was specified'
bashio::exit.nok
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
certfile="/ssl/$(bashio::config 'certfile')"
keyfile="/ssl/$(bashio::config 'keyfile')"
if ! bashio::fs.file_exists "${certfile}"; then
if ! bashio::fs.file_exists "${keyfile}"; then
# Both files are missing, let's print a friendlier error message
text="You enabled encrypted connections using the \"ssl\": true option.
However, the SSL files \"$(hass.config.get 'certfile')\" and \"$(hass.config.get 'keyfile')\"
were not found. If you're using Hass.io on your local network and don't want
to encrypt connections to the ESPHome dashboard, you can manually disable
SSL by setting \"ssl\" to false."
hass.die "${text}"
bashio::log.fatal 'You enabled encrypted connections using the "ssl": true option.'
bashio::log.fatal "However, the SSL files '${certfile}' and '${keyfile}'"
bashio::log.fatal "were not found. If you're using Hass.io on your local network and don't want"
bashio::log.fatal 'to encrypt connections to the ESPHome dashboard, you can manually disable'
bashio::log.fatal 'SSL by setting "ssl" to false."'
bashio::exit.nok
fi
hass.die 'The configured certfile is not found'
bashio::log.fatal "The configured certfile '${certfile}' was not found."
bashio::exit.nok
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
hass.die 'The configured keyfile is not found'
if ! bashio::fs.file_exists "/ssl/$(bashio::config 'keyfile')"; then
bashio::log.fatal "The configured keyfile '${keyfile}' was not found."
bashio::exit.nok
fi
fi

View File

@@ -1,10 +1,8 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# Configures NGINX for use with ESPHome
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare certfile
declare keyfile
@@ -13,16 +11,16 @@ declare port
mkdir -p /var/log/nginx
# Enable SSL
if hass.config.true 'ssl'; then
if bashio::config.true 'ssl'; then
rm /etc/nginx/nginx.conf
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
certfile=$(hass.config.get 'certfile')
keyfile=$(hass.config.get 'keyfile')
certfile=$(bashio::config 'certfile')
keyfile=$(bashio::config 'keyfile')
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
fi
port=$(hass.config.get 'port')
port=$(bashio::config 'port')
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf

View File

@@ -1,14 +1,15 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# This files installs the user ESPHome version if specified
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare esphome_version
if hass.config.has_value 'esphome_version'; then
esphome_version=$(hass.config.get 'esphome_version')
pip2 install --no-cache-dir --no-binary :all: "https://github.com/esphome/esphome/archive/${esphome_version}.zip"
if bashio::config.has_value 'esphome_version'; then
esphome_version=$(bashio::config 'esphome_version')
full_url="https://github.com/esphome/esphome/archive/${esphome_version}.zip"
bashio::log.info "Installing esphome version '${esphome_version}' (${full_url})..."
pip2 install --no-cache-dir --no-binary :all: "${full_url}" \
|| bashio::exit.nok "Failed installing esphome pinned version."
fi

View File

@@ -1,10 +1,8 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# This files migrates the esphome config directory from the old path
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if [[ ! -d /config/esphome && -d /config/esphomeyaml ]]; then
echo "Moving config directory from /config/esphomeyaml to /config/esphome"

View File

@@ -1,28 +1,26 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# Runs the ESPHome dashboard
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
export ESPHOME_IS_HASSIO=true
if hass.config.true 'leave_front_door_open'; then
if bashio::config.true 'leave_front_door_open'; then
export DISABLE_HA_AUTHENTICATION=true
fi
if hass.config.true 'streamer_mode'; then
if bashio::config.true 'streamer_mode'; then
export ESPHOME_STREAMER_MODE=true
fi
if hass.config.true 'status_use_ping'; then
if bashio::config.true 'status_use_ping'; then
export ESPHOME_DASHBOARD_USE_PING=true
fi
if hass.config.has_value 'relative_url'; then
export ESPHOME_DASHBOARD_RELATIVE_URL=$(hass.config.get 'relative_url')
if bashio::config.has_value 'relative_url'; then
export ESPHOME_DASHBOARD_RELATIVE_URL=$(bashio::config 'relative_url')
fi
hass.log.info "Starting ESPHome dashboard..."
bashio::log.info "Starting ESPHome dashboard..."
exec esphome /config/esphome dashboard --socket /var/run/esphome.sock --hassio

View File

@@ -1,10 +1,8 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# Runs the NGINX proxy
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
hass.log.info "Starting NGINX..."
bashio::log.info "Starting NGINX..."
exec nginx -g "daemon off;"

View File

@@ -1,7 +1,6 @@
from __future__ import print_function
import argparse
from collections import OrderedDict
from datetime import datetime
import logging
import os
@@ -348,28 +347,6 @@ def command_clean(args, config):
return 0
def command_hass_config(args, config):
from esphome.components import mqtt as mqtt_component
_LOGGER.info("This is what you should put in your Home Assistant YAML configuration.")
_LOGGER.info("Please note this is only necessary if you're not using MQTT discovery.")
data = mqtt_component.GenerateHassConfigData(config)
hass_config = OrderedDict()
for domain, component, conf in iter_components(config):
if not hasattr(component, 'to_hass_config'):
continue
func = getattr(component, 'to_hass_config')
ret = func(data, conf)
if not isinstance(ret, (list, tuple)):
ret = [ret]
ret = [x for x in ret if x is not None]
domain_conf = hass_config.setdefault(domain.split('.')[0], [])
domain_conf += ret
safe_print(yaml_util.dump(hass_config))
return 0
def command_dashboard(args):
from esphome.dashboard import dashboard
@@ -391,7 +368,6 @@ POST_CONFIG_ACTIONS = {
'clean-mqtt': command_clean_mqtt,
'mqtt-fingerprint': command_mqtt_fingerprint,
'clean': command_clean,
'hass-config': command_hass_config,
}
@@ -471,10 +447,6 @@ def parse_args(argv):
dashboard.add_argument("--socket",
help="Make the dashboard serve under a unix socket", type=str)
subparsers.add_parser('hass-config',
help="Dump the configuration entries that should be added "
"to Home Assistant when not using MQTT discovery.")
return parser.parse_args(argv[1:])

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: api.proto

View File

@@ -287,16 +287,6 @@ def register_binary_sensor(var, config):
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, config)
def core_to_hass_config(data, config):
ret = mqtt.build_hass_config(data, 'binary_sensor', config,
include_state=True, include_command=False)
if ret is None:
return None
if CONF_DEVICE_CLASS in config:
ret['device_class'] = config[CONF_DEVICE_CLASS]
return ret
BUILD_FLAGS = '-DUSE_BINARY_SENSOR'
CONF_BINARY_SENSOR_IS_ON = 'binary_sensor.is_on'

View File

@@ -30,7 +30,3 @@ def to_code(config):
func = getattr(hub, DIRECTIONS[config[CONF_DIRECTION]])
rhs = func(config[CONF_NAME])
binary_sensor.register_binary_sensor(rhs, config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -33,7 +33,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR'
def to_hass_config(data, config):
return [binary_sensor.core_to_hass_config(data, sens) for sens in config[CONF_BINARY_SENSORS]]

View File

@@ -23,7 +23,3 @@ def to_code(config):
yield
rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS]))
binary_sensor.register_binary_sensor(rhs, config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -56,7 +56,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_ESP32_TOUCH_BINARY_SENSOR'
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -29,7 +29,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_GPIO_BINARY_SENSOR'
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -24,7 +24,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_BINARY_SENSOR'
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -22,7 +22,3 @@ def to_code(config):
yield
rhs = MPR121Channel.new(config[CONF_NAME], config[CONF_CHANNEL])
binary_sensor.register_binary_sensor(hub.add_channel(rhs), config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -27,7 +27,3 @@ def to_code(config):
rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID],
config[CONF_COMPONENT_ID])
binary_sensor.register_binary_sensor(rhs, config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -43,7 +43,3 @@ def to_code(config):
addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')]
rhs = hub.make_tag(config[CONF_NAME], addr)
binary_sensor.register_binary_sensor(rhs, config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -24,7 +24,3 @@ def to_code(config):
yield
rhs = hub.make_card(config[CONF_NAME], config[CONF_UID])
binary_sensor.register_binary_sensor(rhs, config)
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -145,7 +145,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_REMOTE_RECEIVER'
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -22,7 +22,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR'
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -54,7 +54,3 @@ def binary_sensor_template_publish_to_code(config, action_id, template_arg, args
yield None
add(action.set_state(template_))
yield action
def to_hass_config(data, config):
return binary_sensor.core_to_hass_config(data, config)

View File

@@ -96,10 +96,3 @@ def cover_stop_to_code(config, action_id, template_arg, args):
rhs = var.make_stop_action(template_arg)
type = StopAction.template(template_arg)
yield Pvariable(action_id, rhs, type=type)
def core_to_hass_config(data, config):
ret = mqtt.build_hass_config(data, 'cover', config, include_state=True, include_command=True)
if ret is None:
return None
return ret

View File

@@ -77,12 +77,3 @@ def cover_template_publish_to_code(config, action_id, template_arg, args):
yield None
add(action.set_state(template_))
yield action
def to_hass_config(data, config):
ret = cover.core_to_hass_config(data, config)
if ret is None:
return None
if CONF_OPTIMISTIC in config:
ret['optimistic'] = config[CONF_OPTIMISTIC]
return ret

View File

@@ -7,6 +7,7 @@ from esphome.cpp_helpers import setup_component
from esphome.cpp_types import App, Component, esphome_ns
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
CONFLICTS_WITH = ['esp32_ble_tracker']
ESP32BLEBeacon = esphome_ns.class_('ESP32BLEBeacon', Component)

View File

@@ -64,11 +64,11 @@ CONFIG_SCHEMA = cv.Schema({
vol.Required(CONF_VSYNC_PIN): pins.input_pin,
vol.Required(CONF_HREF_PIN): pins.input_pin,
vol.Required(CONF_PIXEL_CLOCK_PIN): pins.input_pin,
vol.Required(CONF_EXTERNAL_CLOCK): vol.Schema({
vol.Required(CONF_EXTERNAL_CLOCK): cv.Schema({
vol.Required(CONF_PIN): pins.output_pin,
vol.Optional(CONF_FREQUENCY, default='20MHz'): vol.All(cv.frequency, vol.In([20e6, 10e6])),
}),
vol.Required(CONF_I2C_PINS): vol.Schema({
vol.Required(CONF_I2C_PINS): cv.Schema({
vol.Required(CONF_SDA): pins.output_pin,
vol.Required(CONF_SCL): pins.output_pin,
}),
@@ -127,4 +127,4 @@ def to_code(config):
add(cam.set_frame_size(FRAME_SIZES[config[CONF_RESOLUTION]]))
BUILD_FLAGS = '-DUSE_ESP32_CAMERA'
BUILD_FLAGS = ['-DUSE_ESP32_CAMERA', '-DBOARD_HAS_PSRAM']

View File

@@ -4,9 +4,9 @@ from esphome.automation import ACTION_REGISTRY, maybe_simple_id
from esphome.components import mqtt
from esphome.components.mqtt import setup_mqtt_component
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_NAME, CONF_OSCILLATING, \
CONF_OSCILLATION_COMMAND_TOPIC, CONF_OSCILLATION_OUTPUT, CONF_OSCILLATION_STATE_TOPIC, \
CONF_SPEED, CONF_SPEED_COMMAND_TOPIC, CONF_SPEED_STATE_TOPIC
from esphome.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_OSCILLATING, \
CONF_OSCILLATION_COMMAND_TOPIC, CONF_OSCILLATION_STATE_TOPIC, CONF_SPEED, \
CONF_SPEED_COMMAND_TOPIC, CONF_SPEED_STATE_TOPIC
from esphome.core import CORE
from esphome.cpp_generator import Pvariable, add, get_variable, templatable
from esphome.cpp_types import Action, Application, Component, Nameable, bool_, esphome_ns
@@ -130,15 +130,3 @@ def fan_turn_on_to_code(config, action_id, template_arg, args):
template_ = FAN_SPEEDS[template_]
add(action.set_speed(template_))
yield action
def core_to_hass_config(data, config):
ret = mqtt.build_hass_config(data, 'fan', config, include_state=True, include_command=True)
if ret is None:
return None
if CONF_OSCILLATION_OUTPUT in config:
default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'oscillation/state')
ret['oscillation_state_topic'] = config.get(CONF_OSCILLATION_STATE_TOPIC, default)
default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'oscillation/command')
ret['oscillation_command__topic'] = config.get(CONF_OSCILLATION_COMMAND_TOPIC, default)
return ret

View File

@@ -28,7 +28,3 @@ def to_code(config):
fan.setup_fan(fan_struct.Pstate, config)
setup_component(fan_struct.Poutput, config)
def to_hass_config(data, config):
return fan.core_to_hass_config(data, config)

View File

@@ -1,6 +1,6 @@
import voluptuous as vol
from esphome.components import fan, mqtt, output
from esphome.components import fan, output
import esphome.config_validation as cv
from esphome.const import CONF_HIGH, CONF_LOW, CONF_MAKE_ID, CONF_MEDIUM, CONF_NAME, \
CONF_OSCILLATION_OUTPUT, CONF_OUTPUT, CONF_SPEED, CONF_SPEED_COMMAND_TOPIC, \
@@ -42,14 +42,3 @@ def to_code(config):
add(fan_struct.Poutput.set_oscillation(oscillation_output))
fan.setup_fan(fan_struct.Pstate, config)
def to_hass_config(data, config):
ret = fan.core_to_hass_config(data, config)
if ret is None:
return None
default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'speed/state')
ret['speed_state_topic'] = config.get(CONF_SPEED_STATE_TOPIC, default)
default = mqtt.get_default_topic_for(data, 'fan', config[CONF_NAME], 'speed/command')
ret['speed_command__topic'] = config.get(CONF_SPEED_COMMAND_TOPIC, default)
return ret

View File

@@ -499,24 +499,3 @@ def light_turn_on_to_code(config, action_id, template_arg, args):
yield None
add(action.set_effect(template_))
yield action
def core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=True,
white_value=True):
ret = mqtt.build_hass_config(data, 'light', config, include_state=True, include_command=True)
if ret is None:
return None
ret['schema'] = 'json'
if brightness:
ret['brightness'] = True
if rgb:
ret['rgb'] = True
if color_temp:
ret['color_temp'] = True
if white_value:
ret['white_value'] = True
for effect in config.get(CONF_EFFECTS, []):
ret["effect"] = True
effects = ret.setdefault("effect_list", [])
effects.append(next(x for x in effect.values())[CONF_NAME])
return ret

View File

@@ -21,8 +21,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=False, rgb=False, color_temp=False,
white_value=False)

View File

@@ -35,8 +35,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=False, color_temp=True,
white_value=False)

View File

@@ -106,8 +106,3 @@ def to_code(config):
REQUIRED_BUILD_FLAGS = '-DUSE_FAST_LED_LIGHT'
LIB_DEPS = 'FastLED@3.2.0'
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False,
white_value=False)

View File

@@ -86,8 +86,3 @@ def to_code(config):
REQUIRED_BUILD_FLAGS = '-DUSE_FAST_LED_LIGHT'
LIB_DEPS = 'FastLED@3.2.0'
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False,
white_value=False)

View File

@@ -24,8 +24,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=False, color_temp=False,
white_value=False)

View File

@@ -188,8 +188,3 @@ def to_code(config):
REQUIRED_BUILD_FLAGS = '-DUSE_NEO_PIXEL_BUS_LIGHT'
LIB_DEPS = 'NeoPixelBus@2.4.1'
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False,
white_value='W' in config[CONF_TYPE])

View File

@@ -46,7 +46,3 @@ def to_code(config):
rhs = App.make_partition_light(config[CONF_NAME], segments)
make = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(make.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False)

View File

@@ -30,8 +30,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False,
white_value=False)

View File

@@ -33,8 +33,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=False,
white_value=True)

View File

@@ -63,8 +63,3 @@ def to_code(config):
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, config)
setup_component(light_struct.Pstate, config)
def to_hass_config(data, config):
return light.core_to_hass_config(data, config, brightness=True, rgb=True, color_temp=True,
white_value=True)

View File

@@ -1,4 +1,3 @@
from collections import OrderedDict
import re
import voluptuous as vol
@@ -9,12 +8,11 @@ from esphome.components import logger
import esphome.config_validation as cv
from esphome.const import CONF_AVAILABILITY, CONF_BIRTH_MESSAGE, CONF_BROKER, CONF_CLIENT_ID, \
CONF_COMMAND_TOPIC, CONF_DISCOVERY, CONF_DISCOVERY_PREFIX, CONF_DISCOVERY_RETAIN, \
CONF_ESPHOME, CONF_ID, CONF_INTERNAL, CONF_KEEPALIVE, CONF_LEVEL, CONF_LOG_TOPIC, \
CONF_MQTT, CONF_NAME, CONF_ON_JSON_MESSAGE, CONF_ON_MESSAGE, CONF_PASSWORD, CONF_PAYLOAD, \
CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE, CONF_PORT, CONF_QOS, CONF_REBOOT_TIMEOUT, \
CONF_RETAIN, CONF_SHUTDOWN_MESSAGE, CONF_SSL_FINGERPRINTS, CONF_STATE_TOPIC, CONF_TOPIC, \
CONF_TOPIC_PREFIX, CONF_TRIGGER_ID, CONF_USERNAME, CONF_WILL_MESSAGE
from esphome.core import EsphomeError
CONF_ID, CONF_KEEPALIVE, CONF_LEVEL, CONF_LOG_TOPIC, CONF_ON_JSON_MESSAGE, CONF_ON_MESSAGE, \
CONF_PASSWORD, CONF_PAYLOAD, CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE, CONF_PORT, \
CONF_QOS, CONF_REBOOT_TIMEOUT, CONF_RETAIN, CONF_SHUTDOWN_MESSAGE, CONF_SSL_FINGERPRINTS, \
CONF_STATE_TOPIC, CONF_TOPIC, CONF_TOPIC_PREFIX, CONF_TRIGGER_ID, CONF_USERNAME, \
CONF_WILL_MESSAGE
from esphome.cpp_generator import Pvariable, RawExpression, StructInitializer, TemplateArguments, \
add, get_variable, process_lambda, templatable
from esphome.cpp_types import Action, App, Component, JsonObjectConstRef, JsonObjectRef, \
@@ -273,61 +271,6 @@ def get_default_topic_for(data, component_type, name, suffix):
sanitized_name, suffix)
def build_hass_config(data, component_type, config, include_state=True, include_command=True):
if config.get(CONF_INTERNAL, False):
return None
ret = OrderedDict()
ret['platform'] = 'mqtt'
ret['name'] = config[CONF_NAME]
if include_state:
default = get_default_topic_for(data, component_type, config[CONF_NAME], 'state')
ret['state_topic'] = config.get(CONF_STATE_TOPIC, default)
if include_command:
default = get_default_topic_for(data, component_type, config[CONF_NAME], 'command')
ret['command_topic'] = config.get(CONF_STATE_TOPIC, default)
avail = config.get(CONF_AVAILABILITY, data.availability)
if avail:
ret['availability_topic'] = avail[CONF_TOPIC]
payload_available = avail[CONF_PAYLOAD_AVAILABLE]
if payload_available != 'online':
ret['payload_available'] = payload_available
payload_not_available = avail[CONF_PAYLOAD_NOT_AVAILABLE]
if payload_not_available != 'offline':
ret['payload_not_available'] = payload_not_available
return ret
class GenerateHassConfigData(object):
def __init__(self, config):
if 'mqtt' not in config:
raise EsphomeError("Cannot generate Home Assistant MQTT config if MQTT is not "
"used!")
mqtt = config[CONF_MQTT]
self.topic_prefix = mqtt.get(CONF_TOPIC_PREFIX, config[CONF_ESPHOME][CONF_NAME])
birth_message = mqtt.get(CONF_BIRTH_MESSAGE)
if CONF_BIRTH_MESSAGE not in mqtt:
birth_message = {
CONF_TOPIC: self.topic_prefix + '/status',
CONF_PAYLOAD: 'online',
}
will_message = mqtt.get(CONF_WILL_MESSAGE)
if CONF_WILL_MESSAGE not in mqtt:
will_message = {
CONF_TOPIC: self.topic_prefix + '/status',
CONF_PAYLOAD: 'offline'
}
if not birth_message or not will_message:
self.availability = None
elif birth_message[CONF_TOPIC] != will_message[CONF_TOPIC]:
self.availability = None
else:
self.availability = {
CONF_TOPIC: birth_message[CONF_TOPIC],
CONF_PAYLOAD_AVAILABLE: birth_message[CONF_PAYLOAD],
CONF_PAYLOAD_NOT_AVAILABLE: will_message[CONF_PAYLOAD],
}
def setup_mqtt_component(obj, config):
if CONF_RETAIN in config:
add(obj.set_retain(config[CONF_RETAIN]))

View File

@@ -273,21 +273,6 @@ def sensor_in_range_to_code(config, condition_id, template_arg, args):
yield cond
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_UNIT_OF_MEASUREMENT in config:
ret['unit_of_measurement'] = config[CONF_UNIT_OF_MEASUREMENT]
if CONF_EXPIRE_AFTER in config:
expire = config[CONF_EXPIRE_AFTER]
if expire is not None:
ret['expire_after'] = expire.total_seconds
if CONF_ICON in config:
ret['icon'] = config[CONF_ICON]
return ret
def _mean(xs):
return sum(xs) / len(xs)

View File

@@ -56,10 +56,6 @@ def required_build_flags(config):
return None
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)
def includes(config):
if config[CONF_PIN] == 'VCC':
return 'ADC_MODE(ADC_VCC);'

View File

@@ -70,7 +70,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_ADS1115_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -29,7 +29,3 @@ def to_code(config):
func = getattr(hub, TYPES[config[CONF_TYPE]])
rhs = func(config[CONF_NAME])
sensor.register_sensor(rhs, config)
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -39,7 +39,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_BH1750'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -24,7 +24,3 @@ def to_code(config):
yield
rhs = hub.make_rssi_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS]))
sensor.register_sensor(rhs, config)
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -85,9 +85,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_BME280'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_PRESSURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -108,10 +108,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_BME680'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_PRESSURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY]),
sensor.core_to_hass_config(data, config[CONF_GAS_RESISTANCE])]

View File

@@ -43,8 +43,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_BMP085_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_PRESSURE])]

View File

@@ -75,8 +75,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_BMP280'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_PRESSURE])]

View File

@@ -57,11 +57,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_CSE7766'
def to_hass_config(data, config):
ret = []
for key in (CONF_VOLTAGE, CONF_CURRENT, CONF_POWER):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -31,7 +31,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_CUSTOM_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, sens) for sens in config[CONF_SENSORS]]

View File

@@ -32,7 +32,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_DALLAS_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -57,8 +57,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_DHT_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -40,8 +40,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_DHT12_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -29,7 +29,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_DUTY_CYCLE_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -26,7 +26,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_ESP32_HALL_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -40,8 +40,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HDC1080_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -66,11 +66,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HLW8012'
def to_hass_config(data, config):
ret = []
for key in (CONF_VOLTAGE, CONF_CURRENT, CONF_POWER):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -87,11 +87,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HMC5883L'
def to_hass_config(data, config):
ret = []
for key in (CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, CONF_FIELD_STRENGTH_Z, CONF_HEADING):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -23,7 +23,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -41,8 +41,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HTU21D_SENSOR'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -47,7 +47,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_HX711'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -66,11 +66,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_INA219'
def to_hass_config(data, config):
ret = []
for key in (CONF_BUS_VOLTAGE, CONF_SHUNT_VOLTAGE, CONF_CURRENT, CONF_POWER):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -77,15 +77,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_INA3221'
def to_hass_config(data, config):
ret = []
for channel in (CONF_CHANNEL_1, CONF_CHANNEL_2, CONF_CHANNEL_3):
if channel not in config:
continue
conf = config[channel]
for key in (CONF_BUS_VOLTAGE, CONF_SHUNT_VOLTAGE, CONF_CURRENT, CONF_POWER):
if key in conf:
ret.append(sensor.core_to_hass_config(data, conf[key]))
return ret

View File

@@ -33,7 +33,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MAX31855_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -34,7 +34,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MAX6675_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -45,11 +45,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MHZ19'
def to_hass_config(data, config):
ret = []
for key in (CONF_CO2, CONF_TEMPERATURE):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -90,12 +90,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MPU6050'
def to_hass_config(data, config):
ret = []
for key in (CONF_ACCEL_X, CONF_ACCEL_Y, CONF_ACCEL_Z, CONF_GYRO_X, CONF_GYRO_Y, CONF_GYRO_Z,
CONF_TEMPERATURE):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -30,7 +30,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MQTT_SUBSCRIBE_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -44,8 +44,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_MS5611'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_PRESSURE])]

View File

@@ -95,12 +95,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_PMSX003'
def to_hass_config(data, config):
ret = []
for key in (CONF_PM_1_0, CONF_PM_2_5, CONF_PM_10_0, CONF_TEMPERATURE, CONF_HUMIDITY,
CONF_FORMALDEHYDE):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -76,7 +76,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_PULSE_COUNTER_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -63,14 +63,10 @@ def to_code(config):
if CONF_MIN_VALUE in config:
add(encoder.set_min_value(config[CONF_MIN_VALUE]))
if CONF_MAX_VALUE in config:
add(encoder.set_min_value(config[CONF_MAX_VALUE]))
add(encoder.set_max_value(config[CONF_MAX_VALUE]))
sensor.setup_sensor(encoder, config)
setup_component(encoder, config)
BUILD_FLAGS = '-DUSE_ROTARY_ENCODER_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -68,11 +68,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_SDS011'
def to_hass_config(data, config):
ret = []
for key in (CONF_PM_2_5, CONF_PM_10_0):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -42,8 +42,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_SHT3XD'
def to_hass_config(data, config):
return [sensor.core_to_hass_config(data, config[CONF_TEMPERATURE]),
sensor.core_to_hass_config(data, config[CONF_HUMIDITY])]

View File

@@ -102,12 +102,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_TCS34725'
def to_hass_config(data, config):
ret = []
for key in (CONF_RED_CHANNEL, CONF_GREEN_CHANNEL, CONF_BLUE_CHANNEL, CONF_CLEAR_CHANNEL,
CONF_ILLUMINANCE, CONF_COLOR_TEMPERATURE):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -52,7 +52,3 @@ def sensor_template_publish_to_code(config, action_id, template_arg, args):
yield None
add(action.set_state(template_))
yield action
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -32,7 +32,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_TOTAL_DAILY_ENERGY_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -63,7 +63,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_TSL2561'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -52,7 +52,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_ULTRASONIC_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -24,7 +24,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_UPTIME_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -24,7 +24,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_WIFI_SIGNAL_SENSOR'
def to_hass_config(data, config):
return sensor.core_to_hass_config(data, config)

View File

@@ -42,12 +42,3 @@ def to_code(config):
if CONF_BATTERY_LEVEL in config:
conf = config[CONF_BATTERY_LEVEL]
sensor.register_sensor(dev.Pmake_battery_level_sensor(conf[CONF_NAME]), conf)
def to_hass_config(data, config):
ret = []
for key in (CONF_TEMPERATURE, CONF_MOISTURE, CONF_ILLUMINANCE, CONF_CONDUCTIVITY,
CONF_BATTERY_LEVEL):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -34,11 +34,3 @@ def to_code(config):
if CONF_BATTERY_LEVEL in config:
conf = config[CONF_BATTERY_LEVEL]
sensor.register_sensor(dev.Pmake_battery_level_sensor(conf[CONF_NAME]), conf)
def to_hass_config(data, config):
ret = []
for key in (CONF_TEMPERATURE, CONF_HUMIDITY, CONF_BATTERY_LEVEL):
if key in config:
ret.append(sensor.core_to_hass_config(data, config[key]))
return ret

View File

@@ -6,7 +6,7 @@ from esphome.components import mqtt
from esphome.components.mqtt import setup_mqtt_component
import esphome.config_validation as cv
from esphome.const import CONF_ICON, CONF_ID, CONF_INTERNAL, CONF_INVERTED, CONF_MQTT_ID, \
CONF_ON_TURN_OFF, CONF_ON_TURN_ON, CONF_OPTIMISTIC, CONF_TRIGGER_ID
CONF_ON_TURN_OFF, CONF_ON_TURN_ON, CONF_TRIGGER_ID
from esphome.core import CORE
from esphome.cpp_generator import Pvariable, add, get_variable
from esphome.cpp_types import Action, App, Nameable, Trigger, esphome_ns
@@ -149,14 +149,3 @@ def switch_is_off_to_code(config, condition_id, template_arg, args):
rhs = var.make_switch_is_off_condition(template_arg)
type = SwitchCondition.template(template_arg)
yield Pvariable(condition_id, rhs, type=type)
def core_to_hass_config(data, config):
ret = mqtt.build_hass_config(data, 'switch', config, include_state=True, include_command=True)
if ret is None:
return None
if CONF_ICON in config:
ret['icon'] = config[CONF_ICON]
if CONF_OPTIMISTIC in config:
ret['optimistic'] = config[CONF_OPTIMISTIC]
return ret

View File

@@ -32,7 +32,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_CUSTOM_SWITCH'
def to_hass_config(data, config):
return [switch.core_to_hass_config(data, swi) for swi in config[CONF_SWITCHES]]

View File

@@ -48,7 +48,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_GPIO_SWITCH'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -26,7 +26,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_OUTPUT_SWITCH'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -164,7 +164,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_REMOTE_TRANSMITTER'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -21,7 +21,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_RESTART_SWITCH'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -21,7 +21,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_SHUTDOWN_SWITCH'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -72,7 +72,3 @@ def switch_template_publish_to_code(config, action_id, template_arg, args):
yield None
add(action.set_state(template_))
yield action
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

View File

@@ -44,7 +44,3 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_UART_SWITCH'
def to_hass_config(data, config):
return switch.core_to_hass_config(data, config)

Some files were not shown because too many files have changed in this diff Show More