esphome 2024.9.1__py3-none-any.whl → 2024.10.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/components/aic3204/__init__.py +0 -0
- esphome/components/aic3204/aic3204.cpp +173 -0
- esphome/components/aic3204/aic3204.h +88 -0
- esphome/components/aic3204/audio_dac.py +52 -0
- esphome/components/aic3204/automation.h +23 -0
- esphome/components/alarm_control_panel/__init__.py +3 -4
- esphome/components/animation/__init__.py +16 -12
- esphome/components/api/api_connection.cpp +2 -0
- esphome/components/api/api_connection.h +3 -1
- esphome/components/api/api_frame_helper.cpp +2 -1
- esphome/components/api/api_frame_helper.h +2 -1
- esphome/components/api/api_server.cpp +2 -0
- esphome/components/api/api_server.h +3 -1
- esphome/components/api/custom_api_device.h +3 -2
- esphome/components/api/homeassistant_service.h +4 -3
- esphome/components/api/list_entities.cpp +2 -0
- esphome/components/api/list_entities.h +3 -2
- esphome/components/api/subscribe_state.cpp +2 -0
- esphome/components/api/subscribe_state.h +3 -2
- esphome/components/audio_dac/__init__.py +57 -0
- esphome/components/audio_dac/audio_dac.h +23 -0
- esphome/components/audio_dac/automation.h +43 -0
- esphome/components/bang_bang/bang_bang_climate.cpp +5 -2
- esphome/components/bedjet/bedjet_codec.cpp +4 -2
- esphome/components/binary_sensor/__init__.py +3 -4
- esphome/components/bl0906/sensor.py +3 -2
- esphome/components/button/__init__.py +3 -4
- esphome/components/ch422g/__init__.py +26 -17
- esphome/components/ch422g/ch422g.cpp +66 -49
- esphome/components/ch422g/ch422g.h +17 -19
- esphome/components/climate/__init__.py +3 -4
- esphome/components/cover/__init__.py +4 -5
- esphome/components/cse7766/cse7766.cpp +12 -1
- esphome/components/cse7766/cse7766.h +4 -0
- esphome/components/cse7766/sensor.py +13 -1
- esphome/components/cst816/touchscreen/__init__.py +7 -4
- esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +20 -19
- esphome/components/cst816/touchscreen/cst816_touchscreen.h +2 -0
- esphome/components/datetime/__init__.py +21 -14
- esphome/components/datetime/datetime_base.h +8 -1
- esphome/components/datetime/datetime_entity.cpp +2 -0
- esphome/components/datetime/datetime_entity.h +2 -0
- esphome/components/datetime/time_entity.cpp +2 -0
- esphome/components/datetime/time_entity.h +2 -0
- esphome/components/esp32/__init__.py +20 -4
- esphome/components/esp32_improv/__init__.py +82 -1
- esphome/components/esp32_improv/automation.h +72 -0
- esphome/components/esp32_improv/esp32_improv_component.cpp +13 -5
- esphome/components/esp32_improv/esp32_improv_component.h +15 -0
- esphome/components/ethernet/__init__.py +5 -0
- esphome/components/ethernet/ethernet_component.cpp +13 -0
- esphome/components/ethernet/ethernet_component.h +1 -0
- esphome/components/event/__init__.py +20 -12
- esphome/components/fan/__init__.py +3 -4
- esphome/components/gp2y1010au0f/__init__.py +0 -0
- esphome/components/gp2y1010au0f/gp2y1010au0f.cpp +67 -0
- esphome/components/gp2y1010au0f/gp2y1010au0f.h +52 -0
- esphome/components/gp2y1010au0f/sensor.py +61 -0
- esphome/components/gpio_expander/__init__.py +0 -0
- esphome/components/gpio_expander/cached_gpio.h +38 -0
- esphome/components/grove_gas_mc_v2/__init__.py +0 -0
- esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.cpp +88 -0
- esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.h +39 -0
- esphome/components/grove_gas_mc_v2/sensor.py +77 -0
- esphome/components/haier/climate.py +4 -3
- esphome/components/haier/haier_base.cpp +63 -8
- esphome/components/haier/haier_base.h +29 -3
- esphome/components/haier/hon_climate.cpp +122 -65
- esphome/components/haier/hon_climate.h +18 -2
- esphome/components/haier/smartair2_climate.cpp +21 -21
- esphome/components/haier/switch/__init__.py +91 -0
- esphome/components/haier/switch/beeper.cpp +14 -0
- esphome/components/haier/switch/beeper.h +18 -0
- esphome/components/haier/switch/display.cpp +14 -0
- esphome/components/haier/switch/display.h +18 -0
- esphome/components/haier/switch/health_mode.cpp +14 -0
- esphome/components/haier/switch/health_mode.h +18 -0
- esphome/components/haier/switch/quiet_mode.cpp +14 -0
- esphome/components/haier/switch/quiet_mode.h +18 -0
- esphome/components/hmac_md5/hmac_md5.cpp +2 -0
- esphome/components/hmac_md5/hmac_md5.h +2 -1
- esphome/components/i2s_audio/speaker/__init__.py +19 -0
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
- esphome/components/ili9xxx/ili9xxx_display.h +1 -0
- esphome/components/image/__init__.py +12 -12
- esphome/components/image/image.cpp +44 -0
- esphome/components/image/image.h +17 -2
- esphome/components/inkplate6/display.py +2 -0
- esphome/components/inkplate6/inkplate.h +30 -2
- esphome/components/light/__init__.py +3 -4
- esphome/components/lock/__init__.py +3 -4
- esphome/components/lvgl/__init__.py +16 -5
- esphome/components/lvgl/defines.py +1 -0
- esphome/components/lvgl/hello_world.py +64 -0
- esphome/components/lvgl/lv_validation.py +159 -3
- esphome/components/lvgl/lvgl_esphome.cpp +0 -43
- esphome/components/lvgl/lvgl_esphome.h +0 -4
- esphome/components/lvgl/styles.py +3 -2
- esphome/components/lvgl/text/__init__.py +3 -3
- esphome/components/lvgl/widgets/__init__.py +2 -0
- esphome/components/lvgl/widgets/animimg.py +3 -4
- esphome/components/lvgl/widgets/dropdown.py +5 -1
- esphome/components/lvgl/widgets/meter.py +16 -11
- esphome/components/md5/__init__.py +6 -0
- esphome/components/md5/md5.cpp +2 -0
- esphome/components/md5/md5.h +2 -0
- esphome/components/micro_wake_word/__init__.py +7 -0
- esphome/components/mics_4514/sensor.py +11 -26
- esphome/components/modbus_controller/__init__.py +7 -5
- esphome/components/modbus_controller/binary_sensor/__init__.py +6 -6
- esphome/components/modbus_controller/number/__init__.py +5 -6
- esphome/components/modbus_controller/output/__init__.py +10 -14
- esphome/components/modbus_controller/select/__init__.py +1 -1
- esphome/components/modbus_controller/sensor/__init__.py +7 -7
- esphome/components/modbus_controller/switch/__init__.py +6 -7
- esphome/components/modbus_controller/text_sensor/__init__.py +8 -9
- esphome/components/mqtt/__init__.py +3 -0
- esphome/components/mqtt/mqtt_client.cpp +2 -0
- esphome/components/mqtt/mqtt_client.h +2 -0
- esphome/components/nau7802/__init__.py +0 -0
- esphome/components/nau7802/nau7802.cpp +323 -0
- esphome/components/nau7802/nau7802.h +121 -0
- esphome/components/nau7802/sensor.py +134 -0
- esphome/components/nextion/base_component.py +1 -0
- esphome/components/nextion/display.py +4 -0
- esphome/components/nextion/nextion.cpp +19 -4
- esphome/components/nextion/nextion.h +16 -0
- esphome/components/npi19/__init__.py +0 -0
- esphome/components/npi19/npi19.cpp +111 -0
- esphome/components/npi19/npi19.h +30 -0
- esphome/components/npi19/sensor.py +52 -0
- esphome/components/number/__init__.py +3 -5
- esphome/components/online_image/__init__.py +1 -1
- esphome/components/online_image/online_image.h +1 -2
- esphome/components/opentherm/__init__.py +57 -0
- esphome/components/opentherm/hub.cpp +277 -0
- esphome/components/opentherm/hub.h +110 -0
- esphome/components/opentherm/opentherm.cpp +568 -0
- esphome/components/opentherm/opentherm.h +347 -0
- esphome/components/pulse_counter/pulse_counter_sensor.cpp +8 -1
- esphome/components/pulse_counter/pulse_counter_sensor.h +1 -0
- esphome/components/radon_eye_ble/radon_eye_listener.cpp +10 -3
- esphome/components/remote_transmitter/__init__.py +18 -2
- esphome/components/remote_transmitter/remote_transmitter.h +6 -0
- esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +2 -0
- esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +2 -0
- esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +2 -0
- esphome/components/rp2040/__init__.py +13 -14
- esphome/components/select/__init__.py +3 -4
- esphome/components/sensor/__init__.py +3 -4
- esphome/components/shelly_dimmer/shelly_dimmer.cpp +32 -32
- esphome/components/shelly_dimmer/shelly_dimmer.h +2 -0
- esphome/components/st7701s/st7701s.cpp +21 -8
- esphome/components/st7701s/st7701s.h +2 -0
- esphome/components/switch/__init__.py +3 -4
- esphome/components/tca9555/__init__.py +72 -0
- esphome/components/tca9555/tca9555.cpp +140 -0
- esphome/components/tca9555/tca9555.h +64 -0
- esphome/components/tcs34725/tcs34725.cpp +62 -64
- esphome/components/tem3200/__init__.py +0 -0
- esphome/components/tem3200/sensor.py +55 -0
- esphome/components/tem3200/tem3200.cpp +151 -0
- esphome/components/tem3200/tem3200.h +30 -0
- esphome/components/template/binary_sensor/__init__.py +19 -6
- esphome/components/text/__init__.py +3 -4
- esphome/components/text_sensor/__init__.py +3 -4
- esphome/components/thermostat/climate.py +11 -9
- esphome/components/thermostat/thermostat_climate.cpp +21 -15
- esphome/components/tm1638/binary_sensor/__init__.py +3 -2
- esphome/components/tm1638/display.py +5 -5
- esphome/components/tm1638/output/__init__.py +3 -2
- esphome/components/tm1638/switch/__init__.py +3 -2
- esphome/components/touchscreen/touchscreen.cpp +2 -2
- esphome/components/update/__init__.py +3 -4
- esphome/components/valve/__init__.py +3 -4
- esphome/components/web_server/__init__.py +78 -22
- esphome/components/web_server/server_index_v3.h +3989 -3979
- esphome/components/web_server/web_server.cpp +219 -34
- esphome/components/web_server/web_server.h +10 -1
- esphome/components/wifi/wifi_component_esp_idf.cpp +4 -5
- esphome/config_validation.py +1 -0
- esphome/const.py +12 -2
- esphome/core/defines.h +4 -2
- esphome/core/helpers.cpp +46 -10
- esphome/core/helpers.h +8 -0
- esphome/core/ring_buffer.cpp +12 -2
- esphome/core/ring_buffer.h +3 -0
- esphome/voluptuous_schema.py +3 -1
- esphome/wizard.py +0 -3
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/METADATA +5 -3
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/RECORD +196 -147
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/LICENSE +0 -0
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/WHEEL +0 -0
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/core/automation.h"
|
5
|
+
#include "esphome/components/sensor/sensor.h"
|
6
|
+
#include "esphome/components/i2c/i2c.h"
|
7
|
+
|
8
|
+
#include <cinttypes>
|
9
|
+
|
10
|
+
namespace esphome {
|
11
|
+
namespace nau7802 {
|
12
|
+
|
13
|
+
enum NAU7802Gain {
|
14
|
+
NAU7802_GAIN_128 = 0b111,
|
15
|
+
NAU7802_GAIN_64 = 0b110,
|
16
|
+
NAU7802_GAIN_32 = 0b101,
|
17
|
+
NAU7802_GAIN_16 = 0b100,
|
18
|
+
NAU7802_GAIN_8 = 0b011,
|
19
|
+
NAU7802_GAIN_4 = 0b010,
|
20
|
+
NAU7802_GAIN_2 = 0b001,
|
21
|
+
NAU7802_GAIN_1 = 0b000,
|
22
|
+
};
|
23
|
+
|
24
|
+
enum NAU7802SPS {
|
25
|
+
NAU7802_SPS_320 = 0b111,
|
26
|
+
NAU7802_SPS_80 = 0b011,
|
27
|
+
NAU7802_SPS_40 = 0b010,
|
28
|
+
NAU7802_SPS_20 = 0b001,
|
29
|
+
NAU7802_SPS_10 = 0b000,
|
30
|
+
};
|
31
|
+
|
32
|
+
enum NAU7802LDO {
|
33
|
+
NAU7802_LDO_2V4 = 0b111,
|
34
|
+
NAU7802_LDO_2V7 = 0b110,
|
35
|
+
NAU7802_LDO_3V0 = 0b101,
|
36
|
+
NAU7802_LDO_3V3 = 0b100,
|
37
|
+
NAU7802_LDO_3V6 = 0b011,
|
38
|
+
NAU7802_LDO_3V9 = 0b010,
|
39
|
+
NAU7802_LDO_4V2 = 0b001,
|
40
|
+
NAU7802_LDO_4V5 = 0b000,
|
41
|
+
// Never write this to a register
|
42
|
+
NAU7802_LDO_EXTERNAL = 0b1000,
|
43
|
+
};
|
44
|
+
|
45
|
+
enum NAU7802CalibrationModes {
|
46
|
+
NAU7802_CALIBRATE_EXTERNAL_OFFSET = 0b10,
|
47
|
+
NAU7802_CALIBRATE_INTERNAL_OFFSET = 0b00,
|
48
|
+
NAU7802_CALIBRATE_GAIN = 0b11,
|
49
|
+
};
|
50
|
+
|
51
|
+
class NAU7802Sensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
52
|
+
public:
|
53
|
+
void set_samples_per_second(NAU7802SPS sps) { this->sps_ = sps; }
|
54
|
+
void set_ldo_voltage(NAU7802LDO ldo) { this->ldo_ = ldo; }
|
55
|
+
void set_gain(NAU7802Gain gain) { this->gain_ = gain; }
|
56
|
+
void set_gain_calibration(float gain_calibration) { this->gain_calibration_ = gain_calibration; }
|
57
|
+
void set_offset_calibration(int32_t offset_calibration) { this->offset_calibration_ = offset_calibration; }
|
58
|
+
bool calibrate_external_offset() { return this->calibrate_(NAU7802_CALIBRATE_EXTERNAL_OFFSET); }
|
59
|
+
bool calibrate_internal_offset() { return this->calibrate_(NAU7802_CALIBRATE_INTERNAL_OFFSET); }
|
60
|
+
bool calibrate_gain() { return this->calibrate_(NAU7802_CALIBRATE_GAIN); }
|
61
|
+
|
62
|
+
void setup() override;
|
63
|
+
void loop() override;
|
64
|
+
bool can_proceed() override;
|
65
|
+
void dump_config() override;
|
66
|
+
float get_setup_priority() const override;
|
67
|
+
void update() override;
|
68
|
+
|
69
|
+
protected:
|
70
|
+
//
|
71
|
+
// Internal state
|
72
|
+
//
|
73
|
+
enum class CalibrationState : uint8_t {
|
74
|
+
INACTIVE,
|
75
|
+
OFFSET,
|
76
|
+
GAIN,
|
77
|
+
} state_{CalibrationState::INACTIVE};
|
78
|
+
|
79
|
+
float gain_calibration_;
|
80
|
+
int32_t offset_calibration_;
|
81
|
+
bool offset_calibration_failed_ = false;
|
82
|
+
bool gain_calibration_failed_ = false;
|
83
|
+
bool setup_complete_ = false;
|
84
|
+
|
85
|
+
//
|
86
|
+
// Config values
|
87
|
+
//
|
88
|
+
NAU7802LDO ldo_;
|
89
|
+
NAU7802SPS sps_;
|
90
|
+
NAU7802Gain gain_;
|
91
|
+
|
92
|
+
//
|
93
|
+
// Internal Methods
|
94
|
+
//
|
95
|
+
bool calibrate_(enum NAU7802CalibrationModes mode);
|
96
|
+
void complete_setup_();
|
97
|
+
void write_value_(uint8_t start_reg, size_t size, int32_t value);
|
98
|
+
int32_t read_value_(uint8_t start_reg, size_t size);
|
99
|
+
bool is_data_ready_();
|
100
|
+
void set_calibration_failure_(bool failed);
|
101
|
+
};
|
102
|
+
|
103
|
+
template<typename... Ts>
|
104
|
+
class NAU7802CalbrateExternalOffsetAction : public Action<Ts...>, public Parented<NAU7802Sensor> {
|
105
|
+
public:
|
106
|
+
void play(Ts... x) override { this->parent_->calibrate_external_offset(); }
|
107
|
+
};
|
108
|
+
|
109
|
+
template<typename... Ts>
|
110
|
+
class NAU7802CalbrateInternalOffsetAction : public Action<Ts...>, public Parented<NAU7802Sensor> {
|
111
|
+
public:
|
112
|
+
void play(Ts... x) override { this->parent_->calibrate_internal_offset(); }
|
113
|
+
};
|
114
|
+
|
115
|
+
template<typename... Ts> class NAU7802CalbrateGainAction : public Action<Ts...>, public Parented<NAU7802Sensor> {
|
116
|
+
public:
|
117
|
+
void play(Ts... x) override { this->parent_->calibrate_gain(); }
|
118
|
+
};
|
119
|
+
|
120
|
+
} // namespace nau7802
|
121
|
+
} // namespace esphome
|
@@ -0,0 +1,134 @@
|
|
1
|
+
from esphome import automation
|
2
|
+
from esphome.automation import maybe_simple_id
|
3
|
+
import esphome.codegen as cg
|
4
|
+
from esphome.components import i2c, sensor
|
5
|
+
import esphome.config_validation as cv
|
6
|
+
from esphome.const import CONF_GAIN, CONF_ID, ICON_SCALE, STATE_CLASS_MEASUREMENT
|
7
|
+
|
8
|
+
CODEOWNERS = ["@cujomalainey"]
|
9
|
+
DEPENDENCIES = ["i2c"]
|
10
|
+
|
11
|
+
CONF_GAIN_CALIBRATION = "gain_calibration"
|
12
|
+
CONF_OFFSET_CALIBRATION = "offset_calibration"
|
13
|
+
CONF_LDO_VOLTAGE = "ldo_voltage"
|
14
|
+
CONF_SAMPLES_PER_SECOND = "samples_per_second"
|
15
|
+
|
16
|
+
nau7802_ns = cg.esphome_ns.namespace("nau7802")
|
17
|
+
NAU7802Sensor = nau7802_ns.class_(
|
18
|
+
"NAU7802Sensor", sensor.Sensor, cg.PollingComponent, i2c.I2CDevice
|
19
|
+
)
|
20
|
+
NAU7802CalbrateExternalOffsetAction = nau7802_ns.class_(
|
21
|
+
"NAU7802CalbrateExternalOffsetAction",
|
22
|
+
automation.Action,
|
23
|
+
cg.Parented.template(NAU7802Sensor),
|
24
|
+
)
|
25
|
+
NAU7802CalbrateInternalOffsetAction = nau7802_ns.class_(
|
26
|
+
"NAU7802CalbrateInternalOffsetAction",
|
27
|
+
automation.Action,
|
28
|
+
cg.Parented.template(NAU7802Sensor),
|
29
|
+
)
|
30
|
+
NAU7802CalbrateGainAction = nau7802_ns.class_(
|
31
|
+
"NAU7802CalbrateGainAction", automation.Action, cg.Parented.template(NAU7802Sensor)
|
32
|
+
)
|
33
|
+
|
34
|
+
NAU7802Gain = nau7802_ns.enum("NAU7802Gain")
|
35
|
+
GAINS = {
|
36
|
+
128: NAU7802Gain.NAU7802_GAIN_128,
|
37
|
+
64: NAU7802Gain.NAU7802_GAIN_64,
|
38
|
+
32: NAU7802Gain.NAU7802_GAIN_32,
|
39
|
+
16: NAU7802Gain.NAU7802_GAIN_16,
|
40
|
+
8: NAU7802Gain.NAU7802_GAIN_8,
|
41
|
+
4: NAU7802Gain.NAU7802_GAIN_4,
|
42
|
+
2: NAU7802Gain.NAU7802_GAIN_2,
|
43
|
+
1: NAU7802Gain.NAU7802_GAIN_1,
|
44
|
+
}
|
45
|
+
|
46
|
+
NAU7802SPS = nau7802_ns.enum("NAU7802SPS")
|
47
|
+
SAMPLES_PER_SECOND = {
|
48
|
+
320: NAU7802SPS.NAU7802_SPS_320,
|
49
|
+
80: NAU7802SPS.NAU7802_SPS_80,
|
50
|
+
40: NAU7802SPS.NAU7802_SPS_40,
|
51
|
+
20: NAU7802SPS.NAU7802_SPS_20,
|
52
|
+
10: NAU7802SPS.NAU7802_SPS_10,
|
53
|
+
}
|
54
|
+
|
55
|
+
NAU7802LDO = nau7802_ns.enum("NAU7802LDO")
|
56
|
+
LDO = {
|
57
|
+
"2.4V": NAU7802LDO.NAU7802_LDO_2V4,
|
58
|
+
"2.7V": NAU7802LDO.NAU7802_LDO_2V7,
|
59
|
+
"3.0V": NAU7802LDO.NAU7802_LDO_3V0,
|
60
|
+
"3.3V": NAU7802LDO.NAU7802_LDO_3V3,
|
61
|
+
"3.6V": NAU7802LDO.NAU7802_LDO_3V6,
|
62
|
+
"3.9V": NAU7802LDO.NAU7802_LDO_3V9,
|
63
|
+
"4.2V": NAU7802LDO.NAU7802_LDO_4V2,
|
64
|
+
"4.5V": NAU7802LDO.NAU7802_LDO_4V5,
|
65
|
+
"EXTERNAL": NAU7802LDO.NAU7802_LDO_EXTERNAL,
|
66
|
+
"EXT": NAU7802LDO.NAU7802_LDO_EXTERNAL,
|
67
|
+
}
|
68
|
+
|
69
|
+
CONFIG_SCHEMA = (
|
70
|
+
sensor.sensor_schema(
|
71
|
+
NAU7802Sensor,
|
72
|
+
icon=ICON_SCALE,
|
73
|
+
accuracy_decimals=0,
|
74
|
+
state_class=STATE_CLASS_MEASUREMENT,
|
75
|
+
)
|
76
|
+
.extend(
|
77
|
+
{
|
78
|
+
cv.Optional(CONF_LDO_VOLTAGE, default="3.0V"): cv.enum(LDO, upper=True),
|
79
|
+
cv.Optional(CONF_SAMPLES_PER_SECOND, default=10): cv.enum(
|
80
|
+
SAMPLES_PER_SECOND, int=True
|
81
|
+
),
|
82
|
+
cv.Optional(CONF_GAIN, default=128): cv.enum(GAINS, int=True),
|
83
|
+
cv.Optional(CONF_OFFSET_CALIBRATION, default=0): cv.int_range(
|
84
|
+
min=-8388608, max=8388607
|
85
|
+
),
|
86
|
+
cv.Optional(CONF_GAIN_CALIBRATION, default=1.0): cv.float_range(
|
87
|
+
min=0, max=511.9999998807907
|
88
|
+
),
|
89
|
+
}
|
90
|
+
)
|
91
|
+
.extend(cv.polling_component_schema("60s"))
|
92
|
+
.extend(i2c.i2c_device_schema(0x2A))
|
93
|
+
)
|
94
|
+
|
95
|
+
|
96
|
+
async def to_code(config):
|
97
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
98
|
+
await cg.register_component(var, config)
|
99
|
+
await i2c.register_i2c_device(var, config)
|
100
|
+
await sensor.register_sensor(var, config)
|
101
|
+
|
102
|
+
cg.add(var.set_samples_per_second(config[CONF_SAMPLES_PER_SECOND]))
|
103
|
+
cg.add(var.set_ldo_voltage(config[CONF_LDO_VOLTAGE]))
|
104
|
+
cg.add(var.set_gain(config[CONF_GAIN]))
|
105
|
+
cg.add(var.set_gain_calibration(config[CONF_GAIN_CALIBRATION]))
|
106
|
+
cg.add(var.set_offset_calibration(config[CONF_OFFSET_CALIBRATION]))
|
107
|
+
|
108
|
+
|
109
|
+
NAU7802_CALIBRATE_SCHEMA = maybe_simple_id(
|
110
|
+
{
|
111
|
+
cv.GenerateID(CONF_ID): cv.use_id(NAU7802Sensor),
|
112
|
+
}
|
113
|
+
)
|
114
|
+
|
115
|
+
|
116
|
+
@automation.register_action(
|
117
|
+
"nau7802.calibrate_internal_offset",
|
118
|
+
NAU7802CalbrateInternalOffsetAction,
|
119
|
+
NAU7802_CALIBRATE_SCHEMA,
|
120
|
+
)
|
121
|
+
@automation.register_action(
|
122
|
+
"nau7802.calibrate_external_offset",
|
123
|
+
NAU7802CalbrateExternalOffsetAction,
|
124
|
+
NAU7802_CALIBRATE_SCHEMA,
|
125
|
+
)
|
126
|
+
@automation.register_action(
|
127
|
+
"nau7802.calibrate_gain",
|
128
|
+
NAU7802CalbrateGainAction,
|
129
|
+
NAU7802_CALIBRATE_SCHEMA,
|
130
|
+
)
|
131
|
+
async def nau7802_calibrate_to_code(config, action_id, template_arg, args):
|
132
|
+
var = cg.new_Pvariable(action_id, template_arg)
|
133
|
+
await cg.register_parented(var, config[CONF_ID])
|
134
|
+
return var
|
@@ -27,6 +27,7 @@ CONF_BACKGROUND_PRESSED_COLOR = "background_pressed_color"
|
|
27
27
|
CONF_FOREGROUND_PRESSED_COLOR = "foreground_pressed_color"
|
28
28
|
CONF_FONT_ID = "font_id"
|
29
29
|
CONF_EXIT_REPARSE_ON_START = "exit_reparse_on_start"
|
30
|
+
CONF_SKIP_CONNECTION_HANDSHAKE = "skip_connection_handshake"
|
30
31
|
|
31
32
|
|
32
33
|
def NextionName(value):
|
@@ -23,6 +23,7 @@ from .base_component import (
|
|
23
23
|
CONF_START_UP_PAGE,
|
24
24
|
CONF_AUTO_WAKE_ON_TOUCH,
|
25
25
|
CONF_EXIT_REPARSE_ON_START,
|
26
|
+
CONF_SKIP_CONNECTION_HANDSHAKE,
|
26
27
|
)
|
27
28
|
|
28
29
|
CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]
|
@@ -72,6 +73,7 @@ CONFIG_SCHEMA = (
|
|
72
73
|
cv.Optional(CONF_START_UP_PAGE): cv.uint8_t,
|
73
74
|
cv.Optional(CONF_AUTO_WAKE_ON_TOUCH, default=True): cv.boolean,
|
74
75
|
cv.Optional(CONF_EXIT_REPARSE_ON_START, default=False): cv.boolean,
|
76
|
+
cv.Optional(CONF_SKIP_CONNECTION_HANDSHAKE, default=False): cv.boolean,
|
75
77
|
}
|
76
78
|
)
|
77
79
|
.extend(cv.polling_component_schema("5s"))
|
@@ -118,6 +120,8 @@ async def to_code(config):
|
|
118
120
|
|
119
121
|
cg.add(var.set_exit_reparse_on_start_internal(config[CONF_EXIT_REPARSE_ON_START]))
|
120
122
|
|
123
|
+
cg.add(var.set_skip_connection_handshake(config[CONF_SKIP_CONNECTION_HANDSHAKE]))
|
124
|
+
|
121
125
|
await display.register_display(var, config)
|
122
126
|
|
123
127
|
for conf in config.get(CONF_ON_SETUP, []):
|
@@ -43,6 +43,16 @@ bool Nextion::check_connect_() {
|
|
43
43
|
if (this->get_is_connected_())
|
44
44
|
return true;
|
45
45
|
|
46
|
+
// Check if the handshake should be skipped for the Nextion connection
|
47
|
+
if (this->skip_connection_handshake_) {
|
48
|
+
// Log the connection status without handshake
|
49
|
+
ESP_LOGW(TAG, "Nextion display set as connected without performing handshake");
|
50
|
+
// Set the connection status to true
|
51
|
+
this->is_connected_ = true;
|
52
|
+
// Return true indicating the connection is set
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
|
46
56
|
if (this->comok_sent_ == 0) {
|
47
57
|
this->reset_(false);
|
48
58
|
|
@@ -126,10 +136,14 @@ void Nextion::reset_(bool reset_nextion) {
|
|
126
136
|
|
127
137
|
void Nextion::dump_config() {
|
128
138
|
ESP_LOGCONFIG(TAG, "Nextion:");
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
139
|
+
if (this->skip_connection_handshake_) {
|
140
|
+
ESP_LOGCONFIG(TAG, " Skip handshake: %s", YESNO(this->skip_connection_handshake_));
|
141
|
+
} else {
|
142
|
+
ESP_LOGCONFIG(TAG, " Device Model: %s", this->device_model_.c_str());
|
143
|
+
ESP_LOGCONFIG(TAG, " Firmware Version: %s", this->firmware_version_.c_str());
|
144
|
+
ESP_LOGCONFIG(TAG, " Serial Number: %s", this->serial_number_.c_str());
|
145
|
+
ESP_LOGCONFIG(TAG, " Flash Size: %s", this->flash_size_.c_str());
|
146
|
+
}
|
133
147
|
ESP_LOGCONFIG(TAG, " Wake On Touch: %s", YESNO(this->auto_wake_on_touch_));
|
134
148
|
ESP_LOGCONFIG(TAG, " Exit reparse: %s", YESNO(this->exit_reparse_on_start_));
|
135
149
|
|
@@ -262,6 +276,7 @@ void Nextion::loop() {
|
|
262
276
|
this->goto_page(this->start_up_page_);
|
263
277
|
}
|
264
278
|
|
279
|
+
// This could probably be removed from the loop area, as those are redundant.
|
265
280
|
this->set_auto_wake_on_touch(this->auto_wake_on_touch_);
|
266
281
|
this->set_exit_reparse_on_start(this->exit_reparse_on_start_);
|
267
282
|
|
@@ -926,6 +926,21 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
926
926
|
*/
|
927
927
|
void set_exit_reparse_on_start(bool exit_reparse);
|
928
928
|
|
929
|
+
/**
|
930
|
+
* Sets whether the Nextion display should skip the connection handshake process.
|
931
|
+
* @param skip_handshake True or false. When skip_connection_handshake is true,
|
932
|
+
* the connection will be established without performing the handshake.
|
933
|
+
* This can be useful when using Nextion Simulator.
|
934
|
+
*
|
935
|
+
* Example:
|
936
|
+
* ```cpp
|
937
|
+
* it.set_skip_connection_handshake(true);
|
938
|
+
* ```
|
939
|
+
*
|
940
|
+
* When set to true, the display will be marked as connected without performing a handshake.
|
941
|
+
*/
|
942
|
+
void set_skip_connection_handshake(bool skip_handshake) { this->skip_connection_handshake_ = skip_handshake; }
|
943
|
+
|
929
944
|
/**
|
930
945
|
* Sets Nextion mode between sleep and awake
|
931
946
|
* @param True or false. Sleep=true to enter sleep mode or sleep=false to exit sleep mode.
|
@@ -1221,6 +1236,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1221
1236
|
int16_t start_up_page_ = -1;
|
1222
1237
|
bool auto_wake_on_touch_ = true;
|
1223
1238
|
bool exit_reparse_on_start_ = false;
|
1239
|
+
bool skip_connection_handshake_ = false;
|
1224
1240
|
|
1225
1241
|
/**
|
1226
1242
|
* Manually send a raw command to the display and don't wait for an acknowledgement packet.
|
File without changes
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#include "npi19.h"
|
2
|
+
#include "esphome/core/log.h"
|
3
|
+
#include "esphome/core/helpers.h"
|
4
|
+
#include "esphome/core/hal.h"
|
5
|
+
|
6
|
+
namespace esphome {
|
7
|
+
namespace npi19 {
|
8
|
+
|
9
|
+
static const char *const TAG = "npi19";
|
10
|
+
|
11
|
+
static const uint8_t READ_COMMAND = 0xAC;
|
12
|
+
|
13
|
+
void NPI19Component::setup() {
|
14
|
+
ESP_LOGCONFIG(TAG, "Setting up NPI19...");
|
15
|
+
|
16
|
+
uint16_t raw_temperature(0);
|
17
|
+
uint16_t raw_pressure(0);
|
18
|
+
i2c::ErrorCode err = this->read_(raw_temperature, raw_pressure);
|
19
|
+
if (err != i2c::ERROR_OK) {
|
20
|
+
ESP_LOGCONFIG(TAG, " I2C Communication Failed...");
|
21
|
+
this->mark_failed();
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
25
|
+
ESP_LOGCONFIG(TAG, " Success...");
|
26
|
+
}
|
27
|
+
|
28
|
+
void NPI19Component::dump_config() {
|
29
|
+
ESP_LOGCONFIG(TAG, "NPI19:");
|
30
|
+
LOG_I2C_DEVICE(this);
|
31
|
+
LOG_UPDATE_INTERVAL(this);
|
32
|
+
LOG_SENSOR(" ", "Raw Pressure", this->raw_pressure_sensor_);
|
33
|
+
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
34
|
+
}
|
35
|
+
|
36
|
+
float NPI19Component::get_setup_priority() const { return setup_priority::DATA; }
|
37
|
+
|
38
|
+
i2c::ErrorCode NPI19Component::read_(uint16_t &raw_temperature, uint16_t &raw_pressure) {
|
39
|
+
// initiate data read from device
|
40
|
+
i2c::ErrorCode w_err = write(&READ_COMMAND, sizeof(READ_COMMAND), true);
|
41
|
+
if (w_err != i2c::ERROR_OK) {
|
42
|
+
return w_err;
|
43
|
+
}
|
44
|
+
|
45
|
+
// read 4 bytes from senesor
|
46
|
+
uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
|
47
|
+
i2c::ErrorCode r_err = this->read(response, 4);
|
48
|
+
|
49
|
+
if (r_err != i2c::ERROR_OK) {
|
50
|
+
return r_err;
|
51
|
+
}
|
52
|
+
|
53
|
+
// extract top 6 bits of first byte and all bits of second byte for pressure
|
54
|
+
raw_pressure = ((response[0] & 0x3F) << 8) | response[1];
|
55
|
+
|
56
|
+
// extract all bytes of 3rd byte and top 3 bits of fourth byte for temperature
|
57
|
+
raw_temperature = (response[2] << 3) | ((response[3] & 0xE0) >> 5);
|
58
|
+
|
59
|
+
return i2c::ERROR_OK;
|
60
|
+
}
|
61
|
+
|
62
|
+
inline float convert_temperature(uint16_t raw_temperature) {
|
63
|
+
/*
|
64
|
+
* Correspondance with Amphenol confirmed the appropriate equation for computing temperature is:
|
65
|
+
* T (°C) =(((((Th*8)+Tl)/2048)*200)-50), where Th is the high (third) byte and Tl is the low (fourth) byte.
|
66
|
+
*
|
67
|
+
* Tl is actually the upper 3 bits of the fourth data byte; the first 5 (LSBs) must be masked out.
|
68
|
+
*
|
69
|
+
*
|
70
|
+
* The NPI-19 I2C has a temperature output, however the manufacturer does
|
71
|
+
* not specify its accuracy on the published datasheet. They indicate
|
72
|
+
* that the sensor should not be used as a calibrated temperature
|
73
|
+
* reading; it’s only intended for curve fitting data during
|
74
|
+
* compensation.
|
75
|
+
*/
|
76
|
+
const float temperature_bits_span = 2048;
|
77
|
+
const float temperature_max = 150;
|
78
|
+
const float temperature_min = -50;
|
79
|
+
const float temperature_span = temperature_max - temperature_min;
|
80
|
+
|
81
|
+
float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
|
82
|
+
|
83
|
+
return temperature;
|
84
|
+
}
|
85
|
+
|
86
|
+
void NPI19Component::update() {
|
87
|
+
uint16_t raw_temperature(0);
|
88
|
+
uint16_t raw_pressure(0);
|
89
|
+
|
90
|
+
i2c::ErrorCode err = this->read_(raw_temperature, raw_pressure);
|
91
|
+
|
92
|
+
if (err != i2c::ERROR_OK) {
|
93
|
+
ESP_LOGW(TAG, "I2C Communication Failed");
|
94
|
+
this->status_set_warning();
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
|
98
|
+
float temperature = convert_temperature(raw_temperature);
|
99
|
+
|
100
|
+
ESP_LOGD(TAG, "Got raw pressure=%d, temperature=%.1f°C", raw_pressure, temperature);
|
101
|
+
|
102
|
+
if (this->temperature_sensor_ != nullptr)
|
103
|
+
this->temperature_sensor_->publish_state(temperature);
|
104
|
+
if (this->raw_pressure_sensor_ != nullptr)
|
105
|
+
this->raw_pressure_sensor_->publish_state(raw_pressure);
|
106
|
+
|
107
|
+
this->status_clear_warning();
|
108
|
+
}
|
109
|
+
|
110
|
+
} // namespace npi19
|
111
|
+
} // namespace esphome
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/components/sensor/sensor.h"
|
5
|
+
#include "esphome/components/i2c/i2c.h"
|
6
|
+
|
7
|
+
namespace esphome {
|
8
|
+
namespace npi19 {
|
9
|
+
|
10
|
+
/// This class implements support for the npi19 pressure and temperature i2c sensors.
|
11
|
+
class NPI19Component : public PollingComponent, public i2c::I2CDevice {
|
12
|
+
public:
|
13
|
+
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
|
14
|
+
void set_raw_pressure_sensor(sensor::Sensor *raw_pressure_sensor) {
|
15
|
+
this->raw_pressure_sensor_ = raw_pressure_sensor;
|
16
|
+
}
|
17
|
+
|
18
|
+
float get_setup_priority() const override;
|
19
|
+
void setup() override;
|
20
|
+
void dump_config() override;
|
21
|
+
void update() override;
|
22
|
+
|
23
|
+
protected:
|
24
|
+
i2c::ErrorCode read_(uint16_t &raw_temperature, uint16_t &raw_pressure);
|
25
|
+
sensor::Sensor *temperature_sensor_{nullptr};
|
26
|
+
sensor::Sensor *raw_pressure_sensor_{nullptr};
|
27
|
+
};
|
28
|
+
|
29
|
+
} // namespace npi19
|
30
|
+
} // namespace esphome
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import i2c, sensor
|
3
|
+
import esphome.config_validation as cv
|
4
|
+
from esphome.const import (
|
5
|
+
CONF_ID,
|
6
|
+
CONF_TEMPERATURE,
|
7
|
+
DEVICE_CLASS_TEMPERATURE,
|
8
|
+
STATE_CLASS_MEASUREMENT,
|
9
|
+
UNIT_CELSIUS,
|
10
|
+
)
|
11
|
+
|
12
|
+
CODEOWNERS = ["@bakerkj"]
|
13
|
+
DEPENDENCIES = ["i2c"]
|
14
|
+
|
15
|
+
npi19_ns = cg.esphome_ns.namespace("npi19")
|
16
|
+
|
17
|
+
NPI19Component = npi19_ns.class_("NPI19Component", cg.PollingComponent, i2c.I2CDevice)
|
18
|
+
|
19
|
+
CONF_RAW_PRESSURE = "raw_pressure"
|
20
|
+
|
21
|
+
CONFIG_SCHEMA = (
|
22
|
+
cv.Schema(
|
23
|
+
{
|
24
|
+
cv.GenerateID(): cv.declare_id(NPI19Component),
|
25
|
+
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
26
|
+
unit_of_measurement=UNIT_CELSIUS,
|
27
|
+
accuracy_decimals=1,
|
28
|
+
device_class=DEVICE_CLASS_TEMPERATURE,
|
29
|
+
state_class=STATE_CLASS_MEASUREMENT,
|
30
|
+
),
|
31
|
+
cv.Optional(CONF_RAW_PRESSURE): sensor.sensor_schema(
|
32
|
+
accuracy_decimals=0, state_class=STATE_CLASS_MEASUREMENT
|
33
|
+
),
|
34
|
+
}
|
35
|
+
)
|
36
|
+
.extend(cv.polling_component_schema("60s"))
|
37
|
+
.extend(i2c.i2c_device_schema(0x28))
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
async def to_code(config):
|
42
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
43
|
+
await cg.register_component(var, config)
|
44
|
+
await i2c.register_i2c_device(var, config)
|
45
|
+
|
46
|
+
if temperature_config := config.get(CONF_TEMPERATURE):
|
47
|
+
sens = await sensor.new_sensor(temperature_config)
|
48
|
+
cg.add(var.set_temperature_sensor(sens))
|
49
|
+
|
50
|
+
if raw_pressure_config := config.get(CONF_RAW_PRESSURE):
|
51
|
+
sens = await sensor.new_sensor(raw_pressure_config)
|
52
|
+
cg.add(var.set_raw_pressure_sensor(sens))
|
@@ -18,7 +18,7 @@ from esphome.const import (
|
|
18
18
|
CONF_TRIGGER_ID,
|
19
19
|
CONF_UNIT_OF_MEASUREMENT,
|
20
20
|
CONF_VALUE,
|
21
|
-
|
21
|
+
CONF_WEB_SERVER,
|
22
22
|
DEVICE_CLASS_APPARENT_POWER,
|
23
23
|
DEVICE_CLASS_AQI,
|
24
24
|
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
|
@@ -254,10 +254,8 @@ async def setup_number_core_(
|
|
254
254
|
if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
|
255
255
|
mqtt_ = cg.new_Pvariable(mqtt_id, var)
|
256
256
|
await mqtt.register_mqtt_component(mqtt_, config)
|
257
|
-
|
258
|
-
|
259
|
-
web_server_ = await cg.get_variable(webserver_id)
|
260
|
-
web_server.add_entity_to_sorting_list(web_server_, var, config)
|
257
|
+
if web_server_config := config.get(CONF_WEB_SERVER):
|
258
|
+
await web_server.add_entity_config(var, web_server_config)
|
261
259
|
|
262
260
|
|
263
261
|
async def register_number(
|
@@ -125,7 +125,7 @@ async def online_image_action_to_code(config, action_id, template_arg, args):
|
|
125
125
|
var = cg.new_Pvariable(action_id, template_arg, paren)
|
126
126
|
|
127
127
|
if CONF_URL in config:
|
128
|
-
template_ = await cg.templatable(config[CONF_URL], args, cg.
|
128
|
+
template_ = await cg.templatable(config[CONF_URL], args, cg.std_string)
|
129
129
|
cg.add(var.set_url(template_))
|
130
130
|
return var
|
131
131
|
|
@@ -157,7 +157,7 @@ class OnlineImage : public PollingComponent,
|
|
157
157
|
template<typename... Ts> class OnlineImageSetUrlAction : public Action<Ts...> {
|
158
158
|
public:
|
159
159
|
OnlineImageSetUrlAction(OnlineImage *parent) : parent_(parent) {}
|
160
|
-
TEMPLATABLE_VALUE(
|
160
|
+
TEMPLATABLE_VALUE(std::string, url)
|
161
161
|
void play(Ts... x) override {
|
162
162
|
this->parent_->set_url(this->url_.value(x...));
|
163
163
|
this->parent_->update();
|
@@ -170,7 +170,6 @@ template<typename... Ts> class OnlineImageSetUrlAction : public Action<Ts...> {
|
|
170
170
|
template<typename... Ts> class OnlineImageReleaseAction : public Action<Ts...> {
|
171
171
|
public:
|
172
172
|
OnlineImageReleaseAction(OnlineImage *parent) : parent_(parent) {}
|
173
|
-
TEMPLATABLE_VALUE(const char *, url)
|
174
173
|
void play(Ts... x) override { this->parent_->release(); }
|
175
174
|
|
176
175
|
protected:
|
@@ -0,0 +1,57 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from esphome import pins
|
4
|
+
import esphome.codegen as cg
|
5
|
+
import esphome.config_validation as cv
|
6
|
+
from esphome.const import CONF_ID, PLATFORM_ESP32, PLATFORM_ESP8266
|
7
|
+
|
8
|
+
CODEOWNERS = ["@olegtarasov"]
|
9
|
+
MULTI_CONF = True
|
10
|
+
|
11
|
+
CONF_IN_PIN = "in_pin"
|
12
|
+
CONF_OUT_PIN = "out_pin"
|
13
|
+
CONF_CH_ENABLE = "ch_enable"
|
14
|
+
CONF_DHW_ENABLE = "dhw_enable"
|
15
|
+
CONF_COOLING_ENABLE = "cooling_enable"
|
16
|
+
CONF_OTC_ACTIVE = "otc_active"
|
17
|
+
CONF_CH2_ACTIVE = "ch2_active"
|
18
|
+
CONF_SYNC_MODE = "sync_mode"
|
19
|
+
|
20
|
+
opentherm_ns = cg.esphome_ns.namespace("opentherm")
|
21
|
+
OpenthermHub = opentherm_ns.class_("OpenthermHub", cg.Component)
|
22
|
+
|
23
|
+
CONFIG_SCHEMA = cv.All(
|
24
|
+
cv.Schema(
|
25
|
+
{
|
26
|
+
cv.GenerateID(): cv.declare_id(OpenthermHub),
|
27
|
+
cv.Required(CONF_IN_PIN): pins.internal_gpio_input_pin_schema,
|
28
|
+
cv.Required(CONF_OUT_PIN): pins.internal_gpio_output_pin_schema,
|
29
|
+
cv.Optional(CONF_CH_ENABLE, True): cv.boolean,
|
30
|
+
cv.Optional(CONF_DHW_ENABLE, True): cv.boolean,
|
31
|
+
cv.Optional(CONF_COOLING_ENABLE, False): cv.boolean,
|
32
|
+
cv.Optional(CONF_OTC_ACTIVE, False): cv.boolean,
|
33
|
+
cv.Optional(CONF_CH2_ACTIVE, False): cv.boolean,
|
34
|
+
cv.Optional(CONF_SYNC_MODE, False): cv.boolean,
|
35
|
+
}
|
36
|
+
).extend(cv.COMPONENT_SCHEMA),
|
37
|
+
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266]),
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
async def to_code(config: dict[str, Any]) -> None:
|
42
|
+
# Create the hub, passing the two callbacks defined below
|
43
|
+
# Since the hub is used in the callbacks, we need to define it first
|
44
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
45
|
+
await cg.register_component(var, config)
|
46
|
+
|
47
|
+
# Set pins
|
48
|
+
in_pin = await cg.gpio_pin_expression(config[CONF_IN_PIN])
|
49
|
+
cg.add(var.set_in_pin(in_pin))
|
50
|
+
|
51
|
+
out_pin = await cg.gpio_pin_expression(config[CONF_OUT_PIN])
|
52
|
+
cg.add(var.set_out_pin(out_pin))
|
53
|
+
|
54
|
+
non_sensors = {CONF_ID, CONF_IN_PIN, CONF_OUT_PIN}
|
55
|
+
for key, value in config.items():
|
56
|
+
if key not in non_sensors:
|
57
|
+
cg.add(getattr(var, f"set_{key}")(value))
|