mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 07:08:20 +00:00
commit
3d9733485e
@ -7,7 +7,7 @@ from esphome.const import CONF_AWAY_CONFIG, CONF_COOL_ACTION, \
|
|||||||
CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR
|
CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR
|
||||||
|
|
||||||
bang_bang_ns = cg.esphome_ns.namespace('bang_bang')
|
bang_bang_ns = cg.esphome_ns.namespace('bang_bang')
|
||||||
BangBangClimate = bang_bang_ns.class_('BangBangClimate', climate.Climate)
|
BangBangClimate = bang_bang_ns.class_('BangBangClimate', climate.Climate, cg.Component)
|
||||||
BangBangClimateTargetTempConfig = bang_bang_ns.struct('BangBangClimateTargetTempConfig')
|
BangBangClimateTargetTempConfig = bang_bang_ns.struct('BangBangClimateTargetTempConfig')
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({
|
CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({
|
||||||
|
@ -6,13 +6,13 @@ namespace climate {
|
|||||||
const char *climate_mode_to_string(ClimateMode mode) {
|
const char *climate_mode_to_string(ClimateMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case CLIMATE_MODE_OFF:
|
case CLIMATE_MODE_OFF:
|
||||||
return "off";
|
return "OFF";
|
||||||
case CLIMATE_MODE_AUTO:
|
case CLIMATE_MODE_AUTO:
|
||||||
return "auto";
|
return "AUTO";
|
||||||
case CLIMATE_MODE_COOL:
|
case CLIMATE_MODE_COOL:
|
||||||
return "cool";
|
return "COOL";
|
||||||
case CLIMATE_MODE_HEAT:
|
case CLIMATE_MODE_HEAT:
|
||||||
return "heat";
|
return "HEAT";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ void DeepSleepComponent::setup() {
|
|||||||
void DeepSleepComponent::dump_config() {
|
void DeepSleepComponent::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up Deep Sleep...");
|
ESP_LOGCONFIG(TAG, "Setting up Deep Sleep...");
|
||||||
if (this->sleep_duration_.has_value()) {
|
if (this->sleep_duration_.has_value()) {
|
||||||
ESP_LOGCONFIG(TAG, " Sleep Duration: %llu ms", *this->sleep_duration_ / 1000);
|
uint32_t duration = *this->sleep_duration_ / 1000;
|
||||||
|
ESP_LOGCONFIG(TAG, " Sleep Duration: %u ms", duration);
|
||||||
}
|
}
|
||||||
if (this->run_duration_.has_value()) {
|
if (this->run_duration_.has_value()) {
|
||||||
ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_);
|
ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_);
|
||||||
|
@ -67,7 +67,7 @@ CONFIG_SCHEMA = cv.All(cv.Schema({
|
|||||||
cv.Optional(CONF_USE_ADDRESS): cv.string_strict,
|
cv.Optional(CONF_USE_ADDRESS): cv.string_strict,
|
||||||
|
|
||||||
cv.Optional('hostname'): cv.invalid("The hostname option has been removed in 1.11.0"),
|
cv.Optional('hostname'): cv.invalid("The hostname option has been removed in 1.11.0"),
|
||||||
}), validate)
|
}).extend(cv.COMPONENT_SCHEMA), validate)
|
||||||
|
|
||||||
|
|
||||||
def manual_ip(config):
|
def manual_ip(config):
|
||||||
@ -84,6 +84,7 @@ def manual_ip(config):
|
|||||||
@coroutine_with_priority(60.0)
|
@coroutine_with_priority(60.0)
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
yield cg.register_component(var, config)
|
||||||
|
|
||||||
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
|
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
|
||||||
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
||||||
|
@ -6,7 +6,8 @@ from .. import homeassistant_ns
|
|||||||
|
|
||||||
DEPENDENCIES = ['api']
|
DEPENDENCIES = ['api']
|
||||||
HomeassistantBinarySensor = homeassistant_ns.class_('HomeassistantBinarySensor',
|
HomeassistantBinarySensor = homeassistant_ns.class_('HomeassistantBinarySensor',
|
||||||
binary_sensor.BinarySensor)
|
binary_sensor.BinarySensor,
|
||||||
|
cg.Component)
|
||||||
|
|
||||||
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_id(HomeassistantBinarySensor),
|
cv.GenerateID(): cv.declare_id(HomeassistantBinarySensor),
|
||||||
|
@ -6,7 +6,8 @@ from .. import homeassistant_ns
|
|||||||
|
|
||||||
DEPENDENCIES = ['api']
|
DEPENDENCIES = ['api']
|
||||||
|
|
||||||
HomeassistantSensor = homeassistant_ns.class_('HomeassistantSensor', sensor.Sensor)
|
HomeassistantSensor = homeassistant_ns.class_('HomeassistantSensor', sensor.Sensor,
|
||||||
|
cg.Component)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(HomeassistantSensor),
|
cv.GenerateID(): cv.declare_id(HomeassistantSensor),
|
||||||
|
@ -71,3 +71,5 @@ def to_code(config):
|
|||||||
yield output.register_output(var, config)
|
yield output.register_output(var, config)
|
||||||
if CONF_CHANNEL in config:
|
if CONF_CHANNEL in config:
|
||||||
cg.add(var.set_channel(config[CONF_CHANNEL]))
|
cg.add(var.set_channel(config[CONF_CHANNEL]))
|
||||||
|
cg.add(var.set_frequency(config[CONF_FREQUENCY]))
|
||||||
|
cg.add(var.set_bit_depth(config[CONF_BIT_DEPTH]))
|
||||||
|
@ -24,12 +24,12 @@ void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryC
|
|||||||
JsonArray &modes = root.createNestedArray("modes");
|
JsonArray &modes = root.createNestedArray("modes");
|
||||||
// sort array for nice UI in HA
|
// sort array for nice UI in HA
|
||||||
if (traits.supports_mode(CLIMATE_MODE_AUTO))
|
if (traits.supports_mode(CLIMATE_MODE_AUTO))
|
||||||
modes.add(climate_mode_to_string(CLIMATE_MODE_AUTO));
|
modes.add("auto");
|
||||||
modes.add(climate_mode_to_string(CLIMATE_MODE_OFF));
|
modes.add("off");
|
||||||
if (traits.supports_mode(CLIMATE_MODE_COOL))
|
if (traits.supports_mode(CLIMATE_MODE_COOL))
|
||||||
modes.add(climate_mode_to_string(CLIMATE_MODE_COOL));
|
modes.add("cool");
|
||||||
if (traits.supports_mode(CLIMATE_MODE_HEAT))
|
if (traits.supports_mode(CLIMATE_MODE_HEAT))
|
||||||
modes.add(climate_mode_to_string(CLIMATE_MODE_HEAT));
|
modes.add("heat");
|
||||||
|
|
||||||
if (traits.get_supports_two_point_target_temperature()) {
|
if (traits.get_supports_two_point_target_temperature()) {
|
||||||
// temperature_low_command_topic
|
// temperature_low_command_topic
|
||||||
|
@ -10,7 +10,7 @@ PulseWidthSensor = pulse_width_ns.class_('PulseWidthSensor', sensor.Sensor, cg.P
|
|||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 3).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 3).extend({
|
||||||
cv.GenerateID(): cv.declare_id(PulseWidthSensor),
|
cv.GenerateID(): cv.declare_id(PulseWidthSensor),
|
||||||
cv.Required(CONF_PIN): cv.All(pins.internal_gpio_input_pullup_pin_schema,
|
cv.Required(CONF_PIN): cv.All(pins.internal_gpio_input_pin_schema,
|
||||||
pins.validate_has_interrupt),
|
pins.validate_has_interrupt),
|
||||||
}).extend(cv.polling_component_schema('60s'))
|
}).extend(cv.polling_component_schema('60s'))
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "status_binary_sensor.h"
|
#include "status_binary_sensor.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/core/util.h"
|
#include "esphome/core/util.h"
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
|
|
||||||
#ifdef USE_MQTT
|
#ifdef USE_MQTT
|
||||||
#include "esphome/components/mqtt/mqtt_client.h"
|
#include "esphome/components/mqtt/mqtt_client.h"
|
||||||
@ -18,19 +19,16 @@ void StatusBinarySensor::loop() {
|
|||||||
bool status = network_is_connected();
|
bool status = network_is_connected();
|
||||||
#ifdef USE_MQTT
|
#ifdef USE_MQTT
|
||||||
if (mqtt::global_mqtt_client != nullptr) {
|
if (mqtt::global_mqtt_client != nullptr) {
|
||||||
status = mqtt::global_mqtt_client->is_connected();
|
status = status && mqtt::global_mqtt_client->is_connected();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_API
|
#ifdef USE_API
|
||||||
if (api::global_api_server != nullptr) {
|
if (api::global_api_server != nullptr) {
|
||||||
status = api::global_api_server->is_connected();
|
status = status && api::global_api_server->is_connected();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (this->last_status_ != status) {
|
this->publish_state(status);
|
||||||
this->publish_state(status);
|
|
||||||
this->last_status_ = status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void StatusBinarySensor::setup() { this->publish_state(false); }
|
void StatusBinarySensor::setup() { this->publish_state(false); }
|
||||||
void StatusBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Status Binary Sensor", this); }
|
void StatusBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Status Binary Sensor", this); }
|
||||||
|
@ -16,9 +16,6 @@ class StatusBinarySensor : public binary_sensor::BinarySensor, public Component
|
|||||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||||
|
|
||||||
bool is_status_binary_sensor() const override { return true; }
|
bool is_status_binary_sensor() const override { return true; }
|
||||||
|
|
||||||
protected:
|
|
||||||
bool last_status_{false};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace status
|
} // namespace status
|
||||||
|
@ -83,13 +83,13 @@ def switch_toggle_to_code(config, action_id, template_arg, args):
|
|||||||
@automation.register_condition('switch.is_on', SwitchCondition, SWITCH_ACTION_SCHEMA)
|
@automation.register_condition('switch.is_on', SwitchCondition, SWITCH_ACTION_SCHEMA)
|
||||||
def switch_is_on_to_code(config, condition_id, template_arg, args):
|
def switch_is_on_to_code(config, condition_id, template_arg, args):
|
||||||
paren = yield cg.get_variable(config[CONF_ID])
|
paren = yield cg.get_variable(config[CONF_ID])
|
||||||
yield cg.new_Pvariable(condition_id, template_arg, paren)
|
yield cg.new_Pvariable(condition_id, template_arg, paren, True)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition('switch.is_off', SwitchCondition, SWITCH_ACTION_SCHEMA)
|
@automation.register_condition('switch.is_off', SwitchCondition, SWITCH_ACTION_SCHEMA)
|
||||||
def switch_is_off_to_code(config, condition_id, template_arg, args):
|
def switch_is_off_to_code(config, condition_id, template_arg, args):
|
||||||
paren = yield cg.get_variable(config[CONF_ID])
|
paren = yield cg.get_variable(config[CONF_ID])
|
||||||
yield cg.new_Pvariable(condition_id, template_arg, paren)
|
yield cg.new_Pvariable(condition_id, template_arg, paren, False)
|
||||||
|
|
||||||
|
|
||||||
@coroutine_with_priority(100.0)
|
@coroutine_with_priority(100.0)
|
||||||
|
@ -450,7 +450,9 @@ def validate_config(config):
|
|||||||
result.remove_output_path([domain], domain)
|
result.remove_output_path([domain], domain)
|
||||||
|
|
||||||
# Ensure conf is a list
|
# Ensure conf is a list
|
||||||
if not isinstance(conf, list) and conf:
|
if not conf:
|
||||||
|
result[domain] = conf = []
|
||||||
|
elif not isinstance(conf, list):
|
||||||
result[domain] = conf = [conf]
|
result[domain] = conf = [conf]
|
||||||
|
|
||||||
for i, p_config in enumerate(conf):
|
for i, p_config in enumerate(conf):
|
||||||
|
@ -19,6 +19,7 @@ ARDUINO_VERSION_ESP8266_DEV = 'https://github.com/platformio/platform-espressif8
|
|||||||
'/stage'
|
'/stage'
|
||||||
ARDUINO_VERSION_ESP8266_2_5_0 = 'espressif8266@2.0.0'
|
ARDUINO_VERSION_ESP8266_2_5_0 = 'espressif8266@2.0.0'
|
||||||
ARDUINO_VERSION_ESP8266_2_5_1 = 'espressif8266@2.1.0'
|
ARDUINO_VERSION_ESP8266_2_5_1 = 'espressif8266@2.1.0'
|
||||||
|
ARDUINO_VERSION_ESP8266_2_5_2 = 'espressif8266@2.2.0'
|
||||||
ARDUINO_VERSION_ESP8266_2_3_0 = 'espressif8266@1.5.0'
|
ARDUINO_VERSION_ESP8266_2_3_0 = 'espressif8266@1.5.0'
|
||||||
SOURCE_FILE_EXTENSIONS = {'.cpp', '.hpp', '.h', '.c', '.tcc', '.ino'}
|
SOURCE_FILE_EXTENSIONS = {'.cpp', '.hpp', '.h', '.c', '.tcc', '.ino'}
|
||||||
HEADER_FILE_EXTENSIONS = {'.h', '.hpp', '.tcc'}
|
HEADER_FILE_EXTENSIONS = {'.h', '.hpp', '.tcc'}
|
||||||
|
@ -257,7 +257,7 @@ std::string to_string(long double val) {
|
|||||||
optional<float> parse_float(const std::string &str) {
|
optional<float> parse_float(const std::string &str) {
|
||||||
char *end;
|
char *end;
|
||||||
float value = ::strtof(str.c_str(), &end);
|
float value = ::strtof(str.c_str(), &end);
|
||||||
if (end == nullptr)
|
if (end == nullptr || end != str.end().base())
|
||||||
return {};
|
return {};
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ from esphome.const import ARDUINO_VERSION_ESP32_DEV, ARDUINO_VERSION_ESP8266_DEV
|
|||||||
CONF_NAME, CONF_ON_BOOT, CONF_ON_LOOP, CONF_ON_SHUTDOWN, CONF_PLATFORM, \
|
CONF_NAME, CONF_ON_BOOT, CONF_ON_LOOP, CONF_ON_SHUTDOWN, CONF_PLATFORM, \
|
||||||
CONF_PLATFORMIO_OPTIONS, CONF_PRIORITY, CONF_TRIGGER_ID, \
|
CONF_PLATFORMIO_OPTIONS, CONF_PRIORITY, CONF_TRIGGER_ID, \
|
||||||
CONF_ESP8266_RESTORE_FROM_FLASH, __version__, ARDUINO_VERSION_ESP8266_2_3_0, \
|
CONF_ESP8266_RESTORE_FROM_FLASH, __version__, ARDUINO_VERSION_ESP8266_2_3_0, \
|
||||||
ARDUINO_VERSION_ESP8266_2_5_0, ARDUINO_VERSION_ESP8266_2_5_1
|
ARDUINO_VERSION_ESP8266_2_5_0, ARDUINO_VERSION_ESP8266_2_5_1, ARDUINO_VERSION_ESP8266_2_5_2
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
from esphome.pins import ESP8266_FLASH_SIZES, ESP8266_LD_SCRIPTS
|
from esphome.pins import ESP8266_FLASH_SIZES, ESP8266_LD_SCRIPTS
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ def validate_board(value):
|
|||||||
validate_platform = cv.one_of('ESP32', 'ESP8266', upper=True)
|
validate_platform = cv.one_of('ESP32', 'ESP8266', upper=True)
|
||||||
|
|
||||||
PLATFORMIO_ESP8266_LUT = {
|
PLATFORMIO_ESP8266_LUT = {
|
||||||
|
'2.5.2': 'espressif8266@2.2.0',
|
||||||
'2.5.1': 'espressif8266@2.1.0',
|
'2.5.1': 'espressif8266@2.1.0',
|
||||||
'2.5.0': 'espressif8266@2.0.1',
|
'2.5.0': 'espressif8266@2.0.1',
|
||||||
'2.4.2': 'espressif8266@1.8.0',
|
'2.4.2': 'espressif8266@1.8.0',
|
||||||
@ -193,7 +194,7 @@ def to_code(config):
|
|||||||
'espressif8266@1.6.0'):
|
'espressif8266@1.6.0'):
|
||||||
ld_script = ld_scripts[0]
|
ld_script = ld_scripts[0]
|
||||||
elif CORE.arduino_version in (ARDUINO_VERSION_ESP8266_DEV, ARDUINO_VERSION_ESP8266_2_5_0,
|
elif CORE.arduino_version in (ARDUINO_VERSION_ESP8266_DEV, ARDUINO_VERSION_ESP8266_2_5_0,
|
||||||
ARDUINO_VERSION_ESP8266_2_5_1):
|
ARDUINO_VERSION_ESP8266_2_5_1, ARDUINO_VERSION_ESP8266_2_5_2):
|
||||||
ld_script = ld_scripts[1]
|
ld_script = ld_scripts[1]
|
||||||
|
|
||||||
if ld_script is not None:
|
if ld_script is not None:
|
||||||
|
@ -13,7 +13,7 @@ import threading
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
from helpers import basepath, get_output, walk_files, filter_changed
|
from helpers import basepath, get_output, git_ls_files, filter_changed
|
||||||
|
|
||||||
is_py2 = sys.version[0] == '2'
|
is_py2 = sys.version[0] == '2'
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ def main():
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for path in walk_files(basepath):
|
for path in git_ls_files():
|
||||||
filetypes = ('.cpp', '.h', '.tcc')
|
filetypes = ('.cpp', '.h', '.tcc')
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext in filetypes:
|
if ext in filetypes:
|
||||||
|
@ -18,7 +18,7 @@ import threading
|
|||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
from helpers import basepath, shlex_quote, get_output, build_compile_commands, \
|
from helpers import basepath, shlex_quote, get_output, build_compile_commands, \
|
||||||
build_all_include, temp_header_file, walk_files, filter_changed
|
build_all_include, temp_header_file, git_ls_files, filter_changed
|
||||||
|
|
||||||
is_py2 = sys.version[0] == '2'
|
is_py2 = sys.version[0] == '2'
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ def main():
|
|||||||
build_compile_commands()
|
build_compile_commands()
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for path in walk_files(basepath):
|
for path in git_ls_files():
|
||||||
filetypes = ('.cpp',)
|
filetypes = ('.cpp',)
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext in filetypes:
|
if ext in filetypes:
|
||||||
|
@ -126,3 +126,13 @@ def filter_changed(files):
|
|||||||
for c in files:
|
for c in files:
|
||||||
print(" {}".format(c))
|
print(" {}".format(c))
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
def git_ls_files():
|
||||||
|
command = ['git', 'ls-files', '-s']
|
||||||
|
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
|
||||||
|
output, err = proc.communicate()
|
||||||
|
lines = [x.split() for x in output.decode('utf-8').splitlines()]
|
||||||
|
return {
|
||||||
|
s[3].strip(): int(s[0]) for s in lines
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
from helpers import basepath, get_output, walk_files, filter_changed
|
from helpers import get_output, git_ls_files, filter_changed
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -21,10 +21,10 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for path in walk_files(basepath):
|
for path in git_ls_files():
|
||||||
filetypes = ('.py',)
|
filetypes = ('.py',)
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext in filetypes:
|
if ext in filetypes and path.startswith('esphome'):
|
||||||
path = os.path.relpath(path, os.getcwd())
|
path = os.path.relpath(path, os.getcwd())
|
||||||
files.append(path)
|
files.append(path)
|
||||||
# Match against re
|
# Match against re
|
||||||
@ -35,6 +35,8 @@ def main():
|
|||||||
files = filter_changed(files)
|
files = filter_changed(files)
|
||||||
|
|
||||||
files.sort()
|
files.sort()
|
||||||
|
if not files:
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
errors = collections.defaultdict(list)
|
errors = collections.defaultdict(list)
|
||||||
cmd = ['flake8'] + files
|
cmd = ['flake8'] + files
|
||||||
|
@ -3,38 +3,26 @@
|
|||||||
|
|
||||||
class CustomSensor : public Component, public Sensor {
|
class CustomSensor : public Component, public Sensor {
|
||||||
public:
|
public:
|
||||||
void loop() override {
|
void loop() override { publish_state(42.0); }
|
||||||
publish_state(42.0);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomTextSensor : public Component, public TextSensor {
|
class CustomTextSensor : public Component, public TextSensor {
|
||||||
public:
|
public:
|
||||||
void loop() override {
|
void loop() override { publish_state("Hello World"); }
|
||||||
publish_state("Hello World");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomBinarySensor : public Component, public BinarySensor {
|
class CustomBinarySensor : public Component, public BinarySensor {
|
||||||
public:
|
public:
|
||||||
void loop() override {
|
void loop() override { publish_state(false); }
|
||||||
publish_state(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomSwitch : public Switch {
|
class CustomSwitch : public Switch {
|
||||||
protected:
|
protected:
|
||||||
void write_state(bool state) override {
|
void write_state(bool state) override { ESP_LOGD("custom_switch", "Setting %s", ONOFF(state)); }
|
||||||
ESP_LOGD("custom_switch", "Setting %s", ONOFF(state));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomComponent : public PollingComponent {
|
class CustomComponent : public PollingComponent {
|
||||||
public:
|
public:
|
||||||
void setup() override {
|
void setup() override { ESP_LOGD("custom_component", "Setup"); }
|
||||||
ESP_LOGD("custom_component", "Setup");
|
void update() override { ESP_LOGD("custom_component", "Update"); }
|
||||||
}
|
|
||||||
void update() override {
|
|
||||||
ESP_LOGD("custom_component", "Update");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@ void setup() {
|
|||||||
App.init_ota()->start_safe_mode();
|
App.init_ota()->start_safe_mode();
|
||||||
|
|
||||||
// LEDC is only available on ESP32! for the ESP8266, take a look at App.make_esp8266_pwm_output().
|
// LEDC is only available on ESP32! for the ESP8266, take a look at App.make_esp8266_pwm_output().
|
||||||
auto *red = App.make_ledc_output(32); // on pin 32
|
auto *red = App.make_ledc_output(32); // on pin 32
|
||||||
auto *green = App.make_ledc_output(33);
|
auto *green = App.make_ledc_output(33);
|
||||||
auto *blue = App.make_ledc_output(34);
|
auto *blue = App.make_ledc_output(34);
|
||||||
App.make_rgb_light("Livingroom Light", red, green, blue);
|
App.make_rgb_light("Livingroom Light", red, green, blue);
|
||||||
@ -23,6 +23,4 @@ void setup() {
|
|||||||
App.setup();
|
App.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() { App.loop(); }
|
||||||
App.loop();
|
|
||||||
}
|
|
||||||
|
@ -29,6 +29,4 @@ void setup() {
|
|||||||
App.setup();
|
App.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() { App.loop(); }
|
||||||
App.loop();
|
|
||||||
}
|
|
||||||
|
@ -238,3 +238,6 @@ interval:
|
|||||||
interval: 5s
|
interval: 5s
|
||||||
then:
|
then:
|
||||||
- logger.log: "Interval Run"
|
- logger.log: "Interval Run"
|
||||||
|
|
||||||
|
display:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user