diff --git a/esphomeyaml/components/switch/custom.py b/esphomeyaml/components/switch/custom.py index 00254abb81..320a8855bf 100644 --- a/esphomeyaml/components/switch/custom.py +++ b/esphomeyaml/components/switch/custom.py @@ -1,14 +1,14 @@ import voluptuous as vol -from esphomeyaml.components import binary_sensor, switch +from esphomeyaml.components import switch import esphomeyaml.config_validation as cv -from esphomeyaml.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA, CONF_SWITCHES +from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_SWITCHES from esphomeyaml.cpp_generator import process_lambda, variable from esphomeyaml.cpp_types import std_vector CustomSwitchConstructor = switch.switch_ns.class_('CustomSwitchConstructor') -PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({ +PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(CustomSwitchConstructor), vol.Required(CONF_LAMBDA): cv.lambda_, vol.Required(CONF_SWITCHES): @@ -29,8 +29,8 @@ def to_code(config): switch.register_switch(custom.get_switch(i), sens) -BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR' +BUILD_FLAGS = '-DUSE_CUSTOM_SWITCH' def to_hass_config(data, config): - return [binary_sensor.core_to_hass_config(data, sens) for sens in config[CONF_BINARY_SENSORS]] + return [switch.core_to_hass_config(data, swi) for swi in config[CONF_SWITCHES]] diff --git a/esphomeyaml/config_validation.py b/esphomeyaml/config_validation.py index bd6cafc22e..d2f13275b3 100644 --- a/esphomeyaml/config_validation.py +++ b/esphomeyaml/config_validation.py @@ -590,10 +590,12 @@ def one_of(*values, **kwargs): upper = kwargs.get('upper', False) string_ = kwargs.get('string', False) or lower or upper to_int = kwargs.get('int', False) + space = kwargs.get('space', ' ') def validator(value): if string_: value = string(value) + value = value.replace(' ', space) if to_int: value = int_(value) if lower: diff --git a/esphomeyaml/const.py b/esphomeyaml/const.py index 71ef6751b9..765682ff64 100644 --- a/esphomeyaml/const.py +++ b/esphomeyaml/const.py @@ -378,6 +378,12 @@ CONF_SWITCHES = 'switches' CONF_TEXT_SENSORS = 'text_sensors' CONF_INCLUDES = 'includes' CONF_LIBRARIES = 'libraries' +CONF_PIN_A = 'pin_a' +CONF_PIN_B = 'pin_b' +CONF_PIN_C = 'pin_c' +CONF_PIN_D = 'pin_d' +CONF_SLEEP_WHEN_DONE = 'sleep_when_done' +CONF_STEP_MODE = 'step_mode' ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_' ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage' diff --git a/esphomeyaml/dashboard/dashboard.py b/esphomeyaml/dashboard/dashboard.py index 117701a2ae..328d49fd8f 100644 --- a/esphomeyaml/dashboard/dashboard.py +++ b/esphomeyaml/dashboard/dashboard.py @@ -269,6 +269,12 @@ class DashboardEntry(object): return None return self.storage.board + @property + def update_available(self): + if self.storage is None: + return True + return self.storage.esphomeyaml_version != const.__version__ + class MainRequestHandler(BaseHandler): def get(self): diff --git a/esphomeyaml/dashboard/static/esphomeyaml.css b/esphomeyaml/dashboard/static/esphomeyaml.css index acdeb8de5a..9fb4a5006b 100644 --- a/esphomeyaml/dashboard/static/esphomeyaml.css +++ b/esphomeyaml/dashboard/static/esphomeyaml.css @@ -204,3 +204,11 @@ ul.stepper:not(.horizontal) .step.active::before, ul.stepper:not(.horizontal) .s border-radius: 3px; height: 100% } + +.update-available i { + vertical-align: bottom; + font-size: 20px !important; + color: #3F51B5 !important; + margin-right: -4.5px; + margin-left: -5.5px; +} diff --git a/esphomeyaml/dashboard/static/esphomeyaml.js b/esphomeyaml/dashboard/static/esphomeyaml.js index df498ba4fa..26b15e7d21 100644 --- a/esphomeyaml/dashboard/static/esphomeyaml.js +++ b/esphomeyaml/dashboard/static/esphomeyaml.js @@ -23,6 +23,13 @@ const colorReplace = (input) => { return input; }; +const removeUpdateAvailable = (filename) => { + const p = document.querySelector(`.update-available[data-node="${filename}"]`); + if (p === undefined) + return; + p.remove(); +}; + let configuration = ""; let wsProtocol = "ws:"; if (window.location.protocol === "https:") { @@ -202,6 +209,7 @@ document.querySelectorAll(".action-upload").forEach((upload) => { } else if (data.event === "exit") { if (data.code === 0) { M.toast({html: "Program exited successfully."}); + removeUpdateAvailable(configuration); } else { M.toast({html: `Program failed with code ${data.code}`}); } @@ -481,7 +489,6 @@ const editorElem = editModalElem.querySelector("#editor"); const editor = ace.edit(editorElem); editor.setTheme("ace/theme/dreamweaver"); editor.session.setMode("ace/mode/yaml"); -editor.session.setValue("Hello World!"); editor.session.setOption('useSoftTabs', true); editor.session.setOption('tabSize', 2); diff --git a/esphomeyaml/dashboard/templates/index.html b/esphomeyaml/dashboard/templates/index.html index c1bc54fbe3..9d6bd62c35 100644 --- a/esphomeyaml/dashboard/templates/index.html +++ b/esphomeyaml/dashboard/templates/index.html @@ -4,17 +4,17 @@ esphomeyaml Dashboard - - - - + + + + - - - - + + + + - + @@ -61,8 +61,15 @@

- . Full path: {{ escape(entry.full_path) }} + . + Full path: {{ escape(entry.full_path) }}

+ {% if entry.update_available %} +

+ system_update + Update Available! +

+ {% end %}
Upload @@ -500,8 +507,8 @@
- - + + {% if len(entries) == 0 %}