esphome 2024.11.3__py3-none-any.whl → 2024.12.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/components/adc/adc_sensor.h +7 -8
- esphome/components/adc/adc_sensor_common.cpp +24 -0
- esphome/components/adc/{adc_sensor.cpp → adc_sensor_esp32.cpp} +10 -179
- esphome/components/adc/adc_sensor_esp8266.cpp +58 -0
- esphome/components/adc/adc_sensor_rp2040.cpp +93 -0
- esphome/components/alarm_control_panel/alarm_control_panel_call.cpp +3 -4
- esphome/components/animation/__init__.py +1 -2
- esphome/components/apds9306/apds9306.cpp +2 -1
- esphome/components/audio/audio.h +1 -1
- esphome/components/bk72xx/__init__.py +1 -1
- esphome/components/cse7766/cse7766.cpp +1 -1
- esphome/components/deep_sleep/deep_sleep_esp32.cpp +2 -2
- esphome/components/dht/dht.cpp +2 -1
- esphome/components/display/display.cpp +10 -6
- esphome/components/display/display.h +14 -0
- esphome/components/display_menu_base/__init__.py +0 -2
- esphome/components/display_menu_base/display_menu_base.cpp +1 -1
- esphome/components/dsmr/dsmr.cpp +1 -1
- esphome/components/esp32/__init__.py +94 -12
- esphome/components/esp32/boards.py +222 -14
- esphome/components/esp32_ble/__init__.py +22 -2
- esphome/components/esp32_ble/ble.cpp +13 -5
- esphome/components/esp32_ble/ble.h +2 -0
- esphome/components/esp32_ble/ble_advertising.cpp +1 -1
- esphome/components/esp32_ble/ble_uuid.cpp +9 -10
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +4 -1
- esphome/components/esp32_camera_web_server/camera_web_server.h +1 -1
- esphome/components/esp32_rmt_led_strip/light.py +3 -3
- esphome/components/esp8266/__init__.py +5 -7
- esphome/components/ezo/ezo.cpp +14 -26
- esphome/components/font/__init__.py +5 -23
- esphome/components/font/font.cpp +5 -3
- esphome/components/graphical_display_menu/__init__.py +2 -0
- esphome/components/haier/hon_climate.cpp +79 -80
- esphome/components/hbridge/switch/__init__.py +44 -0
- esphome/components/hbridge/switch/hbridge_switch.cpp +95 -0
- esphome/components/hbridge/switch/hbridge_switch.h +50 -0
- esphome/components/hitachi_ac344/hitachi_ac344.cpp +4 -2
- esphome/components/hitachi_ac424/hitachi_ac424.cpp +4 -2
- esphome/components/homeassistant/number/homeassistant_number.cpp +3 -0
- esphome/components/hx711/hx711.cpp +1 -1
- esphome/components/hx711/hx711.h +1 -1
- esphome/components/i2c/i2c_bus_esp_idf.cpp +2 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +61 -59
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -17
- esphome/components/ili9xxx/display.py +1 -2
- esphome/components/ili9xxx/ili9xxx_display.cpp +3 -2
- esphome/components/image/__init__.py +1 -2
- esphome/components/logger/logger.cpp +1 -1
- esphome/components/ltr501/ltr501.cpp +1 -1
- esphome/components/lvgl/defines.py +8 -1
- esphome/components/lvgl/lv_validation.py +8 -3
- esphome/components/lvgl/lvgl_esphome.cpp +1 -1
- esphome/components/lvgl/lvgl_esphome.h +16 -0
- esphome/components/lvgl/widgets/animimg.py +12 -17
- esphome/components/lvgl/widgets/img.py +1 -3
- esphome/components/matrix_keypad/__init__.py +15 -3
- esphome/components/matrix_keypad/matrix_keypad.cpp +4 -0
- esphome/components/matrix_keypad/matrix_keypad.h +5 -0
- esphome/components/max31865/max31865.cpp +4 -2
- esphome/components/modbus_controller/modbus_controller.cpp +24 -24
- esphome/components/modbus_controller/modbus_controller.h +22 -22
- esphome/components/modbus_controller/number/modbus_number.cpp +8 -8
- esphome/components/modbus_controller/number/modbus_number.h +4 -4
- esphome/components/modbus_controller/output/modbus_output.cpp +7 -6
- esphome/components/modbus_controller/output/modbus_output.h +5 -5
- esphome/components/modbus_controller/select/modbus_select.cpp +4 -3
- esphome/components/modbus_controller/select/modbus_select.h +4 -4
- esphome/components/modbus_controller/switch/modbus_switch.cpp +5 -5
- esphome/components/modbus_controller/switch/modbus_switch.h +2 -2
- esphome/components/mqtt/__init__.py +4 -0
- esphome/components/mqtt/mqtt_alarm_control_panel.cpp +2 -5
- esphome/components/mqtt/mqtt_backend_esp32.cpp +3 -3
- esphome/components/mqtt/mqtt_client.cpp +4 -0
- esphome/components/mqtt/mqtt_client.h +6 -0
- esphome/components/mqtt/mqtt_climate.cpp +13 -3
- esphome/components/mqtt/mqtt_sensor.cpp +2 -0
- esphome/components/network/ip_address.h +1 -1
- esphome/components/nextion/__init__.py +2 -0
- esphome/components/nextion/automation.h +76 -0
- esphome/components/nextion/base_component.py +1 -0
- esphome/components/nextion/binary_sensor/__init__.py +43 -2
- esphome/components/nextion/display.py +15 -0
- esphome/components/nextion/nextion.cpp +8 -5
- esphome/components/nextion/nextion.h +7 -0
- esphome/components/nextion/nextion_upload_idf.cpp +2 -2
- esphome/components/nextion/sensor/__init__.py +38 -5
- esphome/components/nextion/switch/__init__.py +38 -2
- esphome/components/nextion/text_sensor/__init__.py +37 -2
- esphome/components/nfc/ndef_record.cpp +3 -3
- esphome/components/online_image/__init__.py +1 -0
- esphome/components/opentherm/opentherm.cpp +3 -3
- esphome/components/opentherm/opentherm.h +1 -1
- esphome/components/ota/automation.h +1 -1
- esphome/components/output/float_output.cpp +1 -1
- esphome/components/pca6416a/pca6416a.cpp +5 -3
- esphome/components/pca9554/pca9554.cpp +4 -4
- esphome/components/pipsolar/pipsolar.cpp +2 -2
- esphome/components/pipsolar/switch/pipsolar_switch.cpp +2 -2
- esphome/components/pn532/pn532_mifare_ultralight.cpp +2 -2
- esphome/components/pn7150/pn7150_mifare_ultralight.cpp +2 -2
- esphome/components/pn7160/pn7160_mifare_ultralight.cpp +2 -2
- esphome/components/qmc5883l/qmc5883l.cpp +45 -19
- esphome/components/qmc5883l/qmc5883l.h +1 -1
- esphome/components/qspi_dbi/qspi_dbi.cpp +2 -1
- esphome/components/remote_base/raw_protocol.cpp +1 -1
- esphome/components/rotary_encoder/rotary_encoder.cpp +3 -1
- esphome/components/rp2040/__init__.py +1 -1
- esphome/components/rtl87xx/__init__.py +1 -1
- esphome/components/safe_mode/automation.h +1 -1
- esphome/components/seeed_mr60bha2/__init__.py +41 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +173 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +61 -0
- esphome/components/seeed_mr60bha2/sensor.py +57 -0
- esphome/components/seeed_mr60fda2/__init__.py +41 -0
- esphome/components/seeed_mr60fda2/binary_sensor.py +33 -0
- esphome/components/seeed_mr60fda2/button/__init__.py +45 -0
- esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.cpp +9 -0
- esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.h +18 -0
- esphome/components/seeed_mr60fda2/button/reset_radar_button.cpp +9 -0
- esphome/components/seeed_mr60fda2/button/reset_radar_button.h +18 -0
- esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +368 -0
- esphome/components/seeed_mr60fda2/seeed_mr60fda2.h +101 -0
- esphome/components/seeed_mr60fda2/select/__init__.py +59 -0
- esphome/components/seeed_mr60fda2/select/height_threshold_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/height_threshold_select.h +18 -0
- esphome/components/seeed_mr60fda2/select/install_height_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/install_height_select.h +18 -0
- esphome/components/seeed_mr60fda2/select/sensitivity_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/sensitivity_select.h +18 -0
- esphome/components/sen5x/sensor.py +5 -6
- esphome/components/shelly_dimmer/shelly_dimmer.cpp +1 -1
- esphome/components/sim800l/sim800l.cpp +1 -1
- esphome/components/sntp/sntp_component.cpp +14 -20
- esphome/components/sntp/sntp_component.h +6 -9
- esphome/components/sntp/time.py +4 -7
- esphome/components/sprinkler/sprinkler.cpp +2 -2
- esphome/components/st7735/st7735.cpp +1 -1
- esphome/components/st7789v/st7789v.cpp +1 -1
- esphome/components/stepper/stepper.h +0 -1
- esphome/components/sun_gtil2/sun_gtil2.cpp +1 -1
- esphome/components/switch/binary_sensor/__init__.py +31 -0
- esphome/components/switch/binary_sensor/switch_binary_sensor.cpp +17 -0
- esphome/components/switch/binary_sensor/switch_binary_sensor.h +22 -0
- esphome/components/sx1509/sx1509_gpio_pin.cpp +2 -1
- esphome/components/sx1509/sx1509_gpio_pin.h +5 -5
- esphome/components/uart/uart.h +1 -1
- esphome/components/udp/udp_component.cpp +32 -16
- esphome/components/ufire_ec/sensor.py +4 -4
- esphome/components/uln2003/uln2003.cpp +4 -1
- esphome/components/waveshare_epaper/display.py +8 -0
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +191 -0
- esphome/components/waveshare_epaper/waveshare_epaper.h +56 -0
- esphome/components/wiegand/__init__.py +3 -4
- esphome/components/wifi/__init__.py +42 -0
- esphome/components/wifi/wifi_component.cpp +2 -2
- esphome/components/wifi/wifi_component.h +82 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +1 -1
- esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
- esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
- esphome/components/wifi/wifi_component_libretiny.cpp +1 -1
- esphome/components/wifi/wifi_component_pico_w.cpp +1 -1
- esphome/components/wireguard/wireguard.cpp +2 -2
- esphome/components/xiaomi_ble/xiaomi_ble.cpp +1 -1
- esphome/config_validation.py +15 -11
- esphome/const.py +7 -1
- esphome/core/component.cpp +1 -1
- esphome/core/config.py +1 -2
- esphome/core/defines.h +3 -1
- esphome/core/helpers.cpp +6 -1
- esphome/core/helpers.h +2 -1
- esphome/core/optional.h +2 -2
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/METADATA +3 -3
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/RECORD +178 -149
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0b1.dist-info}/top_level.txt +0 -0
@@ -5,6 +5,13 @@
|
|
5
5
|
namespace esphome {
|
6
6
|
namespace nextion {
|
7
7
|
|
8
|
+
class BufferOverflowTrigger : public Trigger<> {
|
9
|
+
public:
|
10
|
+
explicit BufferOverflowTrigger(Nextion *nextion) {
|
11
|
+
nextion->add_buffer_overflow_event_callback([this]() { this->trigger(); });
|
12
|
+
}
|
13
|
+
};
|
14
|
+
|
8
15
|
class SetupTrigger : public Trigger<> {
|
9
16
|
public:
|
10
17
|
explicit SetupTrigger(Nextion *nextion) {
|
@@ -42,5 +49,74 @@ class TouchTrigger : public Trigger<uint8_t, uint8_t, bool> {
|
|
42
49
|
}
|
43
50
|
};
|
44
51
|
|
52
|
+
template<typename... Ts> class NextionPublishFloatAction : public Action<Ts...> {
|
53
|
+
public:
|
54
|
+
explicit NextionPublishFloatAction(NextionComponent *component) : component_(component) {}
|
55
|
+
|
56
|
+
TEMPLATABLE_VALUE(float, state)
|
57
|
+
TEMPLATABLE_VALUE(bool, publish_state)
|
58
|
+
TEMPLATABLE_VALUE(bool, send_to_nextion)
|
59
|
+
|
60
|
+
void play(Ts... x) override {
|
61
|
+
this->component_->set_state(this->state_.value(x...), this->publish_state_.value(x...),
|
62
|
+
this->send_to_nextion_.value(x...));
|
63
|
+
}
|
64
|
+
|
65
|
+
void set_state(std::function<void(Ts..., float)> state) { this->state_ = state; }
|
66
|
+
void set_publish_state(std::function<void(Ts..., bool)> publish_state) { this->publish_state_ = publish_state; }
|
67
|
+
void set_send_to_nextion(std::function<void(Ts..., bool)> send_to_nextion) {
|
68
|
+
this->send_to_nextion_ = send_to_nextion;
|
69
|
+
}
|
70
|
+
|
71
|
+
protected:
|
72
|
+
NextionComponent *component_;
|
73
|
+
};
|
74
|
+
|
75
|
+
template<typename... Ts> class NextionPublishTextAction : public Action<Ts...> {
|
76
|
+
public:
|
77
|
+
explicit NextionPublishTextAction(NextionComponent *component) : component_(component) {}
|
78
|
+
|
79
|
+
TEMPLATABLE_VALUE(const char *, state)
|
80
|
+
TEMPLATABLE_VALUE(bool, publish_state)
|
81
|
+
TEMPLATABLE_VALUE(bool, send_to_nextion)
|
82
|
+
|
83
|
+
void play(Ts... x) override {
|
84
|
+
this->component_->set_state(this->state_.value(x...), this->publish_state_.value(x...),
|
85
|
+
this->send_to_nextion_.value(x...));
|
86
|
+
}
|
87
|
+
|
88
|
+
void set_state(std::function<void(Ts..., const char *)> state) { this->state_ = state; }
|
89
|
+
void set_publish_state(std::function<void(Ts..., bool)> publish_state) { this->publish_state_ = publish_state; }
|
90
|
+
void set_send_to_nextion(std::function<void(Ts..., bool)> send_to_nextion) {
|
91
|
+
this->send_to_nextion_ = send_to_nextion;
|
92
|
+
}
|
93
|
+
|
94
|
+
protected:
|
95
|
+
NextionComponent *component_;
|
96
|
+
};
|
97
|
+
|
98
|
+
template<typename... Ts> class NextionPublishBoolAction : public Action<Ts...> {
|
99
|
+
public:
|
100
|
+
explicit NextionPublishBoolAction(NextionComponent *component) : component_(component) {}
|
101
|
+
|
102
|
+
TEMPLATABLE_VALUE(bool, state)
|
103
|
+
TEMPLATABLE_VALUE(bool, publish_state)
|
104
|
+
TEMPLATABLE_VALUE(bool, send_to_nextion)
|
105
|
+
|
106
|
+
void play(Ts... x) override {
|
107
|
+
this->component_->set_state(this->state_.value(x...), this->publish_state_.value(x...),
|
108
|
+
this->send_to_nextion_.value(x...));
|
109
|
+
}
|
110
|
+
|
111
|
+
void set_state(std::function<void(Ts..., bool)> state) { this->state_ = state; }
|
112
|
+
void set_publish_state(std::function<void(Ts..., bool)> publish_state) { this->publish_state_ = publish_state; }
|
113
|
+
void set_send_to_nextion(std::function<void(Ts..., bool)> send_to_nextion) {
|
114
|
+
this->send_to_nextion_ = send_to_nextion;
|
115
|
+
}
|
116
|
+
|
117
|
+
protected:
|
118
|
+
NextionComponent *component_;
|
119
|
+
};
|
120
|
+
|
45
121
|
} // namespace nextion
|
46
122
|
} // namespace esphome
|
@@ -18,6 +18,7 @@ CONF_ON_SLEEP = "on_sleep"
|
|
18
18
|
CONF_ON_WAKE = "on_wake"
|
19
19
|
CONF_ON_SETUP = "on_setup"
|
20
20
|
CONF_ON_PAGE = "on_page"
|
21
|
+
CONF_ON_BUFFER_OVERFLOW = "on_buffer_overflow"
|
21
22
|
CONF_TOUCH_SLEEP_TIMEOUT = "touch_sleep_timeout"
|
22
23
|
CONF_WAKE_UP_PAGE = "wake_up_page"
|
23
24
|
CONF_START_UP_PAGE = "start_up_page"
|
@@ -1,9 +1,16 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
2
3
|
import esphome.config_validation as cv
|
3
4
|
from esphome.components import binary_sensor
|
4
5
|
|
5
|
-
from esphome.const import
|
6
|
-
|
6
|
+
from esphome.const import (
|
7
|
+
CONF_ID,
|
8
|
+
CONF_STATE,
|
9
|
+
CONF_COMPONENT_ID,
|
10
|
+
CONF_PAGE_ID,
|
11
|
+
)
|
12
|
+
|
13
|
+
from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION
|
7
14
|
|
8
15
|
|
9
16
|
from ..base_component import (
|
@@ -19,6 +26,10 @@ NextionBinarySensor = nextion_ns.class_(
|
|
19
26
|
"NextionBinarySensor", binary_sensor.BinarySensor, cg.PollingComponent
|
20
27
|
)
|
21
28
|
|
29
|
+
NextionPublishBoolAction = nextion_ns.class_(
|
30
|
+
"NextionPublishBoolAction", automation.Action
|
31
|
+
)
|
32
|
+
|
22
33
|
CONFIG_SCHEMA = cv.All(
|
23
34
|
binary_sensor.binary_sensor_schema(NextionBinarySensor)
|
24
35
|
.extend(
|
@@ -52,3 +63,33 @@ async def to_code(config):
|
|
52
63
|
if CONF_COMPONENT_NAME in config or CONF_VARIABLE_NAME in config:
|
53
64
|
await setup_component_core_(var, config, ".val")
|
54
65
|
cg.add(hub.register_binarysensor_component(var))
|
66
|
+
|
67
|
+
|
68
|
+
@automation.register_action(
|
69
|
+
"binary_sensor.nextion.publish",
|
70
|
+
NextionPublishBoolAction,
|
71
|
+
cv.Schema(
|
72
|
+
{
|
73
|
+
cv.Required(CONF_ID): cv.use_id(NextionBinarySensor),
|
74
|
+
cv.Required(CONF_STATE): cv.templatable(cv.boolean),
|
75
|
+
cv.Optional(CONF_PUBLISH_STATE, default="true"): cv.templatable(cv.boolean),
|
76
|
+
cv.Optional(CONF_SEND_TO_NEXTION, default="true"): cv.templatable(
|
77
|
+
cv.boolean
|
78
|
+
),
|
79
|
+
}
|
80
|
+
),
|
81
|
+
)
|
82
|
+
async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
83
|
+
paren = await cg.get_variable(config[CONF_ID])
|
84
|
+
var = cg.new_Pvariable(action_id, template_arg, paren)
|
85
|
+
|
86
|
+
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
87
|
+
cg.add(var.set_state(template_))
|
88
|
+
|
89
|
+
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
90
|
+
cg.add(var.set_publish_state(template_))
|
91
|
+
|
92
|
+
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
93
|
+
cg.add(var.set_send_to_nextion(template_))
|
94
|
+
|
95
|
+
return var
|
@@ -13,6 +13,7 @@ from esphome.const import (
|
|
13
13
|
from esphome.core import CORE
|
14
14
|
from . import Nextion, nextion_ns, nextion_ref
|
15
15
|
from .base_component import (
|
16
|
+
CONF_ON_BUFFER_OVERFLOW,
|
16
17
|
CONF_ON_SLEEP,
|
17
18
|
CONF_ON_WAKE,
|
18
19
|
CONF_ON_SETUP,
|
@@ -36,6 +37,9 @@ SleepTrigger = nextion_ns.class_("SleepTrigger", automation.Trigger.template())
|
|
36
37
|
WakeTrigger = nextion_ns.class_("WakeTrigger", automation.Trigger.template())
|
37
38
|
PageTrigger = nextion_ns.class_("PageTrigger", automation.Trigger.template())
|
38
39
|
TouchTrigger = nextion_ns.class_("TouchTrigger", automation.Trigger.template())
|
40
|
+
BufferOverflowTrigger = nextion_ns.class_(
|
41
|
+
"BufferOverflowTrigger", automation.Trigger.template()
|
42
|
+
)
|
39
43
|
|
40
44
|
CONFIG_SCHEMA = (
|
41
45
|
display.BASIC_DISPLAY_SCHEMA.extend(
|
@@ -68,6 +72,13 @@ CONFIG_SCHEMA = (
|
|
68
72
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(TouchTrigger),
|
69
73
|
}
|
70
74
|
),
|
75
|
+
cv.Optional(CONF_ON_BUFFER_OVERFLOW): automation.validate_automation(
|
76
|
+
{
|
77
|
+
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
78
|
+
BufferOverflowTrigger
|
79
|
+
),
|
80
|
+
}
|
81
|
+
),
|
71
82
|
cv.Optional(CONF_TOUCH_SLEEP_TIMEOUT): cv.int_range(min=3, max=65535),
|
72
83
|
cv.Optional(CONF_WAKE_UP_PAGE): cv.uint8_t,
|
73
84
|
cv.Optional(CONF_START_UP_PAGE): cv.uint8_t,
|
@@ -151,3 +162,7 @@ async def to_code(config):
|
|
151
162
|
],
|
152
163
|
conf,
|
153
164
|
)
|
165
|
+
|
166
|
+
for conf in config.get(CONF_ON_BUFFER_OVERFLOW, []):
|
167
|
+
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
168
|
+
await automation.build_automation(trigger, [], conf)
|
@@ -190,6 +190,10 @@ void Nextion::add_touch_event_callback(std::function<void(uint8_t, uint8_t, bool
|
|
190
190
|
this->touch_callback_.add(std::move(callback));
|
191
191
|
}
|
192
192
|
|
193
|
+
void Nextion::add_buffer_overflow_event_callback(std::function<void()> &&callback) {
|
194
|
+
this->buffer_overflow_callback_.add(std::move(callback));
|
195
|
+
}
|
196
|
+
|
193
197
|
void Nextion::update_all_components() {
|
194
198
|
if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping())
|
195
199
|
return;
|
@@ -339,7 +343,7 @@ void Nextion::process_serial_() {
|
|
339
343
|
}
|
340
344
|
// nextion.tech/instruction-set/
|
341
345
|
void Nextion::process_nextion_commands_() {
|
342
|
-
if (this->command_data_.
|
346
|
+
if (this->command_data_.empty()) {
|
343
347
|
return;
|
344
348
|
}
|
345
349
|
|
@@ -458,7 +462,9 @@ void Nextion::process_nextion_commands_() {
|
|
458
462
|
this->remove_from_q_();
|
459
463
|
break;
|
460
464
|
case 0x24: // Serial Buffer overflow occurs
|
461
|
-
|
465
|
+
// Buffer will continue to receive the current instruction, all previous instructions are lost.
|
466
|
+
ESP_LOGE(TAG, "Nextion reported Serial Buffer overflow!");
|
467
|
+
this->buffer_overflow_callback_.call();
|
462
468
|
break;
|
463
469
|
case 0x65: { // touch event return data
|
464
470
|
if (to_process_length != 3) {
|
@@ -557,13 +563,10 @@ void Nextion::process_nextion_commands_() {
|
|
557
563
|
break;
|
558
564
|
}
|
559
565
|
|
560
|
-
int dataindex = 0;
|
561
|
-
|
562
566
|
int value = 0;
|
563
567
|
|
564
568
|
for (int i = 0; i < 4; ++i) {
|
565
569
|
value += to_process[i] << (8 * i);
|
566
|
-
++dataindex;
|
567
570
|
}
|
568
571
|
|
569
572
|
NextionQueue *nb = this->nextion_queue_.front();
|
@@ -1134,6 +1134,12 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1134
1134
|
*/
|
1135
1135
|
void add_touch_event_callback(std::function<void(uint8_t, uint8_t, bool)> &&callback);
|
1136
1136
|
|
1137
|
+
/** Add a callback to be notified when the nextion reports a buffer overflow.
|
1138
|
+
*
|
1139
|
+
* @param callback The void() callback.
|
1140
|
+
*/
|
1141
|
+
void add_buffer_overflow_event_callback(std::function<void()> &&callback);
|
1142
|
+
|
1137
1143
|
void update_all_components();
|
1138
1144
|
|
1139
1145
|
/**
|
@@ -1323,6 +1329,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1323
1329
|
CallbackManager<void()> wake_callback_{};
|
1324
1330
|
CallbackManager<void(uint8_t)> page_callback_{};
|
1325
1331
|
CallbackManager<void(uint8_t, uint8_t, bool)> touch_callback_{};
|
1332
|
+
CallbackManager<void()> buffer_overflow_callback_{};
|
1326
1333
|
|
1327
1334
|
optional<nextion_writer_t> writer_;
|
1328
1335
|
float brightness_{1.0};
|
@@ -36,8 +36,8 @@ int Nextion::upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &r
|
|
36
36
|
ESP_LOGV(TAG, "Requesting range: %s", range_header);
|
37
37
|
esp_http_client_set_header(http_client, "Range", range_header);
|
38
38
|
ESP_LOGV(TAG, "Opening HTTP connetion");
|
39
|
-
esp_err_t err;
|
40
|
-
if (
|
39
|
+
esp_err_t err = esp_http_client_open(http_client, 0);
|
40
|
+
if (err != ESP_OK) {
|
41
41
|
ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
|
42
42
|
return -1;
|
43
43
|
}
|
@@ -1,12 +1,11 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
2
3
|
import esphome.config_validation as cv
|
3
4
|
from esphome.components import sensor
|
4
5
|
|
5
|
-
from esphome.const import
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
from .. import nextion_ns, CONF_NEXTION_ID
|
6
|
+
from esphome.const import CONF_ID, CONF_COMPONENT_ID, CONF_STATE
|
7
|
+
|
8
|
+
from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION
|
10
9
|
|
11
10
|
from ..base_component import (
|
12
11
|
setup_component_core_,
|
@@ -25,6 +24,10 @@ CODEOWNERS = ["@senexcrenshaw"]
|
|
25
24
|
|
26
25
|
NextionSensor = nextion_ns.class_("NextionSensor", sensor.Sensor, cg.PollingComponent)
|
27
26
|
|
27
|
+
NextionPublishFloatAction = nextion_ns.class_(
|
28
|
+
"NextionPublishFloatAction", automation.Action
|
29
|
+
)
|
30
|
+
|
28
31
|
|
29
32
|
def CheckWaveID(value):
|
30
33
|
value = cv.int_(value)
|
@@ -95,3 +98,33 @@ async def to_code(config):
|
|
95
98
|
|
96
99
|
if CONF_WAVE_MAX_LENGTH in config:
|
97
100
|
cg.add(var.set_wave_max_length(config[CONF_WAVE_MAX_LENGTH]))
|
101
|
+
|
102
|
+
|
103
|
+
@automation.register_action(
|
104
|
+
"sensor.nextion.publish",
|
105
|
+
NextionPublishFloatAction,
|
106
|
+
cv.Schema(
|
107
|
+
{
|
108
|
+
cv.Required(CONF_ID): cv.use_id(NextionSensor),
|
109
|
+
cv.Required(CONF_STATE): cv.templatable(cv.float_),
|
110
|
+
cv.Optional(CONF_PUBLISH_STATE, default="true"): cv.templatable(cv.boolean),
|
111
|
+
cv.Optional(CONF_SEND_TO_NEXTION, default="true"): cv.templatable(
|
112
|
+
cv.boolean
|
113
|
+
),
|
114
|
+
}
|
115
|
+
),
|
116
|
+
)
|
117
|
+
async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
118
|
+
paren = await cg.get_variable(config[CONF_ID])
|
119
|
+
var = cg.new_Pvariable(action_id, template_arg, paren)
|
120
|
+
|
121
|
+
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
122
|
+
cg.add(var.set_state(template_))
|
123
|
+
|
124
|
+
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
125
|
+
cg.add(var.set_publish_state(template_))
|
126
|
+
|
127
|
+
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
128
|
+
cg.add(var.set_send_to_nextion(template_))
|
129
|
+
|
130
|
+
return var
|
@@ -1,9 +1,11 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
2
3
|
import esphome.config_validation as cv
|
3
4
|
from esphome.components import switch
|
4
5
|
|
5
|
-
from esphome.const import CONF_ID
|
6
|
-
|
6
|
+
from esphome.const import CONF_ID, CONF_STATE
|
7
|
+
|
8
|
+
from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION
|
7
9
|
|
8
10
|
from ..base_component import (
|
9
11
|
setup_component_core_,
|
@@ -16,6 +18,10 @@ CODEOWNERS = ["@senexcrenshaw"]
|
|
16
18
|
|
17
19
|
NextionSwitch = nextion_ns.class_("NextionSwitch", switch.Switch, cg.PollingComponent)
|
18
20
|
|
21
|
+
NextionPublishBoolAction = nextion_ns.class_(
|
22
|
+
"NextionPublishBoolAction", automation.Action
|
23
|
+
)
|
24
|
+
|
19
25
|
CONFIG_SCHEMA = cv.All(
|
20
26
|
switch.switch_schema(NextionSwitch)
|
21
27
|
.extend(CONFIG_SWITCH_COMPONENT_SCHEMA)
|
@@ -33,3 +39,33 @@ async def to_code(config):
|
|
33
39
|
cg.add(hub.register_switch_component(var))
|
34
40
|
|
35
41
|
await setup_component_core_(var, config, ".val")
|
42
|
+
|
43
|
+
|
44
|
+
@automation.register_action(
|
45
|
+
"switch.nextion.publish",
|
46
|
+
NextionPublishBoolAction,
|
47
|
+
cv.Schema(
|
48
|
+
{
|
49
|
+
cv.Required(CONF_ID): cv.use_id(NextionSwitch),
|
50
|
+
cv.Required(CONF_STATE): cv.templatable(cv.boolean),
|
51
|
+
cv.Optional(CONF_PUBLISH_STATE, default="true"): cv.templatable(cv.boolean),
|
52
|
+
cv.Optional(CONF_SEND_TO_NEXTION, default="true"): cv.templatable(
|
53
|
+
cv.boolean
|
54
|
+
),
|
55
|
+
}
|
56
|
+
),
|
57
|
+
)
|
58
|
+
async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
59
|
+
paren = await cg.get_variable(config[CONF_ID])
|
60
|
+
var = cg.new_Pvariable(action_id, template_arg, paren)
|
61
|
+
|
62
|
+
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
63
|
+
cg.add(var.set_state(template_))
|
64
|
+
|
65
|
+
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
66
|
+
cg.add(var.set_publish_state(template_))
|
67
|
+
|
68
|
+
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
69
|
+
cg.add(var.set_send_to_nextion(template_))
|
70
|
+
|
71
|
+
return var
|
@@ -1,9 +1,10 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
from esphome.components import text_sensor
|
2
3
|
import esphome.config_validation as cv
|
3
4
|
import esphome.codegen as cg
|
4
|
-
from esphome.const import CONF_ID
|
5
|
+
from esphome.const import CONF_ID, CONF_STATE
|
5
6
|
|
6
|
-
from .. import nextion_ns, CONF_NEXTION_ID
|
7
|
+
from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION
|
7
8
|
|
8
9
|
from ..base_component import (
|
9
10
|
setup_component_core_,
|
@@ -16,6 +17,10 @@ NextionTextSensor = nextion_ns.class_(
|
|
16
17
|
"NextionTextSensor", text_sensor.TextSensor, cg.PollingComponent
|
17
18
|
)
|
18
19
|
|
20
|
+
NextionPublishTextAction = nextion_ns.class_(
|
21
|
+
"NextionPublishTextAction", automation.Action
|
22
|
+
)
|
23
|
+
|
19
24
|
CONFIG_SCHEMA = (
|
20
25
|
text_sensor.text_sensor_schema(NextionTextSensor)
|
21
26
|
.extend(CONFIG_TEXT_COMPONENT_SCHEMA)
|
@@ -32,3 +37,33 @@ async def to_code(config):
|
|
32
37
|
cg.add(hub.register_textsensor_component(var))
|
33
38
|
|
34
39
|
await setup_component_core_(var, config, ".txt")
|
40
|
+
|
41
|
+
|
42
|
+
@automation.register_action(
|
43
|
+
"text_sensor.nextion.publish",
|
44
|
+
NextionPublishTextAction,
|
45
|
+
cv.Schema(
|
46
|
+
{
|
47
|
+
cv.Required(CONF_ID): cv.use_id(NextionTextSensor),
|
48
|
+
cv.Required(CONF_STATE): cv.templatable(cv.string_strict),
|
49
|
+
cv.Optional(CONF_PUBLISH_STATE, default="true"): cv.templatable(cv.boolean),
|
50
|
+
cv.Optional(CONF_SEND_TO_NEXTION, default="true"): cv.templatable(
|
51
|
+
cv.boolean
|
52
|
+
),
|
53
|
+
}
|
54
|
+
),
|
55
|
+
)
|
56
|
+
async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
57
|
+
paren = await cg.get_variable(config[CONF_ID])
|
58
|
+
var = cg.new_Pvariable(action_id, template_arg, paren)
|
59
|
+
|
60
|
+
template_ = await cg.templatable(config[CONF_STATE], args, cg.const_char_ptr)
|
61
|
+
cg.add(var.set_state(template_))
|
62
|
+
|
63
|
+
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, cg.bool_)
|
64
|
+
cg.add(var.set_publish_state(template_))
|
65
|
+
|
66
|
+
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, cg.bool_)
|
67
|
+
cg.add(var.set_send_to_nextion(template_))
|
68
|
+
|
69
|
+
return var
|
@@ -30,13 +30,13 @@ std::vector<uint8_t> NdefRecord::encode(bool first, bool last) {
|
|
30
30
|
data.push_back(payload_length & 0xFF);
|
31
31
|
}
|
32
32
|
|
33
|
-
if (this->id_.
|
33
|
+
if (!this->id_.empty()) {
|
34
34
|
data.push_back(this->id_.length());
|
35
35
|
}
|
36
36
|
|
37
37
|
data.insert(data.end(), this->type_.begin(), this->type_.end());
|
38
38
|
|
39
|
-
if (this->id_.
|
39
|
+
if (!this->id_.empty()) {
|
40
40
|
data.insert(data.end(), this->id_.begin(), this->id_.end());
|
41
41
|
}
|
42
42
|
|
@@ -55,7 +55,7 @@ uint8_t NdefRecord::create_flag_byte(bool first, bool last, size_t payload_size)
|
|
55
55
|
if (payload_size <= 255) {
|
56
56
|
value = value | 0x10; // Set SR bit
|
57
57
|
}
|
58
|
-
if (this->id_.
|
58
|
+
if (!this->id_.empty()) {
|
59
59
|
value = value | 0x08; // Set IL bit
|
60
60
|
}
|
61
61
|
return value;
|
@@ -25,7 +25,7 @@ using std::to_string;
|
|
25
25
|
static const char *const TAG = "opentherm";
|
26
26
|
|
27
27
|
#ifdef ESP8266
|
28
|
-
OpenTherm *OpenTherm::
|
28
|
+
OpenTherm *OpenTherm::instance = nullptr;
|
29
29
|
#endif
|
30
30
|
|
31
31
|
OpenTherm::OpenTherm(InternalGPIOPin *in_pin, InternalGPIOPin *out_pin, int32_t device_timeout)
|
@@ -49,7 +49,7 @@ OpenTherm::OpenTherm(InternalGPIOPin *in_pin, InternalGPIOPin *out_pin, int32_t
|
|
49
49
|
|
50
50
|
bool OpenTherm::initialize() {
|
51
51
|
#ifdef ESP8266
|
52
|
-
OpenTherm::
|
52
|
+
OpenTherm::instance = this;
|
53
53
|
#endif
|
54
54
|
this->in_pin_->pin_mode(gpio::FLAG_INPUT);
|
55
55
|
this->out_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
@@ -212,7 +212,7 @@ bool IRAM_ATTR OpenTherm::timer_isr(OpenTherm *arg) {
|
|
212
212
|
}
|
213
213
|
|
214
214
|
#ifdef ESP8266
|
215
|
-
void IRAM_ATTR OpenTherm::esp8266_timer_isr() { OpenTherm::timer_isr(OpenTherm::
|
215
|
+
void IRAM_ATTR OpenTherm::esp8266_timer_isr() { OpenTherm::timer_isr(OpenTherm::instance); }
|
216
216
|
#endif
|
217
217
|
|
218
218
|
void IRAM_ATTR OpenTherm::bit_read_(uint8_t value) {
|
@@ -370,7 +370,7 @@ class OpenTherm {
|
|
370
370
|
|
371
371
|
#ifdef ESP8266
|
372
372
|
// ESP8266 timer can accept callback with no parameters, so we have this hack to save a static instance of OpenTherm
|
373
|
-
static OpenTherm *
|
373
|
+
static OpenTherm *instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
374
374
|
#endif
|
375
375
|
};
|
376
376
|
|
@@ -12,7 +12,7 @@ class OTAStateChangeTrigger : public Trigger<OTAState> {
|
|
12
12
|
explicit OTAStateChangeTrigger(OTAComponent *parent) {
|
13
13
|
parent->add_on_state_callback([this, parent](OTAState state, float progress, uint8_t error) {
|
14
14
|
if (!parent->is_failed()) {
|
15
|
-
|
15
|
+
trigger(state);
|
16
16
|
}
|
17
17
|
});
|
18
18
|
}
|
@@ -32,7 +32,7 @@ void FloatOutput::set_level(float state) {
|
|
32
32
|
}
|
33
33
|
#endif
|
34
34
|
|
35
|
-
if (
|
35
|
+
if (state != 0.0f || !this->zero_means_zero_) // regardless of min_power_, 0.0 means off
|
36
36
|
state = (state * (this->max_power_ - this->min_power_)) + this->min_power_;
|
37
37
|
|
38
38
|
if (this->is_inverted())
|
@@ -34,7 +34,7 @@ void PCA6416AComponent::setup() {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
// Test to see if the device supports pull-up resistors
|
37
|
-
if (this->read_register(PCAL6416A_PULL_EN0, &value, 1, true) ==
|
37
|
+
if (this->read_register(PCAL6416A_PULL_EN0, &value, 1, true) == i2c::ERROR_OK) {
|
38
38
|
this->has_pullup_ = true;
|
39
39
|
}
|
40
40
|
|
@@ -106,7 +106,8 @@ bool PCA6416AComponent::read_register_(uint8_t reg, uint8_t *value) {
|
|
106
106
|
return false;
|
107
107
|
}
|
108
108
|
|
109
|
-
|
109
|
+
this->last_error_ = this->read_register(reg, value, 1, true);
|
110
|
+
if (this->last_error_ != i2c::ERROR_OK) {
|
110
111
|
this->status_set_warning();
|
111
112
|
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
112
113
|
return false;
|
@@ -122,7 +123,8 @@ bool PCA6416AComponent::write_register_(uint8_t reg, uint8_t value) {
|
|
122
123
|
return false;
|
123
124
|
}
|
124
125
|
|
125
|
-
|
126
|
+
this->last_error_ = this->write_register(reg, &value, 1, true);
|
127
|
+
if (this->last_error_ != i2c::ERROR_OK) {
|
126
128
|
this->status_set_warning();
|
127
129
|
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
128
130
|
return false;
|
@@ -95,8 +95,8 @@ bool PCA9554Component::read_inputs_() {
|
|
95
95
|
return false;
|
96
96
|
}
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
this->last_error_ = this->read_register(INPUT_REG * this->reg_width_, inputs, this->reg_width_, true);
|
99
|
+
if (this->last_error_ != i2c::ERROR_OK) {
|
100
100
|
this->status_set_warning();
|
101
101
|
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
102
102
|
return false;
|
@@ -113,8 +113,8 @@ bool PCA9554Component::write_register_(uint8_t reg, uint16_t value) {
|
|
113
113
|
uint8_t outputs[2];
|
114
114
|
outputs[0] = (uint8_t) value;
|
115
115
|
outputs[1] = (uint8_t) (value >> 8);
|
116
|
-
|
117
|
-
|
116
|
+
this->last_error_ = this->write_register(reg * this->reg_width_, outputs, this->reg_width_, true);
|
117
|
+
if (this->last_error_ != i2c::ERROR_OK) {
|
118
118
|
this->status_set_warning();
|
119
119
|
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
120
120
|
return false;
|
@@ -790,7 +790,7 @@ uint8_t Pipsolar::check_incoming_crc_() {
|
|
790
790
|
// send next command used
|
791
791
|
uint8_t Pipsolar::send_next_command_() {
|
792
792
|
uint16_t crc16;
|
793
|
-
if (this->command_queue_[this->command_queue_position_].
|
793
|
+
if (!this->command_queue_[this->command_queue_position_].empty()) {
|
794
794
|
const char *command = this->command_queue_[this->command_queue_position_].c_str();
|
795
795
|
uint8_t byte_command[16];
|
796
796
|
uint8_t length = this->command_queue_[this->command_queue_position_].length();
|
@@ -846,7 +846,7 @@ void Pipsolar::queue_command_(const char *command, uint8_t length) {
|
|
846
846
|
uint8_t next_position = command_queue_position_;
|
847
847
|
for (uint8_t i = 0; i < COMMAND_QUEUE_LENGTH; i++) {
|
848
848
|
uint8_t testposition = (next_position + i) % COMMAND_QUEUE_LENGTH;
|
849
|
-
if (command_queue_[testposition].
|
849
|
+
if (command_queue_[testposition].empty()) {
|
850
850
|
command_queue_[testposition] = command;
|
851
851
|
ESP_LOGD(TAG, "Command queued successfully: %s with length %u at position %d", command,
|
852
852
|
command_queue_[testposition].length(), testposition);
|
@@ -10,11 +10,11 @@ static const char *const TAG = "pipsolar.switch";
|
|
10
10
|
void PipsolarSwitch::dump_config() { LOG_SWITCH("", "Pipsolar Switch", this); }
|
11
11
|
void PipsolarSwitch::write_state(bool state) {
|
12
12
|
if (state) {
|
13
|
-
if (this->on_command_.
|
13
|
+
if (!this->on_command_.empty()) {
|
14
14
|
this->parent_->switch_command(this->on_command_);
|
15
15
|
}
|
16
16
|
} else {
|
17
|
-
if (this->off_command_.
|
17
|
+
if (!this->off_command_.empty()) {
|
18
18
|
this->parent_->switch_command(this->off_command_);
|
19
19
|
}
|
20
20
|
}
|
@@ -80,8 +80,8 @@ bool PN532::is_mifare_ultralight_formatted_(const std::vector<uint8_t> &page_3_t
|
|
80
80
|
const uint8_t p4_offset = nfc::MIFARE_ULTRALIGHT_PAGE_SIZE; // page 4 will begin 4 bytes into the vector
|
81
81
|
|
82
82
|
return (page_3_to_6.size() > p4_offset + 3) &&
|
83
|
-
|
84
|
-
|
83
|
+
((page_3_to_6[p4_offset + 0] != 0xFF) || (page_3_to_6[p4_offset + 1] != 0xFF) ||
|
84
|
+
(page_3_to_6[p4_offset + 2] != 0xFF) || (page_3_to_6[p4_offset + 3] != 0xFF));
|
85
85
|
}
|
86
86
|
|
87
87
|
uint16_t PN532::read_mifare_ultralight_capacity_() {
|
@@ -81,8 +81,8 @@ bool PN7150::is_mifare_ultralight_formatted_(const std::vector<uint8_t> &page_3_
|
|
81
81
|
const uint8_t p4_offset = nfc::MIFARE_ULTRALIGHT_PAGE_SIZE; // page 4 will begin 4 bytes into the vector
|
82
82
|
|
83
83
|
return (page_3_to_6.size() > p4_offset + 3) &&
|
84
|
-
|
85
|
-
|
84
|
+
((page_3_to_6[p4_offset + 0] != 0xFF) || (page_3_to_6[p4_offset + 1] != 0xFF) ||
|
85
|
+
(page_3_to_6[p4_offset + 2] != 0xFF) || (page_3_to_6[p4_offset + 3] != 0xFF));
|
86
86
|
}
|
87
87
|
|
88
88
|
uint16_t PN7150::read_mifare_ultralight_capacity_() {
|