From 52dbd35118bd9d2b559affdfca8c5ce63d008dfa Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 6 Jan 2019 16:59:11 +0100 Subject: [PATCH] Add neopixelbus tests --- esphomeyaml/components/api.py | 4 +-- esphomeyaml/components/light/neopixelbus.py | 4 +-- esphomeyaml/writer.py | 31 +++++++++++---------- tests/test1.yaml | 16 +++++++++++ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/esphomeyaml/components/api.py b/esphomeyaml/components/api.py index c1ed16ae95..eb8bc3b682 100644 --- a/esphomeyaml/components/api.py +++ b/esphomeyaml/components/api.py @@ -49,7 +49,7 @@ def lib_deps(config): CONF_HOMEASSISTANT_SERVICE = 'homeassistant.service' -LOGGER_LOG_ACTION_SCHEMA = vol.Schema({ +HOMEASSISTANT_SERVIC_ACTION_SCHEMA = vol.Schema({ cv.GenerateID(): cv.use_variable_id(APIServer), vol.Required(CONF_SERVICE): cv.string, vol.Optional(CONF_DATA): vol.Schema({ @@ -64,7 +64,7 @@ LOGGER_LOG_ACTION_SCHEMA = vol.Schema({ }) -@ACTION_REGISTRY.register(CONF_HOMEASSISTANT_SERVICE, LOGGER_LOG_ACTION_SCHEMA) +@ACTION_REGISTRY.register(CONF_HOMEASSISTANT_SERVICE, HOMEASSISTANT_SERVIC_ACTION_SCHEMA) def homeassistant_service_to_code(config, action_id, arg_type, template_arg): for var in get_variable(config[CONF_ID]): yield None diff --git a/esphomeyaml/components/light/neopixelbus.py b/esphomeyaml/components/light/neopixelbus.py index 36a5cbb6a7..01841094e7 100644 --- a/esphomeyaml/components/light/neopixelbus.py +++ b/esphomeyaml/components/light/neopixelbus.py @@ -54,9 +54,9 @@ def validate_method(value): raise NotImplementedError if CORE.is_esp32: - return cv.one_of(*ESP32_METHODS, upper=True, space='_') + return cv.one_of(*ESP32_METHODS, upper=True, space='_')(value) if CORE.is_esp8266: - return cv.one_of(*ESP8266_METHODS, upper=True, space='_') + return cv.one_of(*ESP8266_METHODS, upper=True, space='_')(value) raise NotImplementedError diff --git a/esphomeyaml/writer.py b/esphomeyaml/writer.py index 235f8078ce..46e3557962 100644 --- a/esphomeyaml/writer.py +++ b/esphomeyaml/writer.py @@ -305,8 +305,8 @@ def gather_build_flags(): def get_ini_content(): - lib_deps = gather_lib_deps() + ['${common.lib_deps}'] - build_flags = gather_build_flags() + ['${common.build_flags}'] + lib_deps = gather_lib_deps() + build_flags = gather_build_flags() if CORE.is_esp8266 and CORE.board in ESP8266_FLASH_SIZES: flash_size = ESP8266_FLASH_SIZES[CORE.board] @@ -326,11 +326,23 @@ def get_ini_content(): 'platform': CORE.config[CONF_ESPHOMEYAML][CONF_ARDUINO_VERSION], 'board': CORE.board, 'framework': 'arduino', - 'lib_deps': lib_deps, - 'build_flags': build_flags, + 'lib_deps': lib_deps + ['${common.lib_deps}'], + 'build_flags': build_flags + ['${common.build_flags}'], 'upload_speed': UPLOAD_SPEED_OVERRIDE.get(CORE.board, 115200), } + if 'esp32_ble_beacon' in CORE.config or 'esp32_ble_tracker' in CORE.config: + data['board_build.partitions'] = "partitions.csv" + partitions_csv = CORE.relative_build_path('partitions.csv') + if not os.path.isfile(partitions_csv): + with open(partitions_csv, "w") as f: + f.write("nvs, data, nvs, 0x009000, 0x005000,\n") + f.write("otadata, data, ota, 0x00e000, 0x002000,\n") + f.write("app0, app, ota_0, 0x010000, 0x190000,\n") + f.write("app1, app, ota_1, 0x200000, 0x190000,\n") + f.write("eeprom, data, 0x99, 0x390000, 0x001000,\n") + f.write("spiffs, data, spiffs, 0x391000, 0x00F000\n") + if CONF_BOARD_FLASH_MODE in CORE.config[CONF_ESPHOMEYAML]: flash_mode = CORE.config[CONF_ESPHOMEYAML][CONF_BOARD_FLASH_MODE] data['board_build.flash_mode'] = flash_mode @@ -391,17 +403,6 @@ def write_platformio_project(): platformio_ini = CORE.relative_build_path('platformio.ini') content = get_ini_content() - if 'esp32_ble_beacon' in CORE.config or 'esp32_ble_tracker' in CORE.config: - content += 'board_build.partitions = partitions.csv\n' - partitions_csv = CORE.relative_build_path('partitions.csv') - if not os.path.isfile(partitions_csv): - with open(partitions_csv, "w") as f: - f.write("nvs, data, nvs, 0x009000, 0x005000,\n") - f.write("otadata, data, ota, 0x00e000, 0x002000,\n") - f.write("app0, app, ota_0, 0x010000, 0x190000,\n") - f.write("app1, app, ota_1, 0x200000, 0x190000,\n") - f.write("eeprom, data, 0x99, 0x390000, 0x001000,\n") - f.write("spiffs, data, spiffs, 0x391000, 0x00F000\n") write_gitignore() write_platformio_ini(content, platformio_ini) diff --git a/tests/test1.yaml b/tests/test1.yaml index 47ba28bac2..ba5bd1f791 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -771,6 +771,22 @@ light: num_leds: 60 rgb_order: BRG name: "FastLED SPI Light" + - platform: neopixelbus + name: "Neopixelbus Light" + gamma_correct: 2.8 + color_correct: [0.0, 0.0, 0.0, 0.0] + default_transition_length: 10s + power_supply: atx_power_supply + effects: + - addressable_flicker: + name: Flicker Effect With Custom Values + update_interval: 16ms + intensity: 5% + type: GRBW + variant: SK6812 + method: ESP32_I2S_0 + num_leds: 60 + pin: GPIO23 remote_transmitter: - pin: 32