Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter committed May 8, 2019
1 parent a07a835 commit 968ff4b
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 35 deletions.
2 changes: 1 addition & 1 deletion esphome/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# pylint: disable=unused-import
from esphome.cpp_generator import ( # noqa
Expression, RawExpression, TemplateArguments,
Expression, RawExpression, RawStatement, TemplateArguments,
StructInitializer, ArrayInitializer, safe_exp, Statement,
progmem_array, statement, variable, Pvariable, new_Pvariable,
add, add_global, add_library, add_build_flag, add_define,
Expand Down
18 changes: 0 additions & 18 deletions esphome/components/ble_ibeacon/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion esphome/components/custom/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ def to_code(config):
var = cg.variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_SENSORS]):
sens = cg.Pvariable(conf[CONF_ID], var.get_sensor(i))
cg.add(sens.set_name(conf[CONF_NAME]))
yield sensor.register_sensor(sens, conf)
3 changes: 1 addition & 2 deletions esphome/components/custom/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ def to_code(config):
rhs = CustomSwitchConstructor(template_)
var = cg.variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_SWITCHES]):
switch_ = cg.new_Pvariable(conf[CONF_ID], var.get_switch(i))
cg.add(switch_.set_name(conf[CONF_NAME]))
switch_ = cg.Pvariable(conf[CONF_ID], var.get_switch(i))
yield switch.register_switch(switch_, conf)
3 changes: 1 addition & 2 deletions esphome/components/custom/text_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ def to_code(config):
var = cg.variable(config[CONF_ID], rhs)

for i, conf in enumerate(config[CONF_TEXT_SENSORS]):
text = cg.new_Pvariable(conf[CONF_ID], var.get_text_sensor(i))
cg.add(text.set_name(conf[CONF_NAME]))
text = cg.Pvariable(conf[CONF_ID], var.get_text_sensor(i))
yield text_sensor.register_text_sensor(text, conf)
2 changes: 1 addition & 1 deletion esphome/components/esp32_ble_tracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from esphome.core import coroutine

ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
AUTO_LOAD = ['xiaomi_ble', 'ble_ibeacon']
AUTO_LOAD = ['xiaomi_ble']

CONF_ESP32_BLE_ID = 'esp32_ble_id'
esp32_ble_tracker_ns = cg.esphome_ns.namespace('esp32_ble_tracker')
Expand Down
5 changes: 2 additions & 3 deletions esphome/components/esp32_ble_tracker/esp32_ble_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ESPBTUUID {

class ESPBLEiBeacon {
public:
ESPBLEiBeacon() { memset(&this->beacon_data_, 0, sizeof(this->beacon_data_)); }
ESPBLEiBeacon(const uint8_t *data);
static optional<ESPBLEiBeacon> from_manufacturer_data(const std::string &data);

Expand Down Expand Up @@ -98,9 +99,7 @@ class ESPBTDeviceListener {
public:
virtual void on_scan_end() {}
virtual bool parse_device(const ESPBTDevice &device) = 0;
void set_parent(ESP32BLETracker *parent) {
parent_ = parent;
}
void set_parent(ESP32BLETracker *parent) { parent_ = parent; }

protected:
ESP32BLETracker *parent_{nullptr};
Expand Down
2 changes: 1 addition & 1 deletion esphome/core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def add_includes(includes):
for include in includes:
path = CORE.relative_config_path(include)
res = os.path.relpath(path, CORE.relative_build_path('src')).replace(os.path.sep, '/')
cg.add_global(cg.RawExpression(u'#include "{}"'.format(res)))
cg.add_global(cg.RawStatement(u'#include "{}"'.format(res)))


@coroutine_with_priority(100.0)
Expand Down
2 changes: 1 addition & 1 deletion script/lint-cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ fi

set -x

script/clang-tidy.py -c --fix
script/clang-tidy.py -c --fix --all-headers
script/clang-format.py -c -i
38 changes: 38 additions & 0 deletions tests/custom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

class CustomSensor : public Component, public Sensor {
public:
void loop() override {
publish_state(42.0);
}
};

class CustomTextSensor : public Component, public TextSensor {
public:
void loop() override {
publish_state("Hello World");
}
};

class CustomBinarySensor : public Component, public BinarySensor {
public:
void loop() override {
publish_state(false);
}
};

class CustomSwitch : public Switch {
protected:
void write_state(bool state) override {
ESP_LOGD("custom_switch", "Setting %s", ONOFF(state));
}
};

class CustomComponent : public PollingComponent {
public:
void setup() override {
ESP_LOGD("custom_component", "Setup");
}
void update() override {
ESP_LOGD("custom_component", "Update");
}
};
29 changes: 24 additions & 5 deletions tests/test3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ esphome:
- wait_until:
- api.connected
- wifi.connected
includes:
- custom.h

substitutions:
devicename: test3
Expand Down Expand Up @@ -65,6 +67,7 @@ ota:
logger:
hardware_uart: UART1
level: DEBUG
esp8266_store_log_strings_in_flash: false

web_server:

Expand Down Expand Up @@ -124,7 +127,8 @@ sensor:
gain: 60x
- platform: custom
lambda: |-
auto s = new sensor::Sensor();
auto s = new CustomSensor();
App.register_component(s);
return {s};
sensors:
- id: custom_sensor
Expand Down Expand Up @@ -187,9 +191,10 @@ binary_sensor:
name: TTP229 LSF Test
- platform: custom
lambda: |-
auto s = new binary_sensor::BinarySensor();
auto s = new CustomBinarySensor();
App.register_component(s);
return {s};
sensors:
binary_sensors:
- id: custom_binary_sensor
name: Custom Binary Sensor

Expand Down Expand Up @@ -225,6 +230,14 @@ text_sensor:
- platform: homeassistant
entity_id: sensor.hello_world2
id: ha_hello_world2
- platform: custom
lambda: |-
auto s = new CustomTextSensor();
App.register_component(s);
return {s};
text_sensors:
- id: custom_text_sensor
name: Custom Text Sensor

script:
- id: my_script
Expand All @@ -249,12 +262,18 @@ switch:
interlock: *interlock
- platform: custom
lambda: |-
auto s = new switch::Switch();
auto s = new CustomSwitch();
return {s};
sensors:
switches:
- id: custom_switch
name: Custom Switch

custom_component:
lambda: |-
auto s = new CustomComponent();
s->set_update_interval(15000);
return {s};
stepper:
- platform: uln2003
id: my_stepper
Expand Down

0 comments on commit 968ff4b

Please sign in to comment.