Skip to content

Commit

Permalink
Changes for 1.12 (#482)
Browse files Browse the repository at this point in the history
* Update setup scripts

* Add delete action, remove Hass config command

* Update esphome.js

* Lint
  • Loading branch information
OttoWinter committed Mar 16, 2019
1 parent 596c334 commit 9fea094
Show file tree
Hide file tree
Showing 107 changed files with 157 additions and 838 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Expand Up @@ -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
Expand Down
21 changes: 5 additions & 16 deletions MANIFEST.in
@@ -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
28 changes: 0 additions & 28 deletions esphome/__main__.py
@@ -1,7 +1,6 @@
from __future__ import print_function

import argparse
from collections import OrderedDict
from datetime import datetime
import logging
import os
Expand Down Expand Up @@ -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

Expand All @@ -391,7 +368,6 @@ def command_dashboard(args):
'clean-mqtt': command_clean_mqtt,
'mqtt-fingerprint': command_mqtt_fingerprint,
'clean': command_clean,
'hass-config': command_hass_config,
}


Expand Down Expand Up @@ -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:])


Expand Down
1 change: 1 addition & 0 deletions esphome/api/api_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions esphome/components/binary_sensor/__init__.py
Expand Up @@ -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'
Expand Down
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/apds9960.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/custom.py
Expand Up @@ -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]]
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/esp32_ble_tracker.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/esp32_touch.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/gpio.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/homeassistant.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/mpr121.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/nextion.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/pn532.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/rdm6300.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/remote_receiver.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/status.py
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions esphome/components/binary_sensor/template.py
Expand Up @@ -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)
7 changes: 0 additions & 7 deletions esphome/components/cover/__init__.py
Expand Up @@ -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
9 changes: 0 additions & 9 deletions esphome/components/cover/template.py
Expand Up @@ -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
18 changes: 3 additions & 15 deletions esphome/components/fan/__init__.py
Expand Up @@ -4,9 +4,9 @@
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
Expand Down Expand Up @@ -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
4 changes: 0 additions & 4 deletions esphome/components/fan/binary.py
Expand Up @@ -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)
13 changes: 1 addition & 12 deletions esphome/components/fan/speed.py
@@ -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, \
Expand Down Expand Up @@ -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
21 changes: 0 additions & 21 deletions esphome/components/light/__init__.py
Expand Up @@ -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
5 changes: 0 additions & 5 deletions esphome/components/light/binary.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/cwww.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/fastled_clockless.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/fastled_spi.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/monochromatic.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/neopixelbus.py
Expand Up @@ -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])
4 changes: 0 additions & 4 deletions esphome/components/light/partition.py
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions esphome/components/light/rgb.py
Expand Up @@ -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)

0 comments on commit 9fea094

Please sign in to comment.