mirror of
https://github.com/esphome/esphome.git
synced 2026-02-27 17:34:22 -07:00
Merge branch 'beta'
This commit is contained in:
4
tests/.gitignore
vendored
4
tests/.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
# Gitignore settings for esphomeyaml
|
||||
# Gitignore settings for ESPHome
|
||||
# This is an example and may include too much for your use-case.
|
||||
# You can modify this file to suit your needs.
|
||||
/.esphomeyaml/
|
||||
/.esphome/
|
||||
**/.pioenvs/
|
||||
**/.piolibdeps/
|
||||
**/lib/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Tests for esphomeyaml
|
||||
# Tests for ESPHome
|
||||
|
||||
This directory contains some tests for esphomeyaml.
|
||||
This directory contains some tests for ESPHome.
|
||||
At the moment, all the tests only work by simply executing
|
||||
`esphomeyaml` over some YAML files that are made to test
|
||||
all of esphomeyaml's features.
|
||||
`esphome` over some YAML files that are made to test
|
||||
whether the yaml gets converted to the proper C++ code.
|
||||
|
||||
Of course this is all just very high-level and things like
|
||||
unit tests would be much better. So if you have time and know
|
||||
|
||||
128
tests/test1.yaml
128
tests/test1.yaml
@@ -1,10 +1,12 @@
|
||||
esphomeyaml:
|
||||
esphome:
|
||||
name: test1
|
||||
platform: ESP32
|
||||
board: nodemcu-32s
|
||||
# Use this for testing while developing:
|
||||
# esphomelib_version:
|
||||
# local: ~/path/to/esphomelib
|
||||
# Note the travis check for esphome PRs will fail until the
|
||||
# esphome-core PR has been merged.
|
||||
# esphome_core_version:
|
||||
# local: ~/path/to/esphome-core
|
||||
use_custom_code: false
|
||||
on_boot:
|
||||
priority: 150.0
|
||||
@@ -35,7 +37,6 @@ wifi:
|
||||
subnet: 255.255.255.0
|
||||
dns1: 1.1.1.1
|
||||
dns2: 1.2.2.1
|
||||
hostname: myverylonghostname
|
||||
domain: .local
|
||||
reboot_timeout: 120s
|
||||
power_save_mode: none
|
||||
@@ -124,8 +125,8 @@ logger:
|
||||
|
||||
web_server:
|
||||
port: 8080
|
||||
css_url: https://esphomelib.com/_static/webserver-v1.min.css
|
||||
js_url: https://esphomelib.com/_static/webserver-v1.min.js
|
||||
css_url: https://esphome.io/_static/webserver-v1.min.css
|
||||
js_url: https://esphome.io/_static/webserver-v1.min.js
|
||||
|
||||
power_supply:
|
||||
id: 'atx_power_supply'
|
||||
@@ -137,7 +138,6 @@ power_supply:
|
||||
|
||||
deep_sleep:
|
||||
run_duration: 20s
|
||||
run_cycles: 500
|
||||
sleep_duration: 50s
|
||||
wakeup_pin: GPIO39
|
||||
wakeup_pin_mode: INVERT_WAKEUP
|
||||
@@ -194,6 +194,8 @@ sensor:
|
||||
then:
|
||||
- lambda: >-
|
||||
ESP_LOGD("main", "Got value range %f", x);
|
||||
- wait_until:
|
||||
binary_sensor.is_on: binary_sensor1
|
||||
on_raw_value:
|
||||
- lambda: >-
|
||||
ESP_LOGD("main", "Got raw value %f", x);
|
||||
@@ -435,13 +437,21 @@ sensor:
|
||||
update_interval: 15s
|
||||
- platform: template
|
||||
name: "Template Sensor"
|
||||
lambda: >-
|
||||
id: template_sensor
|
||||
lambda: |-
|
||||
if (id(ultrasonic_sensor1).state > 1) {
|
||||
return 42.0;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
update_interval: 15s
|
||||
on_value:
|
||||
- sensor.template.publish:
|
||||
id: template_sensor
|
||||
state: 43.0
|
||||
- sensor.template.publish:
|
||||
id: template_sensor
|
||||
state: !lambda 'return NAN;'
|
||||
- platform: tsl2561
|
||||
name: "TSL2561 Ambient Light"
|
||||
address: 0x39
|
||||
@@ -462,6 +472,17 @@ sensor:
|
||||
- platform: wifi_signal
|
||||
name: "WiFi Signal Sensor"
|
||||
update_interval: 15s
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Sensor 1"
|
||||
topic: "mqtt/topic"
|
||||
id: the_sensor
|
||||
qos: 2
|
||||
on_value:
|
||||
- mqtt.publish_json:
|
||||
topic: the/topic
|
||||
payload: |-
|
||||
root["key"] = id(the_sensor).value;
|
||||
root["greeting"] = "Hello World";
|
||||
|
||||
|
||||
esp32_touch:
|
||||
@@ -482,7 +503,6 @@ binary_sensor:
|
||||
- invert:
|
||||
- delayed_on: 40ms
|
||||
- delayed_off: 40ms
|
||||
- heartbeat: 1s
|
||||
on_press:
|
||||
then:
|
||||
- lambda: >-
|
||||
@@ -552,7 +572,8 @@ binary_sensor:
|
||||
name: "Nextion Component 2 Touch"
|
||||
- platform: template
|
||||
name: "Garage Door Open"
|
||||
lambda: >-
|
||||
id: garage_door
|
||||
lambda: |-
|
||||
if (isnan(id(my_sensor).state)) {
|
||||
// isnan checks if the ultrasonic sensor echo
|
||||
// has timed out, resulting in a NaN (not a number) state
|
||||
@@ -565,6 +586,10 @@ binary_sensor:
|
||||
// Garage Door is closed.
|
||||
return false;
|
||||
}
|
||||
on_press:
|
||||
- binary_sensor.template.publish:
|
||||
id: garage_door
|
||||
state: OFF
|
||||
- platform: pn532
|
||||
uid: 74-10-37-94
|
||||
name: "PN532 NFC Tag"
|
||||
@@ -715,6 +740,7 @@ light:
|
||||
cold_white_color_temperature: 153 mireds
|
||||
warm_white_color_temperature: 500 mireds
|
||||
- platform: fastled_clockless
|
||||
id: addr1
|
||||
chipset: WS2811
|
||||
pin: GPIO23
|
||||
num_leds: 60
|
||||
@@ -765,6 +791,7 @@ light:
|
||||
update_interval: 16ms
|
||||
intensity: 5%
|
||||
- platform: fastled_spi
|
||||
id: addr2
|
||||
chipset: WS2801
|
||||
data_pin: GPIO23
|
||||
clock_pin: GPIO22
|
||||
@@ -772,6 +799,7 @@ light:
|
||||
rgb_order: BRG
|
||||
name: "FastLED SPI Light"
|
||||
- platform: neopixelbus
|
||||
id: addr3
|
||||
name: "Neopixelbus Light"
|
||||
gamma_correct: 2.8
|
||||
color_correct: [0.0, 0.0, 0.0, 0.0]
|
||||
@@ -787,6 +815,18 @@ light:
|
||||
method: ESP32_I2S_0
|
||||
num_leds: 60
|
||||
pin: GPIO23
|
||||
- platform: partition
|
||||
name: "Partition Light"
|
||||
segments:
|
||||
- id: addr1
|
||||
from: 0
|
||||
to: 0
|
||||
- id: addr2
|
||||
from: 1
|
||||
to: 10
|
||||
- id: addr2
|
||||
from: 20
|
||||
to: 25
|
||||
|
||||
remote_transmitter:
|
||||
- pin: 32
|
||||
@@ -799,6 +839,11 @@ switch:
|
||||
inverted: True
|
||||
command_topic: custom_command_topic
|
||||
restore_mode: ALWAYS_OFF
|
||||
- platform: remote_transmitter
|
||||
name: "JVC Off"
|
||||
jvc:
|
||||
data: 0x10EF
|
||||
repeat: 25
|
||||
- platform: remote_transmitter
|
||||
name: "Panasonic TV Off"
|
||||
nec:
|
||||
@@ -867,6 +912,11 @@ switch:
|
||||
group: 'a'
|
||||
device: 2
|
||||
state: True
|
||||
- platform: remote_transmitter
|
||||
name: "Panasonic TV Off"
|
||||
rc5:
|
||||
address: 0x00
|
||||
command: 0x0B
|
||||
- platform: remote_transmitter
|
||||
name: "Panasonic TV Off"
|
||||
id: living_room_lights_off
|
||||
@@ -877,7 +927,9 @@ switch:
|
||||
- -1000
|
||||
- platform: template
|
||||
name: Living Room Lights
|
||||
id: livingroom_lights
|
||||
optimistic: True
|
||||
assumed_state: yes
|
||||
turn_on_action:
|
||||
- switch.turn_on: living_room_lights_on
|
||||
- output.set_level:
|
||||
@@ -889,6 +941,10 @@ switch:
|
||||
turn_off_action:
|
||||
- switch.turn_on: living_room_lights_off
|
||||
restore_state: False
|
||||
on_turn_on:
|
||||
- switch.template.publish:
|
||||
id: livingroom_lights
|
||||
state: yes
|
||||
- platform: restart
|
||||
name: "Living Room Restart"
|
||||
- platform: shutdown
|
||||
@@ -915,7 +971,12 @@ switch:
|
||||
// Switch is OFF, do something else here
|
||||
}
|
||||
optimistic: true
|
||||
assumed_state: no
|
||||
restore_state: True
|
||||
on_turn_off:
|
||||
- switch.template.publish:
|
||||
id: my_switch
|
||||
state: !lambda 'return false;'
|
||||
- platform: uart
|
||||
name: "UART String Output"
|
||||
data: 'DataToSend'
|
||||
@@ -923,7 +984,7 @@ switch:
|
||||
name: "UART Bytes Output"
|
||||
data: [0xDE, 0xAD, 0xBE, 0xEF]
|
||||
- platform: template
|
||||
optimistic: true
|
||||
assumed_state: yes
|
||||
name: Stepper Switch
|
||||
turn_on_action:
|
||||
- stepper.set_target:
|
||||
@@ -948,6 +1009,14 @@ fan:
|
||||
medium: 0.75
|
||||
high: 1.0
|
||||
|
||||
interval:
|
||||
- interval: 10s
|
||||
then:
|
||||
- display.page.show: !lambda |-
|
||||
if (true) return id(page1); else return id(page2);
|
||||
- display.page.show_next: display
|
||||
- display.page.show_previous: display
|
||||
|
||||
display:
|
||||
- platform: lcd_gpio
|
||||
dimensions: 18x4
|
||||
@@ -978,8 +1047,14 @@ display:
|
||||
model: "SSD1306 128x64"
|
||||
reset_pin: GPIO23
|
||||
address: 0x3C
|
||||
lambda: |-
|
||||
it.rectangle(0, 0, it.get_width(), it.get_height());
|
||||
id: display
|
||||
pages:
|
||||
- id: page1
|
||||
lambda: |-
|
||||
it.rectangle(0, 0, it.get_width(), it.get_height());
|
||||
- id: page2
|
||||
lambda: |-
|
||||
// Nothing
|
||||
- platform: ssd1306_spi
|
||||
model: "SSD1306 128x64"
|
||||
cs_pin: GPIO23
|
||||
@@ -1022,7 +1097,7 @@ time:
|
||||
servers:
|
||||
- 0.pool.ntp.org
|
||||
- 1.pool.ntp.org
|
||||
- 2.pool.ntp.org
|
||||
- 192.168.178.1
|
||||
on_time:
|
||||
cron: '/30 0-30,30/5 * ? JAN-DEC MON,SAT-SUN,TUE-FRI'
|
||||
then:
|
||||
@@ -1031,13 +1106,19 @@ time:
|
||||
cover:
|
||||
- platform: template
|
||||
name: "Template Cover"
|
||||
lambda: >-
|
||||
id: template_cover
|
||||
lambda: |-
|
||||
if (id(binary_sensor1).state) {
|
||||
return cover::COVER_OPEN;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
optimistic: true
|
||||
open_action:
|
||||
- cover.template.publish:
|
||||
id: template_cover
|
||||
state: CLOSED
|
||||
assumed_state: no
|
||||
|
||||
debug:
|
||||
|
||||
@@ -1074,3 +1155,20 @@ globals:
|
||||
type: std::string
|
||||
restore_value: no
|
||||
# initial_value: ""
|
||||
|
||||
text_sensor:
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Text"
|
||||
topic: "the/topic"
|
||||
qos: 2
|
||||
on_value:
|
||||
- text_sensor.template.publish:
|
||||
id: template_text
|
||||
state: Hello World
|
||||
- text_sensor.template.publish:
|
||||
id: template_text
|
||||
state: |-
|
||||
return "Hello World2";
|
||||
- platform: template
|
||||
name: Template Text Sensor
|
||||
id: template_text
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
esphomeyaml:
|
||||
esphome:
|
||||
name: $devicename
|
||||
platform: ESP32
|
||||
board: nodemcu-32s
|
||||
# Use this for testing while developing:
|
||||
# esphomelib_version:
|
||||
# local: ~/path/to/esphomelib
|
||||
use_custom_code: true
|
||||
# Note the travis check for esphome PRs will fail until the
|
||||
# esphome-core PR has been merged.
|
||||
# esphome_core_version:
|
||||
# local: ~/path/to/esphome-core
|
||||
build_path: build/test2
|
||||
|
||||
substitutions:
|
||||
@@ -22,14 +23,9 @@ ethernet:
|
||||
static_ip: 192.168.178.56
|
||||
gateway: 192.168.178.1
|
||||
subnet: 255.255.255.0
|
||||
hostname: helloworld
|
||||
domain: .local
|
||||
|
||||
mqtt:
|
||||
broker: '192.168.178.84'
|
||||
port: 1883
|
||||
username: 'debug'
|
||||
password: 'debug'
|
||||
api:
|
||||
|
||||
api:
|
||||
|
||||
@@ -85,17 +81,6 @@ sensor:
|
||||
name: "Xiaomi MiJia Humidity"
|
||||
battery_level:
|
||||
name: "Xiaomi MiJia Battery Level"
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Sensor 1"
|
||||
topic: "mqtt/topic"
|
||||
id: the_sensor
|
||||
qos: 2
|
||||
on_value:
|
||||
- mqtt.publish_json:
|
||||
topic: the/topic
|
||||
payload: |-
|
||||
root["key"] = id(the_sensor).value;
|
||||
root["greeting"] = "Hello World";
|
||||
- platform: pmsx003
|
||||
type: PMSX003
|
||||
pm_1_0:
|
||||
@@ -178,6 +163,9 @@ binary_sensor:
|
||||
- platform: apds9960
|
||||
direction: right
|
||||
name: APDS9960 Right
|
||||
- platform: homeassistant
|
||||
entity_id: binary_sensor.hello_world
|
||||
id: ha_hello_world_binary
|
||||
|
||||
remote_receiver:
|
||||
pin: GPIO32
|
||||
@@ -195,17 +183,22 @@ status_led:
|
||||
|
||||
text_sensor:
|
||||
- platform: version
|
||||
name: "Esphomelib Version"
|
||||
name: "ESPHome Version"
|
||||
icon: mdi:icon
|
||||
id: version_sensor
|
||||
on_value:
|
||||
- lambda: !lambda |-
|
||||
ESP_LOGD("main", "The state is %s=%s", x.c_str(), id(version_sensor).state.c_str());
|
||||
- script.execute: my_script
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Text"
|
||||
topic: "the/topic"
|
||||
qos: 2
|
||||
- homeassistant.service:
|
||||
service: notify.html5
|
||||
data:
|
||||
title: New Humidity
|
||||
data_template:
|
||||
message: The humidity is {{ my_variable }}%.
|
||||
variables:
|
||||
my_variable: |-
|
||||
return id(version_sensor).state;
|
||||
- platform: template
|
||||
name: "Template Text Sensor"
|
||||
lambda: |-
|
||||
|
||||
179
tests/test3.yaml
Normal file
179
tests/test3.yaml
Normal file
@@ -0,0 +1,179 @@
|
||||
esphome:
|
||||
name: $devicename
|
||||
platform: ESP8266
|
||||
board: esp07
|
||||
# Use this for testing while developing:
|
||||
# Note the travis check for esphome PRs will fail until the
|
||||
# esphome-core PR has been merged.
|
||||
# esphome_core_version:
|
||||
# local: ~/path/to/esphome-core
|
||||
build_path: build/test3
|
||||
|
||||
substitutions:
|
||||
devicename: test3
|
||||
|
||||
api:
|
||||
|
||||
i2c:
|
||||
sda: 4
|
||||
scl: 5
|
||||
scan: False
|
||||
|
||||
spi:
|
||||
clk_pin: GPIO12
|
||||
mosi_pin: GPIO13
|
||||
miso_pin: GPIO14
|
||||
|
||||
uart:
|
||||
tx_pin: GPIO1
|
||||
rx_pin: GPIO3
|
||||
baud_rate: 115200
|
||||
|
||||
ota:
|
||||
safe_mode: True
|
||||
port: 3286
|
||||
|
||||
logger:
|
||||
hardware_uart: UART1
|
||||
level: DEBUG
|
||||
|
||||
web_server:
|
||||
|
||||
deep_sleep:
|
||||
run_duration: 20s
|
||||
sleep_duration: 50s
|
||||
|
||||
sensor:
|
||||
- platform: pmsx003
|
||||
type: PMSX003
|
||||
pm_1_0:
|
||||
name: "PM 1.0 Concentration"
|
||||
pm_2_5:
|
||||
name: "PM 2.5 Concentration"
|
||||
pm_10_0:
|
||||
name: "PM 10.0 Concentration"
|
||||
- platform: pmsx003
|
||||
type: PMS5003T
|
||||
pm_2_5:
|
||||
name: "PM 2.5 Concentration"
|
||||
temperature:
|
||||
name: "PMS Temperature"
|
||||
humidity:
|
||||
name: "PMS Humidity"
|
||||
- platform: pmsx003
|
||||
type: PMS5003ST
|
||||
pm_2_5:
|
||||
name: "PM 2.5 Concentration"
|
||||
temperature:
|
||||
name: "PMS Temperature"
|
||||
humidity:
|
||||
name: "PMS Humidity"
|
||||
formaldehyde:
|
||||
name: "PMS Formaldehyde Concentration"
|
||||
- platform: cse7766
|
||||
voltage:
|
||||
name: "CSE7766 Voltage"
|
||||
current:
|
||||
name: "CSE7766 Current"
|
||||
power:
|
||||
name: "CSE776 Power"
|
||||
- platform: apds9960
|
||||
type: proximity
|
||||
name: APDS9960 Proximity
|
||||
- platform: apds9960
|
||||
type: clear
|
||||
name: APDS9960 Clear
|
||||
- platform: apds9960
|
||||
type: red
|
||||
name: APDS9960 Red
|
||||
- platform: apds9960
|
||||
type: green
|
||||
name: APDS9960 Green
|
||||
- platform: apds9960
|
||||
type: blue
|
||||
name: APDS9960 Blue
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.hello_world
|
||||
id: ha_hello_world
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
||||
|
||||
apds9960:
|
||||
address: 0x20
|
||||
update_interval: 60s
|
||||
|
||||
binary_sensor:
|
||||
- platform: apds9960
|
||||
direction: up
|
||||
name: APDS9960 Up
|
||||
- platform: apds9960
|
||||
direction: down
|
||||
name: APDS9960 Down
|
||||
- platform: apds9960
|
||||
direction: left
|
||||
name: APDS9960 Left
|
||||
- platform: apds9960
|
||||
direction: right
|
||||
name: APDS9960 Right
|
||||
- platform: homeassistant
|
||||
entity_id: binary_sensor.hello_world
|
||||
id: ha_hello_world_binary
|
||||
|
||||
remote_receiver:
|
||||
pin: GPIO12
|
||||
dump: []
|
||||
|
||||
status_led:
|
||||
pin: GPIO2
|
||||
|
||||
text_sensor:
|
||||
- platform: version
|
||||
name: "ESPHome Version"
|
||||
icon: mdi:icon
|
||||
id: version_sensor
|
||||
on_value:
|
||||
- lambda: !lambda |-
|
||||
ESP_LOGD("main", "The state is %s=%s", x.c_str(), id(version_sensor).state.c_str());
|
||||
- script.execute: my_script
|
||||
- homeassistant.service:
|
||||
service: notify.html5
|
||||
data:
|
||||
title: New Humidity
|
||||
data_template:
|
||||
message: The humidity is {{ my_variable }}%.
|
||||
variables:
|
||||
my_variable: |-
|
||||
return id(version_sensor).state;
|
||||
- platform: template
|
||||
name: "Template Text Sensor"
|
||||
lambda: |-
|
||||
return {"Hello World"};
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.hello_world2
|
||||
id: ha_hello_world2
|
||||
|
||||
script:
|
||||
- id: my_script
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
|
||||
stepper:
|
||||
- platform: uln2003
|
||||
id: my_stepper
|
||||
pin_a: GPIO12
|
||||
pin_b: GPIO13
|
||||
pin_c: GPIO14
|
||||
pin_d: GPIO15
|
||||
sleep_when_done: no
|
||||
step_mode: HALF_STEP
|
||||
max_speed: 250 steps/s
|
||||
|
||||
# Optional:
|
||||
acceleration: inf
|
||||
deceleration: inf
|
||||
|
||||
interval:
|
||||
interval: 5s
|
||||
then:
|
||||
- logger.log: "Interval Run"
|
||||
Reference in New Issue
Block a user