mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Initial Sonoff support
This commit is contained in:
parent
8639eb1b27
commit
4b9bb2b731
4 changed files with 22 additions and 9 deletions
|
@ -9,8 +9,9 @@ from voluptuous.humanize import humanize_error
|
|||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml import core, yaml_util
|
||||
from esphomeyaml.const import CONF_BOARD, CONF_ESPHOMEYAML, CONF_LIBRARY_URI, CONF_NAME, \
|
||||
CONF_PLATFORM, CONF_SIMPLIFY, CONF_USE_BUILD_FLAGS, CONF_WIFI, ESP_PLATFORMS, \
|
||||
from esphomeyaml.const import CONF_BOARD, CONF_BOARD_FLASH_MODE, CONF_ESPHOMEYAML, \
|
||||
CONF_LIBRARY_URI, \
|
||||
CONF_NAME, CONF_PLATFORM, CONF_SIMPLIFY, CONF_USE_BUILD_FLAGS, CONF_WIFI, ESP_PLATFORMS, \
|
||||
ESP_PLATFORM_ESP32, ESP_PLATFORM_ESP8266
|
||||
from esphomeyaml.core import ESPHomeYAMLError
|
||||
from esphomeyaml.helpers import App, add, color
|
||||
|
@ -19,6 +20,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
DEFAULT_LIBRARY_URI = u'https://github.com/OttoWinter/esphomelib.git#v1.5.0'
|
||||
|
||||
BUILD_FLASH_MODES = ['qio', 'qout', 'dio', 'dout']
|
||||
|
||||
CORE_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_NAME): cv.valid_name,
|
||||
vol.Required(CONF_PLATFORM): cv.string,
|
||||
|
@ -26,6 +29,7 @@ CORE_SCHEMA = vol.Schema({
|
|||
vol.Optional(CONF_LIBRARY_URI, default=DEFAULT_LIBRARY_URI): cv.string,
|
||||
vol.Optional(CONF_SIMPLIFY, default=True): cv.boolean,
|
||||
vol.Optional(CONF_USE_BUILD_FLAGS, default=True): cv.boolean,
|
||||
vol.Optional(CONF_BOARD_FLASH_MODE): vol.All(vol.Lower, vol.Any(*BUILD_FLASH_MODES)),
|
||||
})
|
||||
|
||||
REQUIRED_COMPONENTS = [
|
||||
|
|
|
@ -185,6 +185,7 @@ CONF_DATA_PIN = 'data_pin'
|
|||
CONF_CLOCK_PIN = 'clock_pin'
|
||||
CONF_RGB_ORDER = 'rgb_order'
|
||||
CONF_ACCURACY = 'accuracy'
|
||||
CONF_BOARD_FLASH_MODE = 'board_flash_mode'
|
||||
|
||||
ESP32_BOARDS = [
|
||||
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',
|
||||
|
|
|
@ -8,7 +8,8 @@ import voluptuous as vol
|
|||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.components import mqtt
|
||||
from esphomeyaml.const import ESP_BOARDS_FOR_PLATFORM, ESP_PLATFORMS, ESP_PLATFORM_ESP32
|
||||
from esphomeyaml.const import ESP_BOARDS_FOR_PLATFORM, ESP_PLATFORMS, ESP_PLATFORM_ESP32, \
|
||||
ESP_PLATFORM_ESP8266
|
||||
from esphomeyaml.helpers import color
|
||||
|
||||
|
||||
|
@ -141,10 +142,10 @@ def wizard(path):
|
|||
print("Great! Your node is now called \"{}\".".format(color('cyan', name)))
|
||||
sleep(1)
|
||||
print_step(2, ESP_BIG)
|
||||
print("Now I'd like to know which *board* you're using so that I can compile "
|
||||
print("Now I'd like to know what microcontroller you're using so that I can compile "
|
||||
"firmwares for it.")
|
||||
print("Are you using an " + color('green', 'ESP32') + " or " +
|
||||
color('green', 'ESP8266') + " based board?")
|
||||
color('green', 'ESP8266') + " platform? (Choose ESP8266 for Sonoff devices)")
|
||||
while True:
|
||||
sleep(0.5)
|
||||
print()
|
||||
|
@ -168,6 +169,8 @@ def wizard(path):
|
|||
print("Next, I need to know what " + color('green', 'board') + " you're using.")
|
||||
sleep(0.5)
|
||||
print("Please go to {} and choose a board.".format(color('green', board_link)))
|
||||
if platform == ESP_PLATFORM_ESP8266:
|
||||
print("(Type " + color('green', 'esp01_1m') + " for Sonoff devices)")
|
||||
print()
|
||||
# Don't sleep because user needs to copy link
|
||||
if platform == ESP_PLATFORM_ESP32:
|
||||
|
@ -217,7 +220,7 @@ def wizard(path):
|
|||
sleep(0.75)
|
||||
|
||||
print("Now please state the " + color('green', 'password') +
|
||||
" of the WiFi network so that I can connect to it.")
|
||||
" of the WiFi network so that I can connect to it (Leave empty for no password)")
|
||||
print()
|
||||
print("For example \"{}\"".format(color('bold_white', 'PASSWORD42')))
|
||||
sleep(0.5)
|
||||
|
|
|
@ -6,8 +6,9 @@ import os
|
|||
|
||||
from esphomeyaml import core
|
||||
from esphomeyaml.config import iter_components
|
||||
from esphomeyaml.const import CONF_BOARD, CONF_ESPHOMEYAML, CONF_LIBRARY_URI, CONF_NAME, \
|
||||
CONF_PLATFORM, CONF_USE_BUILD_FLAGS, ESP_PLATFORM_ESP32, ESP_PLATFORM_ESP8266
|
||||
from esphomeyaml.const import CONF_BOARD, CONF_BOARD_FLASH_MODE, CONF_ESPHOMEYAML, \
|
||||
CONF_LIBRARY_URI, \
|
||||
CONF_NAME, CONF_PLATFORM, CONF_USE_BUILD_FLAGS, ESP_PLATFORM_ESP32, ESP_PLATFORM_ESP8266
|
||||
from esphomeyaml.core import ESPHomeYAMLError
|
||||
|
||||
CPP_AUTO_GENERATE_BEGIN = u'// ========== AUTO GENERATED CODE BEGIN ==========='
|
||||
|
@ -116,7 +117,11 @@ def get_ini_content(config):
|
|||
if lib_deps:
|
||||
options[u'lib_deps'] = u'\n '.join(lib_deps)
|
||||
|
||||
return INI_CONTENT_FORMAT.format(**options)
|
||||
content = INI_CONTENT_FORMAT.format(**options)
|
||||
if CONF_BOARD_FLASH_MODE in config[CONF_ESPHOMEYAML]:
|
||||
flash_mode = config[CONF_ESPHOMEYAML][CONF_BOARD_FLASH_MODE]
|
||||
content += "board_flash_mode = {}\n".format(flash_mode)
|
||||
return content
|
||||
|
||||
|
||||
def mkdir_p(path):
|
||||
|
|
Loading…
Reference in a new issue