esphome 2024.8.2__py3-none-any.whl → 2024.9.0__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/__main__.py +6 -2
- esphome/components/api/api_connection.cpp +53 -0
- esphome/components/api/api_connection.h +4 -0
- esphome/components/api/api_pb2.cpp +280 -0
- esphome/components/api/api_pb2.h +91 -0
- esphome/components/api/api_pb2_service.cpp +85 -0
- esphome/components/api/api_pb2_service.h +28 -0
- esphome/components/async_tcp/__init__.py +3 -3
- esphome/components/atm90e26/sensor.py +10 -10
- esphome/components/atm90e32/sensor.py +1 -1
- esphome/components/bl0906/__init__.py +1 -0
- esphome/components/bl0906/bl0906.cpp +238 -0
- esphome/components/bl0906/bl0906.h +96 -0
- esphome/components/bl0906/const.py +4 -0
- esphome/components/bl0906/constants.h +122 -0
- esphome/components/bl0906/sensor.py +184 -0
- esphome/components/bl0942/__init__.py +1 -1
- esphome/components/bl0942/bl0942.cpp +127 -34
- esphome/components/bl0942/bl0942.h +87 -3
- esphome/components/bl0942/sensor.py +46 -8
- esphome/components/ble_client/__init__.py +1 -3
- esphome/components/ble_presence/binary_sensor.py +2 -2
- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
- esphome/components/bmp280/sensor.py +2 -93
- esphome/components/bmp280_base/__init__.py +88 -0
- esphome/components/{bmp280/bmp280.cpp → bmp280_base/bmp280_base.cpp} +11 -4
- esphome/components/{bmp280/bmp280.h → bmp280_base/bmp280_base.h} +9 -5
- esphome/components/bmp280_i2c/__init__.py +0 -0
- esphome/components/bmp280_i2c/bmp280_i2c.cpp +27 -0
- esphome/components/bmp280_i2c/bmp280_i2c.h +22 -0
- esphome/components/bmp280_i2c/sensor.py +22 -0
- esphome/components/bmp280_spi/__init__.py +0 -0
- esphome/components/bmp280_spi/bmp280_spi.cpp +65 -0
- esphome/components/bmp280_spi/bmp280_spi.h +20 -0
- esphome/components/bmp280_spi/sensor.py +22 -0
- esphome/components/captive_portal/captive_portal.cpp +2 -0
- esphome/components/captive_portal/captive_portal.h +3 -1
- esphome/components/ch422g/__init__.py +67 -0
- esphome/components/ch422g/ch422g.cpp +122 -0
- esphome/components/ch422g/ch422g.h +70 -0
- esphome/components/debug/debug_esp32.cpp +3 -1
- esphome/components/display/__init__.py +5 -4
- esphome/components/dsmr/dsmr.cpp +6 -0
- esphome/components/dsmr/dsmr.h +6 -0
- esphome/components/dsmr/text_sensor.py +7 -2
- esphome/components/e131/e131.cpp +2 -0
- esphome/components/e131/e131.h +3 -1
- esphome/components/e131/e131_addressable_light_effect.cpp +2 -0
- esphome/components/e131/e131_addressable_light_effect.h +2 -1
- esphome/components/e131/e131_packet.cpp +2 -0
- esphome/components/esp32_ble/ble_uuid.cpp +7 -0
- esphome/components/esp32_ble/ble_uuid.h +1 -0
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +11 -9
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +3 -3
- esphome/components/esp32_camera/__init__.py +4 -0
- esphome/components/esp32_camera/esp32_camera.cpp +9 -1
- esphome/components/esp32_camera/esp32_camera.h +3 -0
- esphome/components/esp32_can/canbus.py +18 -7
- esphome/components/esp32_can/esp32_can.cpp +8 -0
- esphome/components/esp32_can/esp32_can.h +4 -0
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +14 -2
- esphome/components/esp32_rmt_led_strip/led_strip.h +3 -2
- esphome/components/esp32_rmt_led_strip/light.py +21 -4
- esphome/components/esphome/ota/ota_esphome.cpp +2 -1
- esphome/components/esphome/ota/ota_esphome.h +2 -0
- esphome/components/font/__init__.py +11 -22
- esphome/components/font/font.cpp +3 -2
- esphome/components/font/font.h +12 -3
- esphome/components/gree/climate.py +2 -1
- esphome/components/gree/gree.cpp +54 -3
- esphome/components/gree/gree.h +10 -2
- esphome/components/gt911/touchscreen/__init__.py +6 -4
- esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +17 -0
- esphome/components/gt911/touchscreen/gt911_touchscreen.h +2 -0
- esphome/components/hmac_md5/__init__.py +2 -0
- esphome/components/hmac_md5/hmac_md5.cpp +56 -0
- esphome/components/hmac_md5/hmac_md5.h +48 -0
- esphome/components/homeassistant/__init__.py +13 -0
- esphome/components/homeassistant/switch/__init__.py +15 -2
- esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
- esphome/components/i2s_audio/__init__.py +88 -9
- esphome/components/i2s_audio/i2s_audio.h +20 -2
- esphome/components/i2s_audio/media_player/__init__.py +8 -4
- esphome/components/i2s_audio/media_player/i2s_audio_media_player.h +1 -1
- esphome/components/i2s_audio/microphone/__init__.py +19 -51
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +18 -15
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -12
- esphome/components/i2s_audio/speaker/__init__.py +39 -27
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +49 -37
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +3 -4
- esphome/components/ili9xxx/display.py +16 -17
- esphome/components/ili9xxx/ili9xxx_display.cpp +1 -1
- esphome/components/ili9xxx/ili9xxx_display.h +18 -18
- esphome/components/ili9xxx/ili9xxx_init.h +0 -3
- esphome/components/improv_serial/improv_serial_component.cpp +2 -1
- esphome/components/improv_serial/improv_serial_component.h +2 -1
- esphome/components/ledc/ledc_output.cpp +11 -7
- esphome/components/libretiny/__init__.py +8 -13
- esphome/components/ltr501/__init__.py +1 -0
- esphome/components/ltr501/ltr501.cpp +542 -0
- esphome/components/ltr501/ltr501.h +184 -0
- esphome/components/ltr501/ltr_definitions_501.h +260 -0
- esphome/components/ltr501/sensor.py +274 -0
- esphome/components/ltr_als_ps/sensor.py +2 -2
- esphome/components/lvgl/__init__.py +19 -16
- esphome/components/lvgl/automation.py +90 -9
- esphome/components/lvgl/defines.py +29 -2
- esphome/components/lvgl/gradient.py +61 -0
- esphome/components/lvgl/lv_validation.py +45 -27
- esphome/components/lvgl/lvcode.py +8 -3
- esphome/components/lvgl/lvgl_esphome.cpp +54 -0
- esphome/components/lvgl/lvgl_esphome.h +9 -3
- esphome/components/lvgl/number/__init__.py +1 -0
- esphome/components/lvgl/number/lvgl_number.h +3 -1
- esphome/components/lvgl/schemas.py +16 -11
- esphome/components/lvgl/select/__init__.py +1 -0
- esphome/components/lvgl/select/lvgl_select.h +3 -1
- esphome/components/lvgl/switch/__init__.py +2 -1
- esphome/components/lvgl/switch/lvgl_switch.h +3 -1
- esphome/components/lvgl/text/__init__.py +1 -0
- esphome/components/lvgl/text/lvgl_text.h +3 -1
- esphome/components/lvgl/trigger.py +3 -2
- esphome/components/lvgl/types.py +2 -1
- esphome/components/lvgl/widgets/__init__.py +23 -8
- esphome/components/lvgl/widgets/arc.py +5 -1
- esphome/components/lvgl/widgets/buttonmatrix.py +5 -1
- esphome/components/lvgl/widgets/checkbox.py +8 -3
- esphome/components/lvgl/widgets/meter.py +8 -1
- esphome/components/lvgl/widgets/msgbox.py +26 -15
- esphome/components/lvgl/widgets/page.py +51 -7
- esphome/components/lvgl/widgets/tileview.py +2 -8
- esphome/components/max31856/max31856.cpp +12 -1
- esphome/components/max31856/max31856.h +5 -2
- esphome/components/max31856/sensor.py +20 -0
- esphome/components/mcp9600/sensor.py +2 -2
- esphome/components/mdns/__init__.py +6 -6
- esphome/components/media_player/media_player.h +16 -0
- esphome/components/micro_wake_word/__init__.py +2 -25
- esphome/components/microphone/microphone.h +1 -1
- esphome/components/mics_4514/mics_4514.cpp +26 -36
- esphome/components/modbus_controller/__init__.py +6 -0
- esphome/components/modbus_controller/const.py +2 -0
- esphome/components/modbus_controller/modbus_controller.cpp +30 -27
- esphome/components/modbus_controller/modbus_controller.h +22 -4
- esphome/components/network/__init__.py +11 -8
- esphome/components/pipsolar/pipsolar.cpp +3 -0
- esphome/components/pipsolar/pipsolar.h +1 -0
- esphome/components/pipsolar/switch/__init__.py +2 -0
- esphome/components/prometheus/prometheus_handler.cpp +2 -0
- esphome/components/prometheus/prometheus_handler.h +3 -1
- esphome/components/rp2040/__init__.py +7 -8
- esphome/components/rpi_dpi_rgb/display.py +20 -17
- esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +36 -6
- esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +4 -0
- esphome/components/socket/socket.cpp +2 -0
- esphome/components/socket/socket.h +2 -0
- esphome/components/speaker/speaker.h +1 -1
- esphome/components/st7701s/display.py +35 -37
- esphome/components/st7701s/st7701s.cpp +11 -6
- esphome/components/st7701s/st7701s.h +1 -0
- esphome/components/statsd/__init__.py +65 -0
- esphome/components/statsd/statsd.cpp +156 -0
- esphome/components/statsd/statsd.h +86 -0
- esphome/components/tuya/__init__.py +1 -0
- esphome/components/tuya/number/__init__.py +39 -2
- esphome/components/tuya/number/tuya_number.cpp +58 -2
- esphome/components/tuya/number/tuya_number.h +12 -3
- esphome/components/udp/__init__.py +158 -0
- esphome/components/udp/binary_sensor.py +27 -0
- esphome/components/udp/sensor.py +27 -0
- esphome/components/udp/udp_component.cpp +616 -0
- esphome/components/udp/udp_component.h +158 -0
- esphome/components/uponor_smatrix/uponor_smatrix.cpp +4 -6
- esphome/components/uponor_smatrix/uponor_smatrix.h +0 -1
- esphome/components/veml7700/sensor.py +2 -2
- esphome/components/voice_assistant/__init__.py +6 -0
- esphome/components/voice_assistant/voice_assistant.cpp +24 -2
- esphome/components/voice_assistant/voice_assistant.h +20 -0
- esphome/components/web_server/__init__.py +11 -11
- esphome/components/web_server/list_entities.cpp +2 -0
- esphome/components/web_server/list_entities.h +3 -1
- esphome/components/web_server/web_server.cpp +2 -1
- esphome/components/web_server/web_server.h +2 -0
- esphome/components/web_server_base/web_server_base.cpp +2 -0
- esphome/components/web_server_base/web_server_base.h +3 -1
- esphome/components/wifi/wifi_component_libretiny.cpp +15 -1
- esphome/components/wireguard/__init__.py +9 -6
- esphome/components/wireguard/wireguard.cpp +2 -1
- esphome/components/wireguard/wireguard.h +3 -1
- esphome/config_validation.py +8 -0
- esphome/const.py +8 -1
- esphome/core/bytebuffer.cpp +117 -84
- esphome/core/bytebuffer.h +69 -21
- esphome/core/config.py +0 -3
- esphome/core/defines.h +2 -0
- esphome/core/ring_buffer.cpp +13 -2
- esphome/core/ring_buffer.h +56 -0
- esphome/external_files.py +5 -3
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/METADATA +1 -1
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/RECORD +204 -169
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/LICENSE +0 -0
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/WHEEL +0 -0
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/top_level.txt +0 -0
@@ -54,6 +54,9 @@ bool BluetoothProxy::parse_devices(esp_ble_gap_cb_param_t::ble_scan_result_evt_p
|
|
54
54
|
}
|
55
55
|
|
56
56
|
resp.advertisements.push_back(std::move(adv));
|
57
|
+
|
58
|
+
ESP_LOGV(TAG, "Proxying raw packet from %02X:%02X:%02X:%02X:%02X:%02X, length %d. RSSI: %d dB", result.bda[0],
|
59
|
+
result.bda[1], result.bda[2], result.bda[3], result.bda[4], result.bda[5], length, result.rssi);
|
57
60
|
}
|
58
61
|
ESP_LOGV(TAG, "Proxying %d packets", count);
|
59
62
|
this->api_connection_->send_bluetooth_le_raw_advertisements_response(resp);
|
@@ -87,6 +90,8 @@ void BluetoothProxy::send_api_packet_(const esp32_ble_tracker::ESPBTDevice &devi
|
|
87
90
|
void BluetoothProxy::dump_config() {
|
88
91
|
ESP_LOGCONFIG(TAG, "Bluetooth Proxy:");
|
89
92
|
ESP_LOGCONFIG(TAG, " Active: %s", YESNO(this->active_));
|
93
|
+
ESP_LOGCONFIG(TAG, " Connections: %d", this->connections_.size());
|
94
|
+
ESP_LOGCONFIG(TAG, " Raw advertisements: %s", YESNO(this->raw_advertisements_));
|
90
95
|
}
|
91
96
|
|
92
97
|
int BluetoothProxy::get_bluetooth_connections_free() {
|
@@ -1,96 +1,5 @@
|
|
1
|
-
import esphome.codegen as cg
|
2
1
|
import esphome.config_validation as cv
|
3
|
-
from esphome.components import i2c, sensor
|
4
|
-
from esphome.const import (
|
5
|
-
CONF_ID,
|
6
|
-
CONF_PRESSURE,
|
7
|
-
CONF_TEMPERATURE,
|
8
|
-
DEVICE_CLASS_PRESSURE,
|
9
|
-
DEVICE_CLASS_TEMPERATURE,
|
10
|
-
STATE_CLASS_MEASUREMENT,
|
11
|
-
UNIT_CELSIUS,
|
12
|
-
UNIT_HECTOPASCAL,
|
13
|
-
CONF_IIR_FILTER,
|
14
|
-
CONF_OVERSAMPLING,
|
15
|
-
)
|
16
|
-
|
17
|
-
DEPENDENCIES = ["i2c"]
|
18
|
-
|
19
|
-
bmp280_ns = cg.esphome_ns.namespace("bmp280")
|
20
|
-
BMP280Oversampling = bmp280_ns.enum("BMP280Oversampling")
|
21
|
-
OVERSAMPLING_OPTIONS = {
|
22
|
-
"NONE": BMP280Oversampling.BMP280_OVERSAMPLING_NONE,
|
23
|
-
"1X": BMP280Oversampling.BMP280_OVERSAMPLING_1X,
|
24
|
-
"2X": BMP280Oversampling.BMP280_OVERSAMPLING_2X,
|
25
|
-
"4X": BMP280Oversampling.BMP280_OVERSAMPLING_4X,
|
26
|
-
"8X": BMP280Oversampling.BMP280_OVERSAMPLING_8X,
|
27
|
-
"16X": BMP280Oversampling.BMP280_OVERSAMPLING_16X,
|
28
|
-
}
|
29
|
-
|
30
|
-
BMP280IIRFilter = bmp280_ns.enum("BMP280IIRFilter")
|
31
|
-
IIR_FILTER_OPTIONS = {
|
32
|
-
"OFF": BMP280IIRFilter.BMP280_IIR_FILTER_OFF,
|
33
|
-
"2X": BMP280IIRFilter.BMP280_IIR_FILTER_2X,
|
34
|
-
"4X": BMP280IIRFilter.BMP280_IIR_FILTER_4X,
|
35
|
-
"8X": BMP280IIRFilter.BMP280_IIR_FILTER_8X,
|
36
|
-
"16X": BMP280IIRFilter.BMP280_IIR_FILTER_16X,
|
37
|
-
}
|
38
|
-
|
39
|
-
BMP280Component = bmp280_ns.class_(
|
40
|
-
"BMP280Component", cg.PollingComponent, i2c.I2CDevice
|
41
|
-
)
|
42
2
|
|
43
|
-
CONFIG_SCHEMA = (
|
44
|
-
|
45
|
-
{
|
46
|
-
cv.GenerateID(): cv.declare_id(BMP280Component),
|
47
|
-
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
48
|
-
unit_of_measurement=UNIT_CELSIUS,
|
49
|
-
accuracy_decimals=1,
|
50
|
-
device_class=DEVICE_CLASS_TEMPERATURE,
|
51
|
-
state_class=STATE_CLASS_MEASUREMENT,
|
52
|
-
).extend(
|
53
|
-
{
|
54
|
-
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
55
|
-
OVERSAMPLING_OPTIONS, upper=True
|
56
|
-
),
|
57
|
-
}
|
58
|
-
),
|
59
|
-
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
60
|
-
unit_of_measurement=UNIT_HECTOPASCAL,
|
61
|
-
accuracy_decimals=1,
|
62
|
-
device_class=DEVICE_CLASS_PRESSURE,
|
63
|
-
state_class=STATE_CLASS_MEASUREMENT,
|
64
|
-
).extend(
|
65
|
-
{
|
66
|
-
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
67
|
-
OVERSAMPLING_OPTIONS, upper=True
|
68
|
-
),
|
69
|
-
}
|
70
|
-
),
|
71
|
-
cv.Optional(CONF_IIR_FILTER, default="OFF"): cv.enum(
|
72
|
-
IIR_FILTER_OPTIONS, upper=True
|
73
|
-
),
|
74
|
-
}
|
75
|
-
)
|
76
|
-
.extend(cv.polling_component_schema("60s"))
|
77
|
-
.extend(i2c.i2c_device_schema(0x77))
|
3
|
+
CONFIG_SCHEMA = cv.invalid(
|
4
|
+
"The bmp280 sensor component has been renamed to bmp280_i2c."
|
78
5
|
)
|
79
|
-
|
80
|
-
|
81
|
-
async def to_code(config):
|
82
|
-
var = cg.new_Pvariable(config[CONF_ID])
|
83
|
-
await cg.register_component(var, config)
|
84
|
-
await i2c.register_i2c_device(var, config)
|
85
|
-
|
86
|
-
if temperature_config := config.get(CONF_TEMPERATURE):
|
87
|
-
sens = await sensor.new_sensor(temperature_config)
|
88
|
-
cg.add(var.set_temperature_sensor(sens))
|
89
|
-
cg.add(var.set_temperature_oversampling(temperature_config[CONF_OVERSAMPLING]))
|
90
|
-
|
91
|
-
if pressure_config := config.get(CONF_PRESSURE):
|
92
|
-
sens = await sensor.new_sensor(pressure_config)
|
93
|
-
cg.add(var.set_pressure_sensor(sens))
|
94
|
-
cg.add(var.set_pressure_oversampling(pressure_config[CONF_OVERSAMPLING]))
|
95
|
-
|
96
|
-
cg.add(var.set_iir_filter(config[CONF_IIR_FILTER]))
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
import esphome.config_validation as cv
|
3
|
+
from esphome.components import sensor
|
4
|
+
from esphome.const import (
|
5
|
+
CONF_ID,
|
6
|
+
CONF_IIR_FILTER,
|
7
|
+
CONF_OVERSAMPLING,
|
8
|
+
CONF_PRESSURE,
|
9
|
+
CONF_TEMPERATURE,
|
10
|
+
DEVICE_CLASS_PRESSURE,
|
11
|
+
DEVICE_CLASS_TEMPERATURE,
|
12
|
+
STATE_CLASS_MEASUREMENT,
|
13
|
+
UNIT_CELSIUS,
|
14
|
+
UNIT_HECTOPASCAL,
|
15
|
+
)
|
16
|
+
|
17
|
+
CODEOWNERS = ["@ademuri"]
|
18
|
+
|
19
|
+
bmp280_ns = cg.esphome_ns.namespace("bmp280_base")
|
20
|
+
BMP280Oversampling = bmp280_ns.enum("BMP280Oversampling")
|
21
|
+
OVERSAMPLING_OPTIONS = {
|
22
|
+
"NONE": BMP280Oversampling.BMP280_OVERSAMPLING_NONE,
|
23
|
+
"1X": BMP280Oversampling.BMP280_OVERSAMPLING_1X,
|
24
|
+
"2X": BMP280Oversampling.BMP280_OVERSAMPLING_2X,
|
25
|
+
"4X": BMP280Oversampling.BMP280_OVERSAMPLING_4X,
|
26
|
+
"8X": BMP280Oversampling.BMP280_OVERSAMPLING_8X,
|
27
|
+
"16X": BMP280Oversampling.BMP280_OVERSAMPLING_16X,
|
28
|
+
}
|
29
|
+
|
30
|
+
BMP280IIRFilter = bmp280_ns.enum("BMP280IIRFilter")
|
31
|
+
IIR_FILTER_OPTIONS = {
|
32
|
+
"OFF": BMP280IIRFilter.BMP280_IIR_FILTER_OFF,
|
33
|
+
"2X": BMP280IIRFilter.BMP280_IIR_FILTER_2X,
|
34
|
+
"4X": BMP280IIRFilter.BMP280_IIR_FILTER_4X,
|
35
|
+
"8X": BMP280IIRFilter.BMP280_IIR_FILTER_8X,
|
36
|
+
"16X": BMP280IIRFilter.BMP280_IIR_FILTER_16X,
|
37
|
+
}
|
38
|
+
|
39
|
+
CONFIG_SCHEMA_BASE = cv.Schema(
|
40
|
+
{
|
41
|
+
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
42
|
+
unit_of_measurement=UNIT_CELSIUS,
|
43
|
+
accuracy_decimals=1,
|
44
|
+
device_class=DEVICE_CLASS_TEMPERATURE,
|
45
|
+
state_class=STATE_CLASS_MEASUREMENT,
|
46
|
+
).extend(
|
47
|
+
{
|
48
|
+
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
49
|
+
OVERSAMPLING_OPTIONS, upper=True
|
50
|
+
),
|
51
|
+
}
|
52
|
+
),
|
53
|
+
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
54
|
+
unit_of_measurement=UNIT_HECTOPASCAL,
|
55
|
+
accuracy_decimals=1,
|
56
|
+
device_class=DEVICE_CLASS_PRESSURE,
|
57
|
+
state_class=STATE_CLASS_MEASUREMENT,
|
58
|
+
).extend(
|
59
|
+
{
|
60
|
+
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
61
|
+
OVERSAMPLING_OPTIONS, upper=True
|
62
|
+
),
|
63
|
+
}
|
64
|
+
),
|
65
|
+
cv.Optional(CONF_IIR_FILTER, default="OFF"): cv.enum(
|
66
|
+
IIR_FILTER_OPTIONS, upper=True
|
67
|
+
),
|
68
|
+
}
|
69
|
+
).extend(cv.polling_component_schema("60s"))
|
70
|
+
|
71
|
+
|
72
|
+
async def to_code_base(config):
|
73
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
74
|
+
await cg.register_component(var, config)
|
75
|
+
|
76
|
+
if temperature_config := config.get(CONF_TEMPERATURE):
|
77
|
+
sens = await sensor.new_sensor(temperature_config)
|
78
|
+
cg.add(var.set_temperature_sensor(sens))
|
79
|
+
cg.add(var.set_temperature_oversampling(temperature_config[CONF_OVERSAMPLING]))
|
80
|
+
|
81
|
+
if pressure_config := config.get(CONF_PRESSURE):
|
82
|
+
sens = await sensor.new_sensor(pressure_config)
|
83
|
+
cg.add(var.set_pressure_sensor(sens))
|
84
|
+
cg.add(var.set_pressure_oversampling(pressure_config[CONF_OVERSAMPLING]))
|
85
|
+
|
86
|
+
cg.add(var.set_iir_filter(config[CONF_IIR_FILTER]))
|
87
|
+
|
88
|
+
return var
|
@@ -1,9 +1,9 @@
|
|
1
|
-
#include "
|
1
|
+
#include "bmp280_base.h"
|
2
2
|
#include "esphome/core/hal.h"
|
3
3
|
#include "esphome/core/log.h"
|
4
4
|
|
5
5
|
namespace esphome {
|
6
|
-
namespace
|
6
|
+
namespace bmp280_base {
|
7
7
|
|
8
8
|
static const char *const TAG = "bmp280.sensor";
|
9
9
|
|
@@ -59,6 +59,14 @@ static const char *iir_filter_to_str(BMP280IIRFilter filter) {
|
|
59
59
|
void BMP280Component::setup() {
|
60
60
|
ESP_LOGCONFIG(TAG, "Setting up BMP280...");
|
61
61
|
uint8_t chip_id = 0;
|
62
|
+
|
63
|
+
// Read the chip id twice, to work around a bug where the first read is 0.
|
64
|
+
// https://community.st.com/t5/stm32-mcus-products/issue-with-reading-bmp280-chip-id-using-spi/td-p/691855
|
65
|
+
if (!this->read_byte(0xD0, &chip_id)) {
|
66
|
+
this->error_code_ = COMMUNICATION_FAILED;
|
67
|
+
this->mark_failed();
|
68
|
+
return;
|
69
|
+
}
|
62
70
|
if (!this->read_byte(0xD0, &chip_id)) {
|
63
71
|
this->error_code_ = COMMUNICATION_FAILED;
|
64
72
|
this->mark_failed();
|
@@ -122,7 +130,6 @@ void BMP280Component::setup() {
|
|
122
130
|
}
|
123
131
|
void BMP280Component::dump_config() {
|
124
132
|
ESP_LOGCONFIG(TAG, "BMP280:");
|
125
|
-
LOG_I2C_DEVICE(this);
|
126
133
|
switch (this->error_code_) {
|
127
134
|
case COMMUNICATION_FAILED:
|
128
135
|
ESP_LOGE(TAG, "Communication with BMP280 failed!");
|
@@ -262,5 +269,5 @@ uint16_t BMP280Component::read_u16_le_(uint8_t a_register) {
|
|
262
269
|
}
|
263
270
|
int16_t BMP280Component::read_s16_le_(uint8_t a_register) { return this->read_u16_le_(a_register); }
|
264
271
|
|
265
|
-
} // namespace
|
272
|
+
} // namespace bmp280_base
|
266
273
|
} // namespace esphome
|
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
#include "esphome/core/component.h"
|
4
4
|
#include "esphome/components/sensor/sensor.h"
|
5
|
-
#include "esphome/components/i2c/i2c.h"
|
6
5
|
|
7
6
|
namespace esphome {
|
8
|
-
namespace
|
7
|
+
namespace bmp280_base {
|
9
8
|
|
10
9
|
/// Internal struct storing the calibration values of an BMP280.
|
11
10
|
struct BMP280CalibrationData {
|
@@ -50,8 +49,8 @@ enum BMP280IIRFilter {
|
|
50
49
|
BMP280_IIR_FILTER_16X = 0b100,
|
51
50
|
};
|
52
51
|
|
53
|
-
/// This class implements support for the BMP280 Temperature+Pressure
|
54
|
-
class BMP280Component : public PollingComponent
|
52
|
+
/// This class implements support for the BMP280 Temperature+Pressure sensor.
|
53
|
+
class BMP280Component : public PollingComponent {
|
55
54
|
public:
|
56
55
|
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
57
56
|
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
|
@@ -68,6 +67,11 @@ class BMP280Component : public PollingComponent, public i2c::I2CDevice {
|
|
68
67
|
float get_setup_priority() const override;
|
69
68
|
void update() override;
|
70
69
|
|
70
|
+
virtual bool read_byte(uint8_t a_register, uint8_t *data) = 0;
|
71
|
+
virtual bool write_byte(uint8_t a_register, uint8_t data) = 0;
|
72
|
+
virtual bool read_bytes(uint8_t a_register, uint8_t *data, size_t len) = 0;
|
73
|
+
virtual bool read_byte_16(uint8_t a_register, uint16_t *data) = 0;
|
74
|
+
|
71
75
|
protected:
|
72
76
|
/// Read the temperature value and store the calculated ambient temperature in t_fine.
|
73
77
|
float read_temperature_(int32_t *t_fine);
|
@@ -90,5 +94,5 @@ class BMP280Component : public PollingComponent, public i2c::I2CDevice {
|
|
90
94
|
} error_code_{NONE};
|
91
95
|
};
|
92
96
|
|
93
|
-
} // namespace
|
97
|
+
} // namespace bmp280_base
|
94
98
|
} // namespace esphome
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#include "bmp280_i2c.h"
|
2
|
+
#include "esphome/core/hal.h"
|
3
|
+
#include "esphome/core/log.h"
|
4
|
+
|
5
|
+
namespace esphome {
|
6
|
+
namespace bmp280_i2c {
|
7
|
+
|
8
|
+
bool BMP280I2CComponent::read_byte(uint8_t a_register, uint8_t *data) {
|
9
|
+
return I2CDevice::read_byte(a_register, data);
|
10
|
+
};
|
11
|
+
bool BMP280I2CComponent::write_byte(uint8_t a_register, uint8_t data) {
|
12
|
+
return I2CDevice::write_byte(a_register, data);
|
13
|
+
};
|
14
|
+
bool BMP280I2CComponent::read_bytes(uint8_t a_register, uint8_t *data, size_t len) {
|
15
|
+
return I2CDevice::read_bytes(a_register, data, len);
|
16
|
+
};
|
17
|
+
bool BMP280I2CComponent::read_byte_16(uint8_t a_register, uint16_t *data) {
|
18
|
+
return I2CDevice::read_byte_16(a_register, data);
|
19
|
+
};
|
20
|
+
|
21
|
+
void BMP280I2CComponent::dump_config() {
|
22
|
+
LOG_I2C_DEVICE(this);
|
23
|
+
BMP280Component::dump_config();
|
24
|
+
}
|
25
|
+
|
26
|
+
} // namespace bmp280_i2c
|
27
|
+
} // namespace esphome
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/components/bmp280_base/bmp280_base.h"
|
4
|
+
#include "esphome/components/i2c/i2c.h"
|
5
|
+
|
6
|
+
namespace esphome {
|
7
|
+
namespace bmp280_i2c {
|
8
|
+
|
9
|
+
static const char *const TAG = "bmp280_i2c.sensor";
|
10
|
+
|
11
|
+
/// This class implements support for the BMP280 Temperature+Pressure i2c sensor.
|
12
|
+
class BMP280I2CComponent : public esphome::bmp280_base::BMP280Component, public i2c::I2CDevice {
|
13
|
+
public:
|
14
|
+
bool read_byte(uint8_t a_register, uint8_t *data) override;
|
15
|
+
bool write_byte(uint8_t a_register, uint8_t data) override;
|
16
|
+
bool read_bytes(uint8_t a_register, uint8_t *data, size_t len) override;
|
17
|
+
bool read_byte_16(uint8_t a_register, uint16_t *data) override;
|
18
|
+
void dump_config() override;
|
19
|
+
};
|
20
|
+
|
21
|
+
} // namespace bmp280_i2c
|
22
|
+
} // namespace esphome
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
import esphome.config_validation as cv
|
3
|
+
from esphome.components import i2c
|
4
|
+
from ..bmp280_base import to_code_base, CONFIG_SCHEMA_BASE
|
5
|
+
|
6
|
+
AUTO_LOAD = ["bmp280_base"]
|
7
|
+
CODEOWNERS = ["@ademuri"]
|
8
|
+
DEPENDENCIES = ["i2c"]
|
9
|
+
|
10
|
+
bmp280_ns = cg.esphome_ns.namespace("bmp280_i2c")
|
11
|
+
BMP280I2CComponent = bmp280_ns.class_(
|
12
|
+
"BMP280I2CComponent", cg.PollingComponent, i2c.I2CDevice
|
13
|
+
)
|
14
|
+
|
15
|
+
CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(
|
16
|
+
i2c.i2c_device_schema(default_address=0x77)
|
17
|
+
).extend({cv.GenerateID(): cv.declare_id(BMP280I2CComponent)})
|
18
|
+
|
19
|
+
|
20
|
+
async def to_code(config):
|
21
|
+
var = await to_code_base(config)
|
22
|
+
await i2c.register_i2c_device(var, config)
|
File without changes
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#include <cstdint>
|
2
|
+
#include <cstddef>
|
3
|
+
|
4
|
+
#include "bmp280_spi.h"
|
5
|
+
#include <esphome/components/bmp280_base/bmp280_base.h>
|
6
|
+
|
7
|
+
namespace esphome {
|
8
|
+
namespace bmp280_spi {
|
9
|
+
|
10
|
+
uint8_t set_bit(uint8_t num, uint8_t position) {
|
11
|
+
uint8_t mask = 1 << position;
|
12
|
+
return num | mask;
|
13
|
+
}
|
14
|
+
|
15
|
+
uint8_t clear_bit(uint8_t num, uint8_t position) {
|
16
|
+
uint8_t mask = 1 << position;
|
17
|
+
return num & ~mask;
|
18
|
+
}
|
19
|
+
|
20
|
+
void BMP280SPIComponent::setup() {
|
21
|
+
this->spi_setup();
|
22
|
+
BMP280Component::setup();
|
23
|
+
};
|
24
|
+
|
25
|
+
// In SPI mode, only 7 bits of the register addresses are used; the MSB of register address is not used
|
26
|
+
// and replaced by a read/write bit (RW = ‘0’ for write and RW = ‘1’ for read).
|
27
|
+
// Example: address 0xF7 is accessed by using SPI register address 0x77. For write access, the byte
|
28
|
+
// 0x77 is transferred, for read access, the byte 0xF7 is transferred.
|
29
|
+
// https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf
|
30
|
+
|
31
|
+
bool BMP280SPIComponent::read_byte(uint8_t a_register, uint8_t *data) {
|
32
|
+
this->enable();
|
33
|
+
this->transfer_byte(set_bit(a_register, 7));
|
34
|
+
*data = this->transfer_byte(0);
|
35
|
+
this->disable();
|
36
|
+
return true;
|
37
|
+
}
|
38
|
+
|
39
|
+
bool BMP280SPIComponent::write_byte(uint8_t a_register, uint8_t data) {
|
40
|
+
this->enable();
|
41
|
+
this->transfer_byte(clear_bit(a_register, 7));
|
42
|
+
this->transfer_byte(data);
|
43
|
+
this->disable();
|
44
|
+
return true;
|
45
|
+
}
|
46
|
+
|
47
|
+
bool BMP280SPIComponent::read_bytes(uint8_t a_register, uint8_t *data, size_t len) {
|
48
|
+
this->enable();
|
49
|
+
this->transfer_byte(set_bit(a_register, 7));
|
50
|
+
this->read_array(data, len);
|
51
|
+
this->disable();
|
52
|
+
return true;
|
53
|
+
}
|
54
|
+
|
55
|
+
bool BMP280SPIComponent::read_byte_16(uint8_t a_register, uint16_t *data) {
|
56
|
+
this->enable();
|
57
|
+
this->transfer_byte(set_bit(a_register, 7));
|
58
|
+
((uint8_t *) data)[1] = this->transfer_byte(0);
|
59
|
+
((uint8_t *) data)[0] = this->transfer_byte(0);
|
60
|
+
this->disable();
|
61
|
+
return true;
|
62
|
+
}
|
63
|
+
|
64
|
+
} // namespace bmp280_spi
|
65
|
+
} // namespace esphome
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/components/bmp280_base/bmp280_base.h"
|
4
|
+
#include "esphome/components/spi/spi.h"
|
5
|
+
|
6
|
+
namespace esphome {
|
7
|
+
namespace bmp280_spi {
|
8
|
+
|
9
|
+
class BMP280SPIComponent : public esphome::bmp280_base::BMP280Component,
|
10
|
+
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
|
11
|
+
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_200KHZ> {
|
12
|
+
void setup() override;
|
13
|
+
bool read_byte(uint8_t a_register, uint8_t *data) override;
|
14
|
+
bool write_byte(uint8_t a_register, uint8_t data) override;
|
15
|
+
bool read_bytes(uint8_t a_register, uint8_t *data, size_t len) override;
|
16
|
+
bool read_byte_16(uint8_t a_register, uint16_t *data) override;
|
17
|
+
};
|
18
|
+
|
19
|
+
} // namespace bmp280_spi
|
20
|
+
} // namespace esphome
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
import esphome.config_validation as cv
|
3
|
+
from esphome.components import spi
|
4
|
+
from ..bmp280_base import to_code_base, CONFIG_SCHEMA_BASE
|
5
|
+
|
6
|
+
AUTO_LOAD = ["bmp280_base"]
|
7
|
+
CODEOWNERS = ["@ademuri"]
|
8
|
+
DEPENDENCIES = ["spi"]
|
9
|
+
|
10
|
+
bmp280_ns = cg.esphome_ns.namespace("bmp280_spi")
|
11
|
+
BMP280SPIComponent = bmp280_ns.class_(
|
12
|
+
"BMP280SPIComponent", cg.PollingComponent, spi.SPIDevice
|
13
|
+
)
|
14
|
+
|
15
|
+
CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(
|
16
|
+
spi.spi_device_schema(default_mode="mode3")
|
17
|
+
).extend({cv.GenerateID(): cv.declare_id(BMP280SPIComponent)})
|
18
|
+
|
19
|
+
|
20
|
+
async def to_code(config):
|
21
|
+
var = await to_code_base(config)
|
22
|
+
await spi.register_spi_device(var, config)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "captive_portal.h"
|
2
|
+
#ifdef USE_CAPTIVE_PORTAL
|
2
3
|
#include "esphome/core/log.h"
|
3
4
|
#include "esphome/core/application.h"
|
4
5
|
#include "esphome/components/wifi/wifi_component.h"
|
@@ -91,3 +92,4 @@ CaptivePortal *global_captive_portal = nullptr; // NOLINT(cppcoreguidelines-avo
|
|
91
92
|
|
92
93
|
} // namespace captive_portal
|
93
94
|
} // namespace esphome
|
95
|
+
#endif
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#pragma once
|
2
|
-
|
2
|
+
#include "esphome/core/defines.h"
|
3
|
+
#ifdef USE_CAPTIVE_PORTAL
|
3
4
|
#include <memory>
|
4
5
|
#ifdef USE_ARDUINO
|
5
6
|
#include <DNSServer.h>
|
@@ -71,3 +72,4 @@ extern CaptivePortal *global_captive_portal; // NOLINT(cppcoreguidelines-avoid-
|
|
71
72
|
|
72
73
|
} // namespace captive_portal
|
73
74
|
} // namespace esphome
|
75
|
+
#endif
|
@@ -0,0 +1,67 @@
|
|
1
|
+
from esphome import pins
|
2
|
+
import esphome.codegen as cg
|
3
|
+
from esphome.components import i2c
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import (
|
6
|
+
CONF_ID,
|
7
|
+
CONF_INPUT,
|
8
|
+
CONF_INVERTED,
|
9
|
+
CONF_MODE,
|
10
|
+
CONF_NUMBER,
|
11
|
+
CONF_OUTPUT,
|
12
|
+
CONF_RESTORE_VALUE,
|
13
|
+
)
|
14
|
+
|
15
|
+
CODEOWNERS = ["@jesterret"]
|
16
|
+
DEPENDENCIES = ["i2c"]
|
17
|
+
MULTI_CONF = True
|
18
|
+
ch422g_ns = cg.esphome_ns.namespace("ch422g")
|
19
|
+
|
20
|
+
CH422GComponent = ch422g_ns.class_("CH422GComponent", cg.Component, i2c.I2CDevice)
|
21
|
+
CH422GGPIOPin = ch422g_ns.class_(
|
22
|
+
"CH422GGPIOPin", cg.GPIOPin, cg.Parented.template(CH422GComponent)
|
23
|
+
)
|
24
|
+
|
25
|
+
CONF_CH422G = "ch422g"
|
26
|
+
CONFIG_SCHEMA = (
|
27
|
+
cv.Schema(
|
28
|
+
{
|
29
|
+
cv.Required(CONF_ID): cv.declare_id(CH422GComponent),
|
30
|
+
cv.Optional(CONF_RESTORE_VALUE, default=False): cv.boolean,
|
31
|
+
}
|
32
|
+
)
|
33
|
+
.extend(cv.COMPONENT_SCHEMA)
|
34
|
+
.extend(i2c.i2c_device_schema(0x24))
|
35
|
+
)
|
36
|
+
|
37
|
+
|
38
|
+
async def to_code(config):
|
39
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
40
|
+
cg.add(var.set_restore_value(config[CONF_RESTORE_VALUE]))
|
41
|
+
await cg.register_component(var, config)
|
42
|
+
await i2c.register_i2c_device(var, config)
|
43
|
+
|
44
|
+
|
45
|
+
CH422G_PIN_SCHEMA = pins.gpio_base_schema(
|
46
|
+
CH422GGPIOPin,
|
47
|
+
cv.int_range(min=0, max=7),
|
48
|
+
modes=[CONF_INPUT, CONF_OUTPUT],
|
49
|
+
).extend(
|
50
|
+
{
|
51
|
+
cv.Required(CONF_CH422G): cv.use_id(CH422GComponent),
|
52
|
+
}
|
53
|
+
)
|
54
|
+
|
55
|
+
|
56
|
+
@pins.PIN_SCHEMA_REGISTRY.register(CONF_CH422G, CH422G_PIN_SCHEMA)
|
57
|
+
async def ch422g_pin_to_code(config):
|
58
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
59
|
+
parent = await cg.get_variable(config[CONF_CH422G])
|
60
|
+
|
61
|
+
cg.add(var.set_parent(parent))
|
62
|
+
|
63
|
+
num = config[CONF_NUMBER]
|
64
|
+
cg.add(var.set_pin(num))
|
65
|
+
cg.add(var.set_inverted(config[CONF_INVERTED]))
|
66
|
+
cg.add(var.set_flags(pins.gpio_flags_expr(config[CONF_MODE])))
|
67
|
+
return var
|