mirror of
https://github.com/esphome/esphome.git
synced 2026-11-17 18:46:08 +00:00
Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c20f8c0138 | ||
|
|
5071968eb9 | ||
|
|
e6bebc298f | ||
|
|
8831c0dc0d | ||
|
|
9166980740 | ||
|
|
7e575ef16d | ||
|
|
6d9f4421a8 | ||
|
|
8854e1eb94 | ||
|
|
d597be77ac | ||
|
|
f56a4db60f | ||
|
|
362e73313c | ||
|
|
6e92bb301d | ||
|
|
644bd8995a | ||
|
|
3caff2b80b | ||
|
|
4814377805 | ||
|
|
d0bafef28c | ||
|
|
e8cf0cfd06 | ||
|
|
88f6135171 | ||
|
|
055faab7e3 | ||
|
|
f74d8b3ca2 |
No files matched your search
+77
-15
@@ -105,6 +105,7 @@ jobs:
|
||||
esp32-platformio-components: ${{ steps.determine.outputs.esp32-platformio-components }}
|
||||
esp8266-native: ${{ steps.determine.outputs.esp8266-native }}
|
||||
esp8266-native-components: ${{ steps.determine.outputs.esp8266-native-components }}
|
||||
windows-build-matrix: ${{ steps.determine.outputs.windows-build-matrix }}
|
||||
changed-components: ${{ steps.determine.outputs.changed-components }}
|
||||
changed-components-with-tests: ${{ steps.determine.outputs.changed-components-with-tests }}
|
||||
directly-changed-components-with-tests: ${{ steps.determine.outputs.directly-changed-components-with-tests }}
|
||||
@@ -170,6 +171,7 @@ jobs:
|
||||
echo "esp32-platformio-components=$(echo "$output" | jq -r '.esp32_platformio_components')" >> $GITHUB_OUTPUT
|
||||
echo "esp8266-native=$(echo "$output" | jq -r '.esp8266_native')" >> $GITHUB_OUTPUT
|
||||
echo "esp8266-native-components=$(echo "$output" | jq -r '.esp8266_native_components')" >> $GITHUB_OUTPUT
|
||||
echo "windows-build-matrix=$(echo "$output" | jq -c '.windows_build_matrix')" >> $GITHUB_OUTPUT
|
||||
echo "changed-components=$(echo "$output" | jq -c '.changed_components')" >> $GITHUB_OUTPUT
|
||||
echo "changed-components-with-tests=$(echo "$output" | jq -c '.changed_components_with_tests')" >> $GITHUB_OUTPUT
|
||||
echo "directly-changed-components-with-tests=$(echo "$output" | jq -c '.directly_changed_components_with_tests')" >> $GITHUB_OUTPUT
|
||||
@@ -1466,23 +1468,26 @@ jobs:
|
||||
# config first, so a separate config pass is redundant.
|
||||
python3 script/test_build_components.py -e compile -t esp8266-ard -c "$TEST_COMPONENTS" -f --toolchain arduino --fail-on-no-tests
|
||||
|
||||
test-esp8266-native-windows:
|
||||
name: Compile esp8266 with the native toolchain on Windows (ccache ${{ matrix.ccache }})
|
||||
test-windows:
|
||||
name: Compile ${{ matrix.target }} with ${{ matrix.toolchain }} on Windows (ccache ${{ matrix.ccache }})
|
||||
runs-on: windows-latest
|
||||
needs:
|
||||
- common
|
||||
- determine-jobs
|
||||
if: github.event_name == 'pull_request' && needs.determine-jobs.outputs.esp8266-native == 'true'
|
||||
if: github.event_name == 'pull_request' && needs.determine-jobs.outputs.windows-build-matrix != '[]'
|
||||
# A hung compiler must fail the job, not hold the runner for six hours.
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Both ways the build runs on Windows: ESPHome Desktop bundles
|
||||
# ccache and puts it on PATH, a pip install has none.
|
||||
ccache: ["1", "0"]
|
||||
# One leg per build path ESPHome ships on Windows; the list comes from
|
||||
# script/determine-jobs.py (WINDOWS_BUILD_LEGS), which also decides
|
||||
# which legs a change needs. No toolchain is cached: every leg installs
|
||||
# its own from scratch, as a fresh Windows machine does.
|
||||
include: ${{ fromJson(needs.determine-jobs.outputs.windows-build-matrix) }}
|
||||
env:
|
||||
ESPHOME_CCACHE_ENABLE: ${{ matrix.ccache }}
|
||||
# ESPHOME_CCACHE_ENABLE stays unset: the build must detect ccache on
|
||||
# PATH by itself, as it does for ESPHome Desktop and a pip install
|
||||
# The test script prints characters the cp1252 console cannot encode
|
||||
PYTHONUTF8: "1"
|
||||
# The exact static build ESPHome Desktop ships
|
||||
@@ -1516,24 +1521,56 @@ jobs:
|
||||
Add-Content -Path $env:GITHUB_PATH -Value $bin.DirectoryName
|
||||
& $bin.FullName --version
|
||||
|
||||
- name: Take any ccache off PATH
|
||||
if: matrix.ccache == '0'
|
||||
shell: pwsh
|
||||
# The runner image ships one with Strawberry Perl; this leg is the build of a machine without
|
||||
run: |
|
||||
$path = $env:PATH
|
||||
for ($i = 0; $i -lt 5; $i++) {
|
||||
$found = Get-Command ccache -ErrorAction SilentlyContinue
|
||||
if (-not $found) { break }
|
||||
$dir = Split-Path $found.Source
|
||||
Write-Host "Taking $dir off PATH for $($found.Source)"
|
||||
$path = ($path -split ';' | Where-Object { $_ -ne $dir }) -join ';'
|
||||
$env:PATH = $path
|
||||
}
|
||||
if (Get-Command ccache -ErrorAction SilentlyContinue) {
|
||||
Write-Host "::error::a ccache is still on PATH"
|
||||
exit 1
|
||||
}
|
||||
"PATH=$path" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
- name: Show disk space
|
||||
shell: pwsh
|
||||
run: Get-PSDrive -PSProvider FileSystem | Format-Table Name, @{n='FreeGB';e={[math]::Round($_.Free/1GB,1)}}, @{n='UsedGB';e={[math]::Round($_.Used/1GB,1)}}
|
||||
|
||||
- name: Compile
|
||||
shell: pwsh
|
||||
# One component test: web_server brings wifi, api and the async web
|
||||
# server libraries, the shape of a typical ESP8266 device
|
||||
# One base config per leg; the toolchain install is part of the timed
|
||||
# run, and the slowest leg (sdk-nrf from scratch) takes about 7 minutes
|
||||
run: |
|
||||
if ("${{ matrix.ccache }}" -eq "0" -and (Get-Command ccache -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "::error::a ccache is on PATH; this leg builds without one"
|
||||
exit 1
|
||||
}
|
||||
. .\venv\Scripts\Activate.ps1
|
||||
$arguments = "script/test_build_components.py", "-e", "compile", "-t", "esp8266-ard", "-c", "web_server", "--base-only", "--toolchain", "arduino", "--fail-on-no-tests"
|
||||
if ("${{ matrix.idf_target }}") {
|
||||
# Only the chip this leg builds; CI otherwise installs every toolchain
|
||||
$env:ESPHOME_IDF_DEFAULT_TARGETS = "${{ matrix.idf_target }}"
|
||||
}
|
||||
$arguments = "script/test_build_components.py", "-e", "compile", "-t", "${{ matrix.target }}", "-c", "${{ matrix.component }}", "--base-only", "--toolchain", "${{ matrix.toolchain }}", "--fail-on-no-tests"
|
||||
$p = Start-Process -FilePath python -ArgumentList $arguments -NoNewWindow -PassThru
|
||||
# Reading the handle keeps ExitCode available after the process exits
|
||||
$null = $p.Handle
|
||||
if (-not $p.WaitForExit(25 * 60 * 1000)) {
|
||||
Write-Host "::error::The compile did not finish in 25 minutes; processes still running:"
|
||||
Get-CimInstance Win32_Process |
|
||||
Where-Object { $_.CommandLine -match 'xtensa|ccache|ninja|esphome' } |
|
||||
Where-Object { $_.CommandLine -match 'xtensa|riscv|arm-|ccache|ninja|cmake|west|platformio|pio|esphome' } |
|
||||
Select-Object ProcessId, ParentProcessId, CreationDate, CommandLine |
|
||||
Format-List | Out-String -Width 4096 | Write-Host
|
||||
Get-Process |
|
||||
Where-Object { $_.Name -match 'cc1|ccache|ninja|xtensa|python' } |
|
||||
Where-Object { $_.Name -match 'cc1|ccache|ninja|cmake|xtensa|riscv|arm-|python' } |
|
||||
Select-Object Id, Name, CPU, WorkingSet64 |
|
||||
Format-Table | Out-String | Write-Host
|
||||
taskkill /PID $p.Id /T /F
|
||||
@@ -1546,10 +1583,35 @@ jobs:
|
||||
# ccache was ever reached
|
||||
if: always() && matrix.ccache == '1'
|
||||
shell: pwsh
|
||||
# The build keeps its store under the esphome tools cache
|
||||
# The stores live under ESPHome's tools cache (tools_cache_path() in
|
||||
# build_helpers/tools_cache.py), each native build's next to its
|
||||
# install. A passing compile that never called ccache is a bug in the
|
||||
# build's ccache wiring, not a pass.
|
||||
run: |
|
||||
$env:CCACHE_DIR = Join-Path $env:LOCALAPPDATA "esphome\Cache\arduino8266\ccache"
|
||||
$cache = Join-Path $env:LOCALAPPDATA "esphome\Cache"
|
||||
$env:CCACHE_DIR = switch ("${{ matrix.toolchain }}") {
|
||||
"arduino" { Join-Path $cache "arduino8266\ccache" }
|
||||
"esp-idf" { Join-Path $cache "idf\ccache" }
|
||||
"sdk-nrf" { Join-Path $cache "sdk-nrf\ccache" }
|
||||
"platformio" { Join-Path $cache "platformio-ccache" }
|
||||
default {
|
||||
Write-Host "::error::No ccache store known for toolchain ${{ matrix.toolchain }}"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
ccache -s
|
||||
# Cacheable calls = hits + misses; the tab-separated keys do not change between locales
|
||||
$calls = 0
|
||||
foreach ($line in (ccache --print-stats)) {
|
||||
$key, $value = $line -split "`t"
|
||||
if ($key -in "direct_cache_hit", "preprocessed_cache_hit", "cache_miss") {
|
||||
$calls += [int]$value
|
||||
}
|
||||
}
|
||||
if ($calls -eq 0) {
|
||||
Write-Host "::error::ccache was never called by the compile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
device-builder:
|
||||
name: Test downstream esphome/device-builder
|
||||
@@ -1922,7 +1984,7 @@ jobs:
|
||||
- test-build-components-split
|
||||
- test-esp32-platformio
|
||||
- test-esp8266-native
|
||||
- test-esp8266-native-windows
|
||||
- test-windows
|
||||
- device-builder
|
||||
- memory-impact-target-branch
|
||||
- memory-impact-pr-branch
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#include "esphome/components/airthings_wave_base/airthings_wave_base.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome::airthings_wave_plus {
|
||||
|
||||
@@ -20,15 +21,16 @@ static const char *const ACCESS_CONTROL_POINT_CHARACTERISTIC_UUID_WAVE_RADON_GEN
|
||||
"b42e50d8-ade7-11e4-89d3-123b93f75cba";
|
||||
|
||||
class AirthingsWavePlus final : public airthings_wave_base::AirthingsWaveBase {
|
||||
SUB_SENSOR(radon)
|
||||
SUB_SENSOR(radon_long_term)
|
||||
SUB_SENSOR(co2)
|
||||
SUB_SENSOR(illuminance)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void set_radon(sensor::Sensor *radon) { radon_sensor_ = radon; }
|
||||
void set_radon_long_term(sensor::Sensor *radon_long_term) { radon_long_term_sensor_ = radon_long_term; }
|
||||
void set_co2(sensor::Sensor *co2) { co2_sensor_ = co2; }
|
||||
void set_illuminance(sensor::Sensor *illuminance) { illuminance_sensor_ = illuminance; }
|
||||
void set_device_type(WaveDeviceType wave_device_type) { wave_device_type_ = wave_device_type; }
|
||||
|
||||
protected:
|
||||
@@ -38,11 +40,6 @@ class AirthingsWavePlus final : public airthings_wave_base::AirthingsWaveBase {
|
||||
void read_sensors(uint8_t *raw_value, uint16_t value_len) override;
|
||||
WaveDeviceType wave_device_type_{WaveDeviceType::WAVE_PLUS};
|
||||
|
||||
sensor::Sensor *radon_sensor_{nullptr};
|
||||
sensor::Sensor *radon_long_term_sensor_{nullptr};
|
||||
sensor::Sensor *co2_sensor_{nullptr};
|
||||
sensor::Sensor *illuminance_sensor_{nullptr};
|
||||
|
||||
struct WavePlusReadings {
|
||||
uint8_t version;
|
||||
uint8_t humidity;
|
||||
|
||||
@@ -85,8 +85,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
await airthings_wave_base.wave_base_to_code(var, config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_RADON, var.set_radon)
|
||||
await sensors(CONF_RADON_LONG_TERM, var.set_radon_long_term)
|
||||
await sensors(CONF_CO2, var.set_co2)
|
||||
await sensors(CONF_ILLUMINANCE, var.set_illuminance)
|
||||
await sensors(CONF_RADON, var.set_radon_sensor)
|
||||
await sensors(CONF_RADON_LONG_TERM, var.set_radon_long_term_sensor)
|
||||
await sensors(CONF_CO2, var.set_co2_sensor)
|
||||
await sensors(CONF_ILLUMINANCE, var.set_illuminance_sensor)
|
||||
cg.add(var.set_device_type(config[CONF_DEVICE_TYPE]))
|
||||
@@ -46,5 +46,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await ble_client.new_ble_node_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery)
|
||||
await sensors(CONF_ILLUMINANCE, var.set_illuminance)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_sensor)
|
||||
await sensors(CONF_ILLUMINANCE, var.set_illuminance_sensor)
|
||||
@@ -10,18 +10,18 @@ ESPHOME_LOG_TAG(TAG, "am43");
|
||||
|
||||
void Am43::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "AM43");
|
||||
LOG_SENSOR(" ", "Battery", this->battery_);
|
||||
LOG_SENSOR(" ", "Illuminance", this->illuminance_);
|
||||
LOG_SENSOR(" ", "Battery", this->battery_sensor_);
|
||||
LOG_SENSOR(" ", "Illuminance", this->illuminance_sensor_);
|
||||
}
|
||||
|
||||
void Am43::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) {
|
||||
switch (event) {
|
||||
case ESP_GATTC_DISCONNECT_EVT: {
|
||||
this->node_state = espbt::ClientState::IDLE;
|
||||
if (this->battery_ != nullptr)
|
||||
this->battery_->publish_state(NAN);
|
||||
if (this->illuminance_ != nullptr)
|
||||
this->illuminance_->publish_state(NAN);
|
||||
if (this->battery_sensor_ != nullptr)
|
||||
this->battery_sensor_->publish_state(NAN);
|
||||
if (this->illuminance_sensor_ != nullptr)
|
||||
this->illuminance_sensor_->publish_state(NAN);
|
||||
break;
|
||||
}
|
||||
case ESP_GATTC_SEARCH_CMPL_EVT: {
|
||||
@@ -48,17 +48,18 @@ void Am43::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_i
|
||||
Am43Decoder decoder;
|
||||
decoder.decode(param->notify.value, param->notify.value_len);
|
||||
|
||||
if (this->battery_ != nullptr && decoder.has_battery_level() && millis() - this->last_battery_update_ > 10000) {
|
||||
this->battery_->publish_state(decoder.battery_level_);
|
||||
if (this->battery_sensor_ != nullptr && decoder.has_battery_level() &&
|
||||
millis() - this->last_battery_update_ > 10000) {
|
||||
this->battery_sensor_->publish_state(decoder.battery_level_);
|
||||
this->last_battery_update_ = millis();
|
||||
}
|
||||
|
||||
if (this->illuminance_ != nullptr && decoder.has_light_level()) {
|
||||
this->illuminance_->publish_state(decoder.light_level_);
|
||||
if (this->illuminance_sensor_ != nullptr && decoder.has_light_level()) {
|
||||
this->illuminance_sensor_->publish_state(decoder.light_level_);
|
||||
}
|
||||
|
||||
if (this->current_sensor_ > 0) {
|
||||
if (this->illuminance_ != nullptr)
|
||||
if (this->illuminance_sensor_ != nullptr)
|
||||
this->write_packet_(Am43Encoder::get_light_level_request());
|
||||
this->current_sensor_ = 0;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ void Am43::update() {
|
||||
return;
|
||||
}
|
||||
if (this->current_sensor_ == 0) {
|
||||
if (this->battery_ != nullptr)
|
||||
if (this->battery_sensor_ != nullptr)
|
||||
this->write_packet_(Am43Encoder::get_battery_level_request());
|
||||
this->current_sensor_++;
|
||||
}
|
||||
|
||||
@@ -15,19 +15,18 @@ namespace esphome::am43 {
|
||||
namespace espbt = esphome::esp32_ble_tracker;
|
||||
|
||||
class Am43 final : public esphome::ble_client::BLEClientNode, public PollingComponent {
|
||||
SUB_SENSOR(battery)
|
||||
SUB_SENSOR(illuminance)
|
||||
|
||||
public:
|
||||
void update() override;
|
||||
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
|
||||
esp_ble_gattc_cb_param_t *param) override;
|
||||
void dump_config() override;
|
||||
void set_battery(sensor::Sensor *battery) { battery_ = battery; }
|
||||
void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
|
||||
|
||||
protected:
|
||||
/// Writes a request to the control characteristic; logs on failure.
|
||||
void write_packet_(const Am43Packet &packet);
|
||||
sensor::Sensor *battery_{nullptr};
|
||||
sensor::Sensor *illuminance_{nullptr};
|
||||
// The AM43 often gets into a state where it spams loads of battery update
|
||||
// notifications. Here we will limit to no more than every 10s.
|
||||
uint32_t last_battery_update_{0};
|
||||
|
||||
@@ -349,7 +349,7 @@ void AS734XComponent::dump_config() {
|
||||
LOG_SENSOR(" ", "PPFD", this->ppfd_sensor_);
|
||||
LOG_SENSOR(" ", "Color temperature", this->color_temperature_sensor_);
|
||||
#ifdef USE_AS734X_RGB
|
||||
LOG_TEXT_SENSOR(" ", "RGB hex", this->rgb_hex_sensor_);
|
||||
LOG_TEXT_SENSOR(" ", "RGB hex", this->rgb_hex_text_sensor_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ void AS734XComponent::publish_color_() {
|
||||
}
|
||||
|
||||
#ifdef USE_AS734X_RGB
|
||||
if (this->rgb_hex_sensor_ == nullptr) {
|
||||
if (this->rgb_hex_text_sensor_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
// Convert to chromaticity first, so the colour describes the hue rather than the brightness.
|
||||
@@ -633,7 +633,7 @@ void AS734XComponent::publish_color_() {
|
||||
tristimulus_to_rgb(tri_x / sum, tri_y / sum, tri_z / sum, rgb[0], rgb[1], rgb[2]);
|
||||
format_hex_to(rgb_hex, rgb, sizeof(rgb));
|
||||
}
|
||||
this->rgb_hex_sensor_->publish_state(rgb_hex);
|
||||
this->rgb_hex_text_sensor_->publish_state(rgb_hex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,10 @@ extern const ChipInfo TCS3448_CHIP;
|
||||
#endif
|
||||
|
||||
class AS734XComponent : public PollingComponent, public i2c::I2CDevice {
|
||||
#ifdef USE_AS734X_RGB
|
||||
SUB_TEXT_SENSOR(rgb_hex)
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Channel correction is multiplicative, so it starts at unity rather than zero in case no
|
||||
// calibration is configured.
|
||||
@@ -141,10 +145,6 @@ class AS734XComponent : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(ppfd)
|
||||
SUB_SENSOR(color_temperature)
|
||||
|
||||
#ifdef USE_AS734X_RGB
|
||||
void set_rgb_hex_sensor(text_sensor::TextSensor *sensor) { this->rgb_hex_sensor_ = sensor; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
bool select_bank_(uint8_t reg);
|
||||
bool update_bits_(uint8_t reg, uint8_t mask, bool value);
|
||||
@@ -186,9 +186,6 @@ class AS734XComponent : public PollingComponent, public i2c::I2CDevice {
|
||||
uint8_t atime_{0};
|
||||
uint8_t step_{0};
|
||||
bool bank_low_{true}; // unknown until setup() writes CFG0
|
||||
#ifdef USE_AS734X_RGB
|
||||
text_sensor::TextSensor *rgb_hex_sensor_{nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace esphome::as734x
|
||||
@@ -25,4 +25,4 @@ async def to_code(config: ConfigType) -> None:
|
||||
hub = await cg.get_variable(config[CONF_AS734X_ID])
|
||||
cg.add_define("USE_AS734X_RGB")
|
||||
sens = await text_sensor.new_text_sensor(conf)
|
||||
cg.add(hub.set_rgb_hex_sensor(sens))
|
||||
cg.add(hub.set_rgb_hex_text_sensor(sens))
|
||||
@@ -8,10 +8,10 @@ ESPHOME_LOG_TAG(TAG, "atc_mithermometer");
|
||||
|
||||
void ATCMiThermometer::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "ATC MiThermometer");
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_);
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_sensor_);
|
||||
}
|
||||
|
||||
bool ATCMiThermometer::parse_device(const ble_device_base::ESPBTDevice &device) {
|
||||
@@ -35,18 +35,18 @@ bool ATCMiThermometer::parse_device(const ble_device_base::ESPBTDevice &device)
|
||||
if (!(report_results_(res, addr_str))) {
|
||||
continue;
|
||||
}
|
||||
if (res->temperature.has_value() && this->temperature_ != nullptr)
|
||||
this->temperature_->publish_state(*res->temperature);
|
||||
if (res->humidity.has_value() && this->humidity_ != nullptr)
|
||||
this->humidity_->publish_state(*res->humidity);
|
||||
if (res->battery_level.has_value() && this->battery_level_ != nullptr)
|
||||
this->battery_level_->publish_state(*res->battery_level);
|
||||
if (res->battery_voltage.has_value() && this->battery_voltage_ != nullptr)
|
||||
this->battery_voltage_->publish_state(*res->battery_voltage);
|
||||
if (res->temperature.has_value() && this->temperature_sensor_ != nullptr)
|
||||
this->temperature_sensor_->publish_state(*res->temperature);
|
||||
if (res->humidity.has_value() && this->humidity_sensor_ != nullptr)
|
||||
this->humidity_sensor_->publish_state(*res->humidity);
|
||||
if (res->battery_level.has_value() && this->battery_level_sensor_ != nullptr)
|
||||
this->battery_level_sensor_->publish_state(*res->battery_level);
|
||||
if (res->battery_voltage.has_value() && this->battery_voltage_sensor_ != nullptr)
|
||||
this->battery_voltage_sensor_->publish_state(*res->battery_voltage);
|
||||
success = true;
|
||||
}
|
||||
if (this->signal_strength_ != nullptr)
|
||||
this->signal_strength_->publish_state(device.get_rssi());
|
||||
if (this->signal_strength_sensor_ != nullptr)
|
||||
this->signal_strength_sensor_->publish_state(device.get_rssi());
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -17,24 +17,20 @@ struct ParseResult {
|
||||
};
|
||||
|
||||
class ATCMiThermometer final : public Component, public ble_device_base::ESPBTDeviceListener {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(battery_level)
|
||||
SUB_SENSOR(battery_voltage)
|
||||
SUB_SENSOR(signal_strength)
|
||||
|
||||
public:
|
||||
void set_address(uint64_t address) { address_ = address; };
|
||||
|
||||
bool parse_device(const ble_device_base::ESPBTDevice &device) override;
|
||||
void dump_config() override;
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_battery_level(sensor::Sensor *battery_level) { battery_level_ = battery_level; }
|
||||
void set_battery_voltage(sensor::Sensor *battery_voltage) { battery_voltage_ = battery_voltage; }
|
||||
void set_signal_strength(sensor::Sensor *signal_strength) { signal_strength_ = signal_strength; }
|
||||
|
||||
protected:
|
||||
uint64_t address_;
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *battery_level_{nullptr};
|
||||
sensor::Sensor *battery_voltage_{nullptr};
|
||||
sensor::Sensor *signal_strength_{nullptr};
|
||||
|
||||
uint8_t last_frame_count_{0};
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level)
|
||||
await sensors(CONF_BATTERY_VOLTAGE, var.set_battery_voltage)
|
||||
await sensors(CONF_SIGNAL_STRENGTH, var.set_signal_strength)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level_sensor)
|
||||
await sensors(CONF_BATTERY_VOLTAGE, var.set_battery_voltage_sensor)
|
||||
await sensors(CONF_SIGNAL_STRENGTH, var.set_signal_strength_sensor)
|
||||
@@ -20,7 +20,12 @@ static constexpr uint32_t AUDIO_WRITE_TIMEOUT_MS = 50; // Max blockin
|
||||
static constexpr uint32_t READER_WRITE_TIMEOUT_MS = 50; // Max blocking time when writing into the ring buffer
|
||||
static constexpr uint8_t READER_TASK_PRIORITY = 2;
|
||||
static constexpr uint8_t DECODER_TASK_PRIORITY = 2;
|
||||
#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1_3
|
||||
// A TLS 1.3 handshake peaks at about 4.3 KB of reader stack
|
||||
static constexpr size_t READER_TASK_STACK_SIZE = 6144;
|
||||
#else
|
||||
static constexpr size_t READER_TASK_STACK_SIZE = 4096;
|
||||
#endif
|
||||
static constexpr size_t DECODER_TASK_STACK_SIZE = 5120;
|
||||
static constexpr uint32_t PAUSE_POLL_DELAY_MS = 20;
|
||||
static constexpr const char *const HTTP_URI_PREFIX = "http://";
|
||||
|
||||
@@ -8,11 +8,11 @@ ESPHOME_LOG_TAG(TAG, "b_parasite");
|
||||
|
||||
void BParasite::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "b_parasite");
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Soil Moisture", this->soil_moisture_);
|
||||
LOG_SENSOR(" ", "Illuminance", this->illuminance_);
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_sensor_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
LOG_SENSOR(" ", "Soil Moisture", this->soil_moisture_sensor_);
|
||||
LOG_SENSOR(" ", "Illuminance", this->illuminance_sensor_);
|
||||
}
|
||||
|
||||
bool BParasite::parse_device(const ble_device_base::ESPBTDevice &device) {
|
||||
@@ -87,21 +87,21 @@ bool BParasite::parse_device(const ble_device_base::ESPBTDevice &device) {
|
||||
// Ambient light in lux.
|
||||
float illuminance = has_illuminance ? encode_value<uint16_t>(&data[16]) : 0.0f;
|
||||
|
||||
if (battery_voltage_ != nullptr) {
|
||||
battery_voltage_->publish_state(battery_voltage);
|
||||
if (this->battery_voltage_sensor_ != nullptr) {
|
||||
this->battery_voltage_sensor_->publish_state(battery_voltage);
|
||||
}
|
||||
if (temperature_ != nullptr) {
|
||||
temperature_->publish_state(temp_celsius);
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
this->temperature_sensor_->publish_state(temp_celsius);
|
||||
}
|
||||
if (humidity_ != nullptr) {
|
||||
humidity_->publish_state(humidity_percent);
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
this->humidity_sensor_->publish_state(humidity_percent);
|
||||
}
|
||||
if (soil_moisture_ != nullptr) {
|
||||
soil_moisture_->publish_state(moisture_percent);
|
||||
if (this->soil_moisture_sensor_ != nullptr) {
|
||||
this->soil_moisture_sensor_->publish_state(moisture_percent);
|
||||
}
|
||||
if (illuminance_ != nullptr) {
|
||||
if (this->illuminance_sensor_ != nullptr) {
|
||||
if (has_illuminance) {
|
||||
illuminance_->publish_state(illuminance);
|
||||
this->illuminance_sensor_->publish_state(illuminance);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "No lux information is present in the BLE packet");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
namespace esphome::b_parasite {
|
||||
|
||||
class BParasite final : public Component, public ble_device_base::ESPBTDeviceListener {
|
||||
SUB_SENSOR(battery_voltage)
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(soil_moisture)
|
||||
SUB_SENSOR(illuminance)
|
||||
|
||||
public:
|
||||
void set_address(uint64_t address) { address_ = address; };
|
||||
void set_bindkey(const std::string &bindkey);
|
||||
@@ -14,22 +20,11 @@ class BParasite final : public Component, public ble_device_base::ESPBTDeviceLis
|
||||
bool parse_device(const ble_device_base::ESPBTDevice &device) override;
|
||||
void dump_config() override;
|
||||
|
||||
void set_battery_voltage(sensor::Sensor *battery_voltage) { battery_voltage_ = battery_voltage; }
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_soil_moisture(sensor::Sensor *soil_moisture) { soil_moisture_ = soil_moisture; }
|
||||
void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
|
||||
|
||||
protected:
|
||||
// The received advertisement packet contains an unsigned 4 bits wrap-around counter
|
||||
// for deduplicating messages.
|
||||
int8_t last_processed_counter_ = -1;
|
||||
uint64_t address_;
|
||||
sensor::Sensor *battery_voltage_{nullptr};
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *soil_moisture_{nullptr};
|
||||
sensor::Sensor *illuminance_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::b_parasite
|
||||
@@ -79,13 +79,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
|
||||
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
|
||||
|
||||
for config_key, setter in [
|
||||
(CONF_TEMPERATURE, var.set_temperature),
|
||||
(CONF_HUMIDITY, var.set_humidity),
|
||||
(CONF_BATTERY_VOLTAGE, var.set_battery_voltage),
|
||||
(CONF_MOISTURE, var.set_soil_moisture),
|
||||
(CONF_ILLUMINANCE, var.set_illuminance),
|
||||
]:
|
||||
if sensor_config := config.get(config_key):
|
||||
sens = await sensor.new_sensor(sensor_config)
|
||||
cg.add(setter(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
await sensors(CONF_BATTERY_VOLTAGE, var.set_battery_voltage_sensor)
|
||||
await sensors(CONF_MOISTURE, var.set_soil_moisture_sensor)
|
||||
await sensors(CONF_ILLUMINANCE, var.set_illuminance_sensor)
|
||||
@@ -8,23 +8,15 @@
|
||||
namespace esphome::bedjet {
|
||||
|
||||
class BedjetSensor final : public BedJetClient, public Component {
|
||||
SUB_SENSOR(outlet_temperature)
|
||||
SUB_SENSOR(ambient_temperature)
|
||||
|
||||
public:
|
||||
void dump_config() override;
|
||||
|
||||
void on_status(const BedjetStatusPacket *data) override;
|
||||
void on_bedjet_state(bool is_ready) override;
|
||||
std::string describe() override;
|
||||
|
||||
void set_outlet_temperature_sensor(sensor::Sensor *outlet_temperature_sensor) {
|
||||
this->outlet_temperature_sensor_ = outlet_temperature_sensor;
|
||||
}
|
||||
void set_ambient_temperature_sensor(sensor::Sensor *ambient_temperature_sensor) {
|
||||
this->ambient_temperature_sensor_ = ambient_temperature_sensor;
|
||||
}
|
||||
|
||||
protected:
|
||||
sensor::Sensor *outlet_temperature_sensor_{nullptr};
|
||||
sensor::Sensor *ambient_temperature_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::bedjet
|
||||
@@ -47,8 +47,8 @@ void BMP085Component::dump_config() {
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Pressure", this->pressure_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Pressure", this->pressure_sensor_);
|
||||
}
|
||||
|
||||
void BMP085Component::read_temperature_() {
|
||||
@@ -76,8 +76,8 @@ void BMP085Component::read_temperature_() {
|
||||
|
||||
this->calibration_.temp = temp;
|
||||
ESP_LOGD(TAG, "Got Temperature=%.1f °C", temp);
|
||||
if (this->temperature_ != nullptr)
|
||||
this->temperature_->publish_state(temp);
|
||||
if (this->temperature_sensor_ != nullptr)
|
||||
this->temperature_sensor_->publish_state(temp);
|
||||
this->status_clear_warning();
|
||||
|
||||
if (!this->set_mode_(BMP085_CONTROL_MODE_PRESSURE_3)) {
|
||||
@@ -123,8 +123,8 @@ void BMP085Component::read_pressure_() {
|
||||
|
||||
ESP_LOGD(TAG, "Got Pressure=%.1f hPa", pressure);
|
||||
|
||||
if (this->pressure_ != nullptr)
|
||||
this->pressure_->publish_state(pressure);
|
||||
if (this->pressure_sensor_ != nullptr)
|
||||
this->pressure_sensor_->publish_state(pressure);
|
||||
this->status_clear_warning();
|
||||
}
|
||||
bool BMP085Component::set_mode_(uint8_t mode) {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
namespace esphome::bmp085 {
|
||||
|
||||
class BMP085Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_pressure(sensor::Sensor *pressure) { pressure_ = pressure; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(pressure)
|
||||
|
||||
public:
|
||||
/// Schedule temperature+pressure readings.
|
||||
void update() override;
|
||||
/// Setup the sensor and test for a connection.
|
||||
@@ -33,8 +33,6 @@ class BMP085Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
|
||||
bool set_mode_(uint8_t mode);
|
||||
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *pressure_{nullptr};
|
||||
CalibrationData calibration_;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,5 +46,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_PRESSURE, var.set_pressure)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_PRESSURE, var.set_pressure_sensor)
|
||||
@@ -157,11 +157,11 @@ void BTHomeMiThermometer::dump_config() {
|
||||
char bindkey_hex[format_hex_pretty_size(BTHOME_BINDKEY_SIZE)];
|
||||
ESP_LOGCONFIG(TAG, " Bindkey: %s", format_hex_pretty_to(bindkey_hex, this->bindkey_, BTHOME_BINDKEY_SIZE, '.'));
|
||||
}
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_);
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_);
|
||||
LOG_SENSOR(" ", "Signal Strength", this->signal_strength_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_sensor_);
|
||||
LOG_SENSOR(" ", "Signal Strength", this->signal_strength_sensor_);
|
||||
}
|
||||
|
||||
bool BTHomeMiThermometer::parse_device(const ble_device_base::ESPBTDevice &device) {
|
||||
@@ -171,8 +171,8 @@ bool BTHomeMiThermometer::parse_device(const ble_device_base::ESPBTDevice &devic
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
if (matched && this->signal_strength_ != nullptr) {
|
||||
this->signal_strength_->publish_state(device.get_rssi());
|
||||
if (matched && this->signal_strength_sensor_ != nullptr) {
|
||||
this->signal_strength_sensor_->publish_state(device.get_rssi());
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
@@ -392,47 +392,47 @@ bool BTHomeMiThermometer::handle_service_data_(const ble_device_base::ServiceDat
|
||||
break;
|
||||
}
|
||||
case 0x01: { // battery percentage
|
||||
if (this->battery_level_ != nullptr) {
|
||||
this->battery_level_->publish_state(value[0]);
|
||||
if (this->battery_level_sensor_ != nullptr) {
|
||||
this->battery_level_sensor_->publish_state(value[0]);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0C: { // battery voltage (mV)
|
||||
if (this->battery_voltage_ != nullptr) {
|
||||
if (this->battery_voltage_sensor_ != nullptr) {
|
||||
const uint16_t raw = encode_uint16(value[1], value[0]);
|
||||
this->battery_voltage_->publish_state(raw * 0.001f);
|
||||
this->battery_voltage_sensor_->publish_state(raw * 0.001f);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x02: { // temperature
|
||||
if (this->temperature_ != nullptr) {
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
const int16_t raw = encode_value_le<int16_t>(value);
|
||||
this->temperature_->publish_state(raw * 0.01f);
|
||||
this->temperature_sensor_->publish_state(raw * 0.01f);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x03: { // humidity
|
||||
if (this->humidity_ != nullptr) {
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
const uint16_t raw = encode_uint16(value[1], value[0]);
|
||||
this->humidity_->publish_state(raw * 0.01f);
|
||||
this->humidity_sensor_->publish_state(raw * 0.01f);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x45: { // temperature (0.1C), e.g. Shelly BLU H&T
|
||||
if (this->temperature_ != nullptr) {
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
const int16_t raw = encode_value_le<int16_t>(value);
|
||||
this->temperature_->publish_state(raw * 0.1f);
|
||||
this->temperature_sensor_->publish_state(raw * 0.1f);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x2E: { // humidity (uint8, 1%), e.g. Shelly BLU H&T
|
||||
if (this->humidity_ != nullptr) {
|
||||
this->humidity_->publish_state(value[0]);
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
this->humidity_sensor_->publish_state(value[0]);
|
||||
reported = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
namespace esphome::bthome_mithermometer {
|
||||
|
||||
class BTHomeMiThermometer final : public ble_device_base::ESPBTDeviceListener, public Component {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(battery_level)
|
||||
SUB_SENSOR(battery_voltage)
|
||||
SUB_SENSOR(signal_strength)
|
||||
|
||||
public:
|
||||
void set_address(uint64_t address) { this->address_ = address; }
|
||||
void set_bindkey(std::initializer_list<uint8_t> bindkey);
|
||||
|
||||
void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }
|
||||
void set_battery_level(sensor::Sensor *battery_level) { this->battery_level_ = battery_level; }
|
||||
void set_battery_voltage(sensor::Sensor *battery_voltage) { this->battery_voltage_ = battery_voltage; }
|
||||
void set_signal_strength(sensor::Sensor *signal_strength) { this->signal_strength_ = signal_strength; }
|
||||
|
||||
void dump_config() override;
|
||||
bool parse_device(const ble_device_base::ESPBTDevice &device) override;
|
||||
|
||||
@@ -37,12 +37,6 @@ class BTHomeMiThermometer final : public ble_device_base::ESPBTDeviceListener, p
|
||||
optional<uint8_t> last_packet_id_{};
|
||||
bool has_bindkey_{false};
|
||||
uint8_t bindkey_[16];
|
||||
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *battery_level_{nullptr};
|
||||
sensor::Sensor *battery_voltage_{nullptr};
|
||||
sensor::Sensor *signal_strength_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::bthome_mithermometer
|
||||
@@ -73,8 +73,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
await setup_bthome_mithermometer(var, config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level)
|
||||
await sensors(CONF_BATTERY_VOLTAGE, var.set_battery_voltage)
|
||||
await sensors(CONF_SIGNAL_STRENGTH, var.set_signal_strength)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level_sensor)
|
||||
await sensors(CONF_BATTERY_VOLTAGE, var.set_battery_voltage_sensor)
|
||||
await sensors(CONF_SIGNAL_STRENGTH, var.set_signal_strength_sensor)
|
||||
@@ -77,12 +77,12 @@ void CCS811Component::setup() {
|
||||
|
||||
ESP_LOGD(TAG, "hardware_version=0x%x bootloader_version=0x%x application_version=0x%x\n", hardware_version,
|
||||
bootloader_version, application_version);
|
||||
if (this->version_ != nullptr) {
|
||||
if (this->version_text_sensor_ != nullptr) {
|
||||
char version[20]; // "15.15.15 (0xffff)" is 17 chars, plus NUL, plus wiggle room
|
||||
buf_append_printf(version, sizeof(version), 0, "%d.%d.%d (0x%02x)", (application_version >> 12 & 15),
|
||||
(application_version >> 8 & 15), (application_version >> 4 & 15), application_version);
|
||||
ESP_LOGD(TAG, "publishing version state: %s", version);
|
||||
this->version_->publish_state(version);
|
||||
this->version_text_sensor_->publish_state(version);
|
||||
}
|
||||
}
|
||||
void CCS811Component::update() {
|
||||
@@ -112,27 +112,27 @@ void CCS811Component::update() {
|
||||
|
||||
ESP_LOGD(TAG, "Got co2=%u ppm, tvoc=%u ppb, baseline=0x%04X", co2, tvoc, baseline);
|
||||
|
||||
if (this->co2_ != nullptr)
|
||||
this->co2_->publish_state(co2);
|
||||
if (this->tvoc_ != nullptr)
|
||||
this->tvoc_->publish_state(tvoc);
|
||||
if (this->co2_sensor_ != nullptr)
|
||||
this->co2_sensor_->publish_state(co2);
|
||||
if (this->tvoc_sensor_ != nullptr)
|
||||
this->tvoc_sensor_->publish_state(tvoc);
|
||||
|
||||
this->status_clear_warning();
|
||||
|
||||
this->send_env_data_();
|
||||
}
|
||||
void CCS811Component::send_env_data_() {
|
||||
if (this->humidity_ == nullptr && this->temperature_ == nullptr)
|
||||
if (this->humidity_sensor_ == nullptr && this->temperature_sensor_ == nullptr)
|
||||
return;
|
||||
|
||||
float humidity = NAN;
|
||||
if (this->humidity_ != nullptr)
|
||||
humidity = this->humidity_->state;
|
||||
if (this->humidity_sensor_ != nullptr)
|
||||
humidity = this->humidity_sensor_->state;
|
||||
if (std::isnan(humidity) || humidity < 0 || humidity > 100)
|
||||
humidity = 50;
|
||||
float temperature = NAN;
|
||||
if (this->temperature_ != nullptr)
|
||||
temperature = this->temperature_->state;
|
||||
if (this->temperature_sensor_ != nullptr)
|
||||
temperature = this->temperature_sensor_->state;
|
||||
if (std::isnan(temperature) || temperature < -25 || temperature > 50)
|
||||
temperature = 25;
|
||||
// temperature has a 25° offset to allow negative temperatures
|
||||
@@ -151,9 +151,9 @@ void CCS811Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "CCS811");
|
||||
LOG_I2C_DEVICE(this)
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "CO2 Sensor", this->co2_);
|
||||
LOG_SENSOR(" ", "TVOC Sensor", this->tvoc_);
|
||||
LOG_TEXT_SENSOR(" ", "Firmware Version Sensor", this->version_);
|
||||
LOG_SENSOR(" ", "CO2 Sensor", this->co2_sensor_);
|
||||
LOG_SENSOR(" ", "TVOC Sensor", this->tvoc_sensor_);
|
||||
LOG_TEXT_SENSOR(" ", "Firmware Version Sensor", this->version_text_sensor_);
|
||||
if (this->baseline_) {
|
||||
ESP_LOGCONFIG(TAG, " Baseline: %04X", *this->baseline_);
|
||||
} else {
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
namespace esphome::ccs811 {
|
||||
|
||||
class CCS811Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(co2)
|
||||
SUB_SENSOR(tvoc)
|
||||
SUB_TEXT_SENSOR(version)
|
||||
// Input sensors for humidity and temperature compensation
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void set_co2(sensor::Sensor *co2) { co2_ = co2; }
|
||||
void set_tvoc(sensor::Sensor *tvoc) { tvoc_ = tvoc; }
|
||||
void set_version(text_sensor::TextSensor *version) { version_ = version; }
|
||||
void set_baseline(uint16_t baseline) { baseline_ = baseline; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
|
||||
/// Setup the sensor and test for a connection.
|
||||
void setup() override;
|
||||
@@ -31,14 +33,7 @@ class CCS811Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
bool status_has_data_() { return this->read_status_().value_or(0) & (1 << 3); }
|
||||
void send_env_data_();
|
||||
|
||||
sensor::Sensor *co2_{nullptr};
|
||||
sensor::Sensor *tvoc_{nullptr};
|
||||
text_sensor::TextSensor *version_{nullptr};
|
||||
optional<uint16_t> baseline_{};
|
||||
/// Input sensor for humidity reading.
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
/// Input sensor for temperature reading.
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ccs811
|
||||
@@ -63,13 +63,13 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_ECO2, var.set_co2)
|
||||
await sensors(CONF_TVOC, var.set_tvoc)
|
||||
await sensors(CONF_ECO2, var.set_co2_sensor)
|
||||
await sensors(CONF_TVOC, var.set_tvoc_sensor)
|
||||
|
||||
text_sensors = text_sensor.sub_text_sensors(config)
|
||||
await text_sensors(CONF_VERSION, var.set_version)
|
||||
await text_sensors(CONF_VERSION, var.set_version_text_sensor)
|
||||
|
||||
cg.add_optional(var.set_baseline, config.get(CONF_BASELINE))
|
||||
|
||||
await cg.add_variable(var.set_temperature, config.get(CONF_TEMPERATURE))
|
||||
await cg.add_variable(var.set_humidity, config.get(CONF_HUMIDITY))
|
||||
await cg.add_variable(var.set_temperature_sensor, config.get(CONF_TEMPERATURE))
|
||||
await cg.add_variable(var.set_humidity_sensor, config.get(CONF_HUMIDITY))
|
||||
@@ -36,14 +36,14 @@ static const uint8_t DPS310_NUM_COEF_REGS = 18; // Number of coefficients w
|
||||
static const int32_t DPS310_SCALE_FACTOR = 1572864; // Measurement compensation scale factor
|
||||
|
||||
class DPS310Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(pressure)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
|
||||
|
||||
protected:
|
||||
/// Configure the sensor; false on a failure.
|
||||
bool setup_registers_();
|
||||
@@ -52,8 +52,6 @@ class DPS310Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void read_temperature_();
|
||||
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure);
|
||||
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *pressure_sensor_{nullptr};
|
||||
int32_t raw_pressure_, raw_temperature_, c00_, c10_;
|
||||
int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_;
|
||||
uint8_t prod_rev_id_;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
namespace esphome::duty_time_sensor {
|
||||
|
||||
class DutyTimeSensor final : public sensor::Sensor, public PollingComponent {
|
||||
SUB_SENSOR(last_duty_time)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
@@ -28,7 +30,6 @@ class DutyTimeSensor final : public sensor::Sensor, public PollingComponent {
|
||||
void set_sensor(binary_sensor::BinarySensor *sensor);
|
||||
#endif
|
||||
void set_lambda(std::function<bool()> &&func) { this->func_ = std::move(func); }
|
||||
void set_last_duty_time_sensor(sensor::Sensor *sensor) { this->last_duty_time_sensor_ = sensor; }
|
||||
void set_restore(bool restore) { this->restore_ = restore; }
|
||||
|
||||
protected:
|
||||
@@ -37,7 +38,6 @@ class DutyTimeSensor final : public sensor::Sensor, public PollingComponent {
|
||||
void publish_and_save_(uint32_t sec, uint32_t ms);
|
||||
|
||||
std::function<bool()> func_{nullptr};
|
||||
sensor::Sensor *last_duty_time_sensor_{nullptr};
|
||||
ESPPreferenceObject pref_;
|
||||
|
||||
uint32_t total_sec_{0};
|
||||
|
||||
@@ -82,6 +82,20 @@ struct SettingsChar {
|
||||
|
||||
/** Hub component for Ecocomfort 2.0 VMC via BLE. */
|
||||
class Ecocomfort2Hub : public esphome::ble_client::BLEClientNode, public PollingComponent {
|
||||
#ifdef USE_SENSOR
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(voc)
|
||||
SUB_SENSOR(direction)
|
||||
#endif
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
SUB_BINARY_SENSOR(connected)
|
||||
SUB_BINARY_SENSOR(boost)
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
SUB_TEXT_SENSOR(firmware)
|
||||
#endif
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
@@ -95,19 +109,6 @@ class Ecocomfort2Hub : public esphome::ble_client::BLEClientNode, public Polling
|
||||
#ifdef ECOCOMFORT2_CHILD_COUNT
|
||||
void register_child(Ecocomfort2Client *obj);
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
void set_temperature_sensor(sensor::Sensor *s) { this->temperature_sensor_ = s; }
|
||||
void set_humidity_sensor(sensor::Sensor *s) { this->humidity_sensor_ = s; }
|
||||
void set_voc_sensor(sensor::Sensor *s) { this->voc_sensor_ = s; }
|
||||
void set_direction_sensor(sensor::Sensor *s) { this->direction_sensor_ = s; }
|
||||
#endif
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
void set_connected_binary_sensor(binary_sensor::BinarySensor *s) { this->connected_binary_sensor_ = s; }
|
||||
void set_boost_binary_sensor(binary_sensor::BinarySensor *s) { this->boost_binary_sensor_ = s; }
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
void set_firmware_text_sensor(text_sensor::TextSensor *s) { this->firmware_text_sensor_ = s; }
|
||||
#endif
|
||||
#ifdef USE_TIME
|
||||
/// Keeps the unit's clock in step with this time source while connected.
|
||||
void set_time(time::RealTimeClock *time) { this->time_ = time; }
|
||||
@@ -184,19 +185,6 @@ class Ecocomfort2Hub : public esphome::ble_client::BLEClientNode, public Polling
|
||||
#ifdef ECOCOMFORT2_CHILD_COUNT
|
||||
StaticVector<Ecocomfort2Client *, ECOCOMFORT2_CHILD_COUNT> children_;
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
sensor::Sensor *voc_sensor_{nullptr};
|
||||
sensor::Sensor *direction_sensor_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *connected_binary_sensor_{nullptr};
|
||||
binary_sensor::BinarySensor *boost_binary_sensor_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *firmware_text_sensor_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_TIME
|
||||
time::RealTimeClock *time_{nullptr};
|
||||
#endif
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace esphome::ee895 {
|
||||
|
||||
/// This class implements support for the ee895 of temperature i2c sensors.
|
||||
class EE895Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_co2_sensor(sensor::Sensor *co2) { co2_sensor_ = co2; }
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
|
||||
SUB_SENSOR(co2)
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(pressure)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
@@ -21,9 +21,6 @@ class EE895Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void write_command_(uint16_t addr, uint16_t reg_cnt);
|
||||
float read_float_();
|
||||
uint16_t calc_crc16_(const uint8_t buf[], uint8_t len);
|
||||
sensor::Sensor *co2_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *pressure_sensor_{nullptr};
|
||||
|
||||
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED, CRC_CHECK_FAILED } error_code_{NONE};
|
||||
};
|
||||
|
||||
@@ -65,14 +65,16 @@ async def to_code_base(config: ConfigType) -> MockObj:
|
||||
await cg.register_component(var, config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_ECO2, var.set_co2)
|
||||
await sensors(CONF_TVOC, var.set_tvoc)
|
||||
await sensors(CONF_AQI, var.set_aqi)
|
||||
await sensors(CONF_ECO2, var.set_co2_sensor)
|
||||
await sensors(CONF_TVOC, var.set_tvoc_sensor)
|
||||
await sensors(CONF_AQI, var.set_aqi_sensor)
|
||||
|
||||
if compensation_config := config.get(CONF_COMPENSATION):
|
||||
await cg.add_variable(
|
||||
var.set_temperature, compensation_config[CONF_TEMPERATURE]
|
||||
var.set_temperature_sensor, compensation_config[CONF_TEMPERATURE]
|
||||
)
|
||||
await cg.add_variable(
|
||||
var.set_humidity_sensor, compensation_config[CONF_HUMIDITY]
|
||||
)
|
||||
await cg.add_variable(var.set_humidity, compensation_config[CONF_HUMIDITY])
|
||||
|
||||
return var
|
||||
@@ -202,8 +202,8 @@ void ENS160Component::update() {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
if (this->co2_ != nullptr) {
|
||||
this->co2_->publish_state(data_eco2);
|
||||
if (this->co2_sensor_ != nullptr) {
|
||||
this->co2_sensor_->publish_state(data_eco2);
|
||||
}
|
||||
|
||||
uint16_t data_tvoc;
|
||||
@@ -212,8 +212,8 @@ void ENS160Component::update() {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
if (this->tvoc_ != nullptr) {
|
||||
this->tvoc_->publish_state(data_tvoc);
|
||||
if (this->tvoc_sensor_ != nullptr) {
|
||||
this->tvoc_sensor_->publish_state(data_tvoc);
|
||||
}
|
||||
|
||||
uint8_t data_aqi;
|
||||
@@ -222,10 +222,10 @@ void ENS160Component::update() {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
if (this->aqi_ != nullptr) {
|
||||
if (this->aqi_sensor_ != nullptr) {
|
||||
// remove reserved bits, just in case they are used in future
|
||||
data_aqi = ENS160_DATA_AQI & data_aqi;
|
||||
this->aqi_->publish_state(data_aqi);
|
||||
this->aqi_sensor_->publish_state(data_aqi);
|
||||
}
|
||||
|
||||
this->status_clear_warning();
|
||||
@@ -235,12 +235,12 @@ void ENS160Component::update() {
|
||||
}
|
||||
|
||||
void ENS160Component::send_env_data_() {
|
||||
if (this->temperature_ == nullptr && this->humidity_ == nullptr)
|
||||
if (this->temperature_sensor_ == nullptr && this->humidity_sensor_ == nullptr)
|
||||
return;
|
||||
|
||||
float temperature = NAN;
|
||||
if (this->temperature_ != nullptr)
|
||||
temperature = this->temperature_->state;
|
||||
if (this->temperature_sensor_ != nullptr)
|
||||
temperature = this->temperature_sensor_->state;
|
||||
|
||||
if (std::isnan(temperature) || temperature < -40.0f || temperature > 85.0f) {
|
||||
ESP_LOGW(TAG, "Invalid external temperature - compensation values not updated");
|
||||
@@ -250,8 +250,8 @@ void ENS160Component::send_env_data_() {
|
||||
}
|
||||
|
||||
float humidity = NAN;
|
||||
if (this->humidity_ != nullptr)
|
||||
humidity = this->humidity_->state;
|
||||
if (this->humidity_sensor_ != nullptr)
|
||||
humidity = this->humidity_sensor_->state;
|
||||
|
||||
if (std::isnan(humidity) || humidity < 0.0f || humidity > 100.0f) {
|
||||
ESP_LOGW(TAG, "Invalid external humidity - compensation values not updated");
|
||||
@@ -285,13 +285,13 @@ void ENS160Component::dump_config() {
|
||||
this->firmware_ver_build_);
|
||||
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "CO2 Sensor:", this->co2_);
|
||||
LOG_SENSOR(" ", "TVOC Sensor:", this->tvoc_);
|
||||
LOG_SENSOR(" ", "AQI Sensor:", this->aqi_);
|
||||
LOG_SENSOR(" ", "CO2 Sensor:", this->co2_sensor_);
|
||||
LOG_SENSOR(" ", "TVOC Sensor:", this->tvoc_sensor_);
|
||||
LOG_SENSOR(" ", "AQI Sensor:", this->aqi_sensor_);
|
||||
|
||||
if (this->temperature_ != nullptr && this->humidity_ != nullptr) {
|
||||
LOG_SENSOR(" ", " Temperature Compensation:", this->temperature_);
|
||||
LOG_SENSOR(" ", " Humidity Compensation:", this->humidity_);
|
||||
if (this->temperature_sensor_ != nullptr && this->humidity_sensor_ != nullptr) {
|
||||
LOG_SENSOR(" ", " Temperature Compensation:", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", " Humidity Compensation:", this->humidity_sensor_);
|
||||
} else {
|
||||
ESP_LOGCONFIG(TAG, " Compensation: Not configured");
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace esphome::ens160_base {
|
||||
|
||||
class ENS160Component : public PollingComponent, public sensor::Sensor {
|
||||
SUB_SENSOR(co2)
|
||||
SUB_SENSOR(tvoc)
|
||||
SUB_SENSOR(aqi)
|
||||
// Input sensors for humidity and temperature compensation
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void set_co2(sensor::Sensor *co2) { co2_ = co2; }
|
||||
void set_tvoc(sensor::Sensor *tvoc) { tvoc_ = tvoc; }
|
||||
void set_aqi(sensor::Sensor *aqi) { aqi_ = aqi; }
|
||||
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
@@ -39,13 +39,6 @@ class ENS160Component : public PollingComponent, public sensor::Sensor {
|
||||
uint8_t firmware_ver_major_{0};
|
||||
uint8_t firmware_ver_minor_{0};
|
||||
uint8_t firmware_ver_build_{0};
|
||||
|
||||
sensor::Sensor *co2_{nullptr};
|
||||
sensor::Sensor *tvoc_{nullptr};
|
||||
sensor::Sensor *aqi_{nullptr};
|
||||
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ens160_base
|
||||
@@ -8,14 +8,14 @@ namespace esphome::ens210 {
|
||||
|
||||
/// This class implements support for the ENS210 relative humidity and temperature i2c sensor.
|
||||
class ENS210Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void dump_config() override;
|
||||
void setup() override;
|
||||
void update() override;
|
||||
|
||||
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
|
||||
enum ErrorCode {
|
||||
ENS210_STATUS_OK = 0, // The value was read, the CRC matches, and data is valid
|
||||
ENS210_STATUS_INVALID, // The value was read, the CRC matches, but the data is invalid (e.g. the measurement was
|
||||
@@ -27,9 +27,6 @@ class ENS210Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
protected:
|
||||
bool set_low_power_(bool enable);
|
||||
void extract_measurement_(uint32_t val, int *data, int *status);
|
||||
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ens210
|
||||
@@ -2820,8 +2820,21 @@ async def _reconcile_mbedtls_sdkconfig() -> None:
|
||||
if option not in data.tls_extras_required:
|
||||
set_idf_sdkconfig_default(option, False)
|
||||
|
||||
# Keeping the peer certificate costs ~4KB heap per connection.
|
||||
if data.peer_cert_required:
|
||||
# Keeping the peer certificate costs ~4KB heap per connection. TLS 1.3
|
||||
# depends on it in Kconfig, which silently drops TLS 1.3 without it.
|
||||
tls13 = is_idf_sdkconfig_option_enabled("CONFIG_MBEDTLS_SSL_PROTO_TLS1_3")
|
||||
if (
|
||||
tls13
|
||||
and "CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" in opts
|
||||
and not is_idf_sdkconfig_option_enabled(
|
||||
"CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
|
||||
)
|
||||
):
|
||||
_LOGGER.warning(
|
||||
"CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 needs "
|
||||
"CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE; TLS 1.3 is disabled"
|
||||
)
|
||||
if data.peer_cert_required or tls13:
|
||||
set_idf_sdkconfig_default("CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE", True)
|
||||
elif data.disable_peer_cert:
|
||||
set_idf_sdkconfig_default("CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE", False)
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
namespace esphome::espectre {
|
||||
|
||||
class ESPectreComponent final : public Component, public ::espectre::IRuntimeListener {
|
||||
#ifdef USE_SELECT
|
||||
SUB_SELECT(traffic_mode)
|
||||
#endif
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
@@ -52,7 +56,6 @@ class ESPectreComponent final : public Component, public ::espectre::IRuntimeLis
|
||||
// Queue controls so entity automations cannot re-enter the SDK from a listener callback.
|
||||
void recalibrate() { this->recalibrate_pending_ = true; }
|
||||
#ifdef USE_SELECT
|
||||
void set_traffic_mode_select(select::Select *value) { this->traffic_mode_select_ = value; }
|
||||
void request_traffic_generator_mode(::espectre::TrafficGeneratorMode mode) { this->pending_traffic_mode_ = mode; }
|
||||
/// Request a mode by its traffic_generator_mode YAML name; unknown names are ignored.
|
||||
void request_traffic_generator_mode(const char *name);
|
||||
@@ -88,7 +91,6 @@ class ESPectreComponent final : public Component, public ::espectre::IRuntimeLis
|
||||
::espectre::RuntimeFrontendController runtime_;
|
||||
uint32_t restart_requested_ms_{0};
|
||||
#ifdef USE_SELECT
|
||||
select::Select *traffic_mode_select_{nullptr};
|
||||
ESPPreferenceObject traffic_mode_pref_;
|
||||
optional<::espectre::TrafficGeneratorMode> pending_traffic_mode_;
|
||||
#endif
|
||||
|
||||
@@ -34,5 +34,5 @@ async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_ID])
|
||||
|
||||
binary_sensors = binary_sensor.sub_binary_sensors(config)
|
||||
await binary_sensors(CONF_PUMP_STATE, hub.set_is_dosing)
|
||||
await binary_sensors(CONF_IS_PAUSED, hub.set_is_paused)
|
||||
await binary_sensors(CONF_PUMP_STATE, hub.set_is_dosing_binary_sensor)
|
||||
await binary_sensors(CONF_IS_PAUSED, hub.set_is_paused_binary_sensor)
|
||||
@@ -63,14 +63,14 @@ void EzoPMP::update() {
|
||||
|
||||
if (this->is_first_read_) {
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_CALIBRATION_STATUS, 0, 0, (bool) this->calibration_status_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_CALIBRATION_STATUS, 0, 0, (bool) this->calibration_status_text_sensor_);
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_MAX_FLOW_RATE, 0, 0, (bool) this->max_flow_rate_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_MAX_FLOW_RATE, 0, 0, (bool) this->max_flow_rate_sensor_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_sensor_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED, 0, 0,
|
||||
(bool) this->absolute_total_volume_dosed_);
|
||||
(bool) this->absolute_total_volume_dosed_sensor_);
|
||||
#endif
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_PAUSE_STATUS, 0, 0, true);
|
||||
this->is_first_read_ = false;
|
||||
@@ -81,13 +81,13 @@ void EzoPMP::update() {
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
if (this->is_dosing_flag_) {
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_sensor_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED, 0, 0,
|
||||
(bool) this->absolute_total_volume_dosed_);
|
||||
(bool) this->absolute_total_volume_dosed_sensor_);
|
||||
}
|
||||
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_PUMP_VOLTAGE, 0, 0, (bool) this->pump_voltage_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_PUMP_VOLTAGE, 0, 0, (bool) this->pump_voltage_sensor_);
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Not Scheduling new Command during update()");
|
||||
@@ -213,20 +213,20 @@ void EzoPMP::read_command_result_() {
|
||||
this->is_dosing_flag_ = parsed_third_parameter.value_or(0) == 1;
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->is_dosing_)
|
||||
this->is_dosing_->publish_state(this->is_dosing_flag_);
|
||||
if (this->is_dosing_binary_sensor_)
|
||||
this->is_dosing_binary_sensor_->publish_state(this->is_dosing_flag_);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->last_volume_requested_) {
|
||||
this->last_volume_requested_->publish_state(parsed_second_parameter.value_or(0));
|
||||
if (parsed_second_parameter.has_value() && this->last_volume_requested_sensor_) {
|
||||
this->last_volume_requested_sensor_->publish_state(parsed_second_parameter.value_or(0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
if (!this->is_dosing_flag_ && !this->is_paused_flag_) {
|
||||
// If pump is not paused and not dispensing
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_NONE);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -234,16 +234,16 @@ void EzoPMP::read_command_result_() {
|
||||
|
||||
case EZO_PMP_COMMAND_READ_SINGLE_REPORT: // Single Report (page 53)
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_first_parameter.has_value() && (bool) this->current_volume_dosed_) {
|
||||
this->current_volume_dosed_->publish_state(parsed_first_parameter.value_or(0));
|
||||
if (parsed_first_parameter.has_value() && (bool) this->current_volume_dosed_sensor_) {
|
||||
this->current_volume_dosed_sensor_->publish_state(parsed_first_parameter.value_or(0));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_READ_MAX_FLOW_RATE: // Constant Flow Rate (page 57)
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->max_flow_rate_)
|
||||
this->max_flow_rate_->publish_state(parsed_second_parameter.value_or(0));
|
||||
if (parsed_second_parameter.has_value() && this->max_flow_rate_sensor_)
|
||||
this->max_flow_rate_sensor_->publish_state(parsed_second_parameter.value_or(0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -252,36 +252,36 @@ void EzoPMP::read_command_result_() {
|
||||
this->is_paused_flag_ = parsed_second_parameter.value_or(0) == 1;
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->is_paused_)
|
||||
this->is_paused_->publish_state(this->is_paused_flag_);
|
||||
if (this->is_paused_binary_sensor_)
|
||||
this->is_paused_binary_sensor_->publish_state(this->is_paused_flag_);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED: // Total Volume Dispensed (page 64)
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->total_volume_dosed_)
|
||||
this->total_volume_dosed_->publish_state(parsed_second_parameter.value_or(0));
|
||||
if (parsed_second_parameter.has_value() && this->total_volume_dosed_sensor_)
|
||||
this->total_volume_dosed_sensor_->publish_state(parsed_second_parameter.value_or(0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED: // Total Volume Dispensed (page 64)
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->absolute_total_volume_dosed_)
|
||||
this->absolute_total_volume_dosed_->publish_state(parsed_second_parameter.value_or(0));
|
||||
if (parsed_second_parameter.has_value() && this->absolute_total_volume_dosed_sensor_)
|
||||
this->absolute_total_volume_dosed_sensor_->publish_state(parsed_second_parameter.value_or(0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_READ_CALIBRATION_STATUS: // Calibration (page 65)
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->calibration_status_) {
|
||||
if (parsed_second_parameter.has_value() && this->calibration_status_text_sensor_) {
|
||||
if (parsed_second_parameter.value_or(0) == 1) {
|
||||
this->calibration_status_->publish_state("Fixed Volume");
|
||||
this->calibration_status_text_sensor_->publish_state("Fixed Volume");
|
||||
} else if (parsed_second_parameter.value_or(0) == 2) {
|
||||
this->calibration_status_->publish_state("Volume/Time");
|
||||
this->calibration_status_text_sensor_->publish_state("Volume/Time");
|
||||
} else if (parsed_second_parameter.value_or(0) == 3) {
|
||||
this->calibration_status_->publish_state("Fixed Volume & Volume/Time");
|
||||
this->calibration_status_text_sensor_->publish_state("Fixed Volume & Volume/Time");
|
||||
} else {
|
||||
this->calibration_status_->publish_state("Uncalibrated");
|
||||
this->calibration_status_text_sensor_->publish_state("Uncalibrated");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -289,8 +289,8 @@ void EzoPMP::read_command_result_() {
|
||||
|
||||
case EZO_PMP_COMMAND_READ_PUMP_VOLTAGE: // Pump Voltage (page 67)
|
||||
#ifdef USE_SENSOR
|
||||
if (parsed_second_parameter.has_value() && this->pump_voltage_)
|
||||
this->pump_voltage_->publish_state(parsed_second_parameter.value_or(0));
|
||||
if (parsed_second_parameter.has_value() && this->pump_voltage_sensor_)
|
||||
this->pump_voltage_sensor_->publish_state(parsed_second_parameter.value_or(0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -298,36 +298,36 @@ void EzoPMP::read_command_result_() {
|
||||
|
||||
case EZO_PMP_COMMAND_DOSE_VOLUME: // Volume Dispensing (page 55)
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_VOLUME);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_VOLUME);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME: // Dose over time (page 56)
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_VOLUME_OVER_TIME);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_VOLUME_OVER_TIME);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE: // Constant Flow Rate (page 57)
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_CONSTANT_FLOW_RATE);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_CONSTANT_FLOW_RATE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_DOSE_CONTINUOUSLY: // Continuous Dispensing (page 54)
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_CONTINUOUS);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_CONTINUOUS);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EZO_PMP_COMMAND_STOP_DOSING: // Stop (page 62)
|
||||
this->is_paused_flag_ = false;
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->is_paused_)
|
||||
this->is_paused_->publish_state(this->is_paused_flag_);
|
||||
if (this->is_paused_binary_sensor_)
|
||||
this->is_paused_binary_sensor_->publish_state(this->is_paused_flag_);
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
publish_dosing_mode(this->dosing_mode_, DOSING_MODE_NONE);
|
||||
publish_dosing_mode(this->dosing_mode_text_sensor_, DOSING_MODE_NONE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -536,7 +536,7 @@ void EzoPMP::dose_continuously() {
|
||||
this->queue_command_(EZO_PMP_COMMAND_DOSE_CONTINUOUSLY, 0, 0, true);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
|
||||
#ifdef USE_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ void EzoPMP::dose_volume(double volume) {
|
||||
this->queue_command_(EZO_PMP_COMMAND_DOSE_VOLUME, volume, 0, true);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
|
||||
#ifdef USE_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ void EzoPMP::dose_volume_over_time(double volume, int duration) {
|
||||
this->queue_command_(EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME, volume, duration, true);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
|
||||
#ifdef USE_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ void EzoPMP::dose_with_constant_flow_rate(double volume, int duration) {
|
||||
this->queue_command_(EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE, volume, duration, true);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
|
||||
#ifdef USE_SENSOR
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
|
||||
this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_sensor_);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -25,29 +25,6 @@ class EzoPMP final : public PollingComponent, public i2c::I2CDevice {
|
||||
void loop() override;
|
||||
void update() override;
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
void set_current_volume_dosed(sensor::Sensor *current_volume_dosed) { current_volume_dosed_ = current_volume_dosed; }
|
||||
void set_total_volume_dosed(sensor::Sensor *total_volume_dosed) { total_volume_dosed_ = total_volume_dosed; }
|
||||
void set_absolute_total_volume_dosed(sensor::Sensor *absolute_total_volume_dosed) {
|
||||
absolute_total_volume_dosed_ = absolute_total_volume_dosed;
|
||||
}
|
||||
void set_pump_voltage(sensor::Sensor *pump_voltage) { pump_voltage_ = pump_voltage; }
|
||||
void set_last_volume_requested(sensor::Sensor *last_volume_requested) {
|
||||
last_volume_requested_ = last_volume_requested;
|
||||
}
|
||||
void set_max_flow_rate(sensor::Sensor *max_flow_rate) { max_flow_rate_ = max_flow_rate; }
|
||||
#endif
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
void set_is_dosing(binary_sensor::BinarySensor *is_dosing) { is_dosing_ = is_dosing; }
|
||||
void set_is_paused(binary_sensor::BinarySensor *is_paused) { is_paused_ = is_paused; }
|
||||
#endif
|
||||
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
void set_dosing_mode(text_sensor::TextSensor *dosing_mode) { dosing_mode_ = dosing_mode; }
|
||||
void set_calibration_status(text_sensor::TextSensor *calibration_status) { calibration_status_ = calibration_status; }
|
||||
#endif
|
||||
|
||||
// Actions for EZO-PMP
|
||||
void find();
|
||||
void dose_continuously();
|
||||
@@ -93,22 +70,24 @@ class EzoPMP final : public PollingComponent, public i2c::I2CDevice {
|
||||
uint16_t peek_next_command_();
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
sensor::Sensor *current_volume_dosed_{nullptr};
|
||||
sensor::Sensor *total_volume_dosed_{nullptr};
|
||||
sensor::Sensor *absolute_total_volume_dosed_{nullptr};
|
||||
sensor::Sensor *pump_voltage_{nullptr};
|
||||
sensor::Sensor *max_flow_rate_{nullptr};
|
||||
sensor::Sensor *last_volume_requested_{nullptr};
|
||||
SUB_SENSOR(current_volume_dosed)
|
||||
SUB_SENSOR(total_volume_dosed)
|
||||
SUB_SENSOR(absolute_total_volume_dosed)
|
||||
SUB_SENSOR(pump_voltage)
|
||||
SUB_SENSOR(max_flow_rate)
|
||||
SUB_SENSOR(last_volume_requested)
|
||||
protected:
|
||||
#endif
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *is_dosing_{nullptr};
|
||||
binary_sensor::BinarySensor *is_paused_{nullptr};
|
||||
SUB_BINARY_SENSOR(is_dosing)
|
||||
SUB_BINARY_SENSOR(is_paused)
|
||||
protected:
|
||||
#endif
|
||||
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *dosing_mode_{nullptr};
|
||||
text_sensor::TextSensor *calibration_status_{nullptr};
|
||||
SUB_TEXT_SENSOR(dosing_mode)
|
||||
SUB_TEXT_SENSOR(calibration_status)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -79,9 +79,11 @@ async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_ID])
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_CURRENT_VOLUME_DOSED, hub.set_current_volume_dosed)
|
||||
await sensors(CONF_LAST_VOLUME_REQUESTED, hub.set_last_volume_requested)
|
||||
await sensors(CONF_TOTAL_VOLUME_DOSED, hub.set_total_volume_dosed)
|
||||
await sensors(CONF_ABSOLUTE_TOTAL_VOLUME_DOSED, hub.set_absolute_total_volume_dosed)
|
||||
await sensors(CONF_PUMP_VOLTAGE, hub.set_pump_voltage)
|
||||
await sensors(CONF_MAX_FLOW_RATE, hub.set_max_flow_rate)
|
||||
await sensors(CONF_CURRENT_VOLUME_DOSED, hub.set_current_volume_dosed_sensor)
|
||||
await sensors(CONF_LAST_VOLUME_REQUESTED, hub.set_last_volume_requested_sensor)
|
||||
await sensors(CONF_TOTAL_VOLUME_DOSED, hub.set_total_volume_dosed_sensor)
|
||||
await sensors(
|
||||
CONF_ABSOLUTE_TOTAL_VOLUME_DOSED, hub.set_absolute_total_volume_dosed_sensor
|
||||
)
|
||||
await sensors(CONF_PUMP_VOLTAGE, hub.set_pump_voltage_sensor)
|
||||
await sensors(CONF_MAX_FLOW_RATE, hub.set_max_flow_rate_sensor)
|
||||
@@ -27,5 +27,5 @@ async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_ID])
|
||||
|
||||
text_sensors = text_sensor.sub_text_sensors(config)
|
||||
await text_sensors(CONF_DOSING_MODE, hub.set_dosing_mode)
|
||||
await text_sensors(CONF_CALIBRATION_STATUS, hub.set_calibration_status)
|
||||
await text_sensors(CONF_DOSING_MODE, hub.set_dosing_mode_text_sensor)
|
||||
await text_sensors(CONF_CALIBRATION_STATUS, hub.set_calibration_status_text_sensor)
|
||||
@@ -66,8 +66,8 @@ void FilterLifetime::reset_filter() {
|
||||
bool FilterLifetime::get_is_on_() {
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
// Reads false until the sensor first publishes, so nothing accumulates before then.
|
||||
if (this->is_on_sensor_ != nullptr)
|
||||
return this->is_on_sensor_->state;
|
||||
if (this->is_on_binary_sensor_ != nullptr)
|
||||
return this->is_on_binary_sensor_->state;
|
||||
#endif
|
||||
if (this->is_on_lambda_ != nullptr)
|
||||
return this->is_on_lambda_();
|
||||
@@ -90,8 +90,8 @@ void FilterLifetime::dump_config() {
|
||||
this->max_lifetime_minutes_, this->max_lifetime_minutes_ / MINUTES_PER_DAY,
|
||||
this->runtime_seconds_ / 3600.0f);
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->is_on_sensor_ != nullptr) {
|
||||
LOG_BINARY_SENSOR(" ", "Is-on sensor", this->is_on_sensor_);
|
||||
if (this->is_on_binary_sensor_ != nullptr) {
|
||||
LOG_BINARY_SENSOR(" ", "Is-on sensor", this->is_on_binary_sensor_);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
namespace esphome::filter_lifetime {
|
||||
|
||||
class FilterLifetime : public sensor::Sensor, public PollingComponent {
|
||||
SUB_SENSOR(runtime_hours)
|
||||
SUB_SENSOR(remaining_days)
|
||||
// Input sensors for the running state and speed
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
SUB_BINARY_SENSOR(is_on)
|
||||
#endif
|
||||
SUB_SENSOR(current_speed)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
@@ -19,13 +27,7 @@ class FilterLifetime : public sensor::Sensor, public PollingComponent {
|
||||
|
||||
void set_max_lifetime(uint32_t minutes) { this->max_lifetime_minutes_ = minutes; }
|
||||
void set_is_on_lambda(bool (*is_on)()) { this->is_on_lambda_ = is_on; }
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
void set_is_on_sensor(binary_sensor::BinarySensor *sensor) { this->is_on_sensor_ = sensor; }
|
||||
#endif
|
||||
void set_current_speed_lambda(float (*speed)()) { this->current_speed_lambda_ = speed; }
|
||||
void set_current_speed_sensor(sensor::Sensor *sensor) { this->current_speed_sensor_ = sensor; }
|
||||
void set_runtime_hours_sensor(sensor::Sensor *sensor) { this->runtime_hours_sensor_ = sensor; }
|
||||
void set_remaining_days_sensor(sensor::Sensor *sensor) { this->remaining_days_sensor_ = sensor; }
|
||||
|
||||
protected:
|
||||
bool get_is_on_();
|
||||
@@ -34,12 +36,6 @@ class FilterLifetime : public sensor::Sensor, public PollingComponent {
|
||||
|
||||
bool (*is_on_lambda_)(){nullptr};
|
||||
float (*current_speed_lambda_)(){nullptr};
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *is_on_sensor_{nullptr};
|
||||
#endif
|
||||
sensor::Sensor *current_speed_sensor_{nullptr};
|
||||
sensor::Sensor *runtime_hours_sensor_{nullptr};
|
||||
sensor::Sensor *remaining_days_sensor_{nullptr};
|
||||
ESPPreferenceObject pref_;
|
||||
uint32_t max_lifetime_minutes_{0};
|
||||
uint32_t last_update_{0};
|
||||
|
||||
@@ -72,7 +72,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
|
||||
if (is_on := config.get(CONF_IS_ON)) is not None:
|
||||
cg.add(var.set_is_on_lambda(await cg.templatable(is_on, [], bool)))
|
||||
await cg.add_variable(var.set_is_on_sensor, config.get(CONF_IS_ON_SENSOR))
|
||||
await cg.add_variable(var.set_is_on_binary_sensor, config.get(CONF_IS_ON_SENSOR))
|
||||
|
||||
if (current_speed := config.get(CONF_CURRENT_SPEED)) is not None:
|
||||
cg.add(
|
||||
|
||||
@@ -92,6 +92,14 @@ enum GrowAuraLEDColor {
|
||||
};
|
||||
|
||||
class FingerprintGrowComponent final : public PollingComponent, public uart::UARTDevice {
|
||||
SUB_SENSOR(fingerprint_count)
|
||||
SUB_SENSOR(status)
|
||||
SUB_SENSOR(capacity)
|
||||
SUB_SENSOR(security_level)
|
||||
SUB_SENSOR(last_finger_id)
|
||||
SUB_SENSOR(last_confidence)
|
||||
SUB_BINARY_SENSOR(enrolling)
|
||||
|
||||
public:
|
||||
void update() override;
|
||||
void setup() override;
|
||||
@@ -108,23 +116,6 @@ class FingerprintGrowComponent final : public PollingComponent, public uart::UAR
|
||||
void set_password(uint32_t password) { this->password_ = password; }
|
||||
void set_new_password(uint32_t new_password) { this->new_password_ = new_password; }
|
||||
void set_idle_period_to_sleep_ms(uint32_t period_ms) { this->idle_period_to_sleep_ms_ = period_ms; }
|
||||
void set_fingerprint_count_sensor(sensor::Sensor *fingerprint_count_sensor) {
|
||||
this->fingerprint_count_sensor_ = fingerprint_count_sensor;
|
||||
}
|
||||
void set_status_sensor(sensor::Sensor *status_sensor) { this->status_sensor_ = status_sensor; }
|
||||
void set_capacity_sensor(sensor::Sensor *capacity_sensor) { this->capacity_sensor_ = capacity_sensor; }
|
||||
void set_security_level_sensor(sensor::Sensor *security_level_sensor) {
|
||||
this->security_level_sensor_ = security_level_sensor;
|
||||
}
|
||||
void set_last_finger_id_sensor(sensor::Sensor *last_finger_id_sensor) {
|
||||
this->last_finger_id_sensor_ = last_finger_id_sensor;
|
||||
}
|
||||
void set_last_confidence_sensor(sensor::Sensor *last_confidence_sensor) {
|
||||
this->last_confidence_sensor_ = last_confidence_sensor;
|
||||
}
|
||||
void set_enrolling_binary_sensor(binary_sensor::BinarySensor *enrolling_binary_sensor) {
|
||||
this->enrolling_binary_sensor_ = enrolling_binary_sensor;
|
||||
}
|
||||
template<typename F> void add_on_finger_scan_start_callback(F &&callback) {
|
||||
this->finger_scan_start_callback_.add(std::forward<F>(callback));
|
||||
}
|
||||
@@ -191,13 +182,6 @@ class FingerprintGrowComponent final : public PollingComponent, public uart::UAR
|
||||
uint32_t last_aura_led_duration_ = 0;
|
||||
uint16_t system_identifier_code_ = 0;
|
||||
uint32_t idle_period_to_sleep_ms_ = UINT32_MAX;
|
||||
sensor::Sensor *fingerprint_count_sensor_{nullptr};
|
||||
sensor::Sensor *status_sensor_{nullptr};
|
||||
sensor::Sensor *capacity_sensor_{nullptr};
|
||||
sensor::Sensor *security_level_sensor_{nullptr};
|
||||
sensor::Sensor *last_finger_id_sensor_{nullptr};
|
||||
sensor::Sensor *last_confidence_sensor_{nullptr};
|
||||
binary_sensor::BinarySensor *enrolling_binary_sensor_{nullptr};
|
||||
CallbackManager<void()> finger_scan_invalid_callback_;
|
||||
CallbackManager<void()> finger_scan_start_callback_;
|
||||
CallbackManager<void(uint16_t, uint16_t)> finger_scan_matched_callback_;
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace esphome::fusb302b {
|
||||
/// A dedicated task owns all I2C traffic to the chip so that PD replies meet the protocol timing
|
||||
/// even while the main loop is busy. The main loop only publishes state changes.
|
||||
class FUSB302B : public PowerDelivery, public Component, public i2c::I2CDevice {
|
||||
#ifdef USE_SENSOR
|
||||
SUB_SENSOR(voltage)
|
||||
SUB_SENSOR(current)
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
SUB_TEXT_SENSOR(contract)
|
||||
#endif
|
||||
|
||||
public:
|
||||
explicit FUSB302B(InternalGPIOPin *interrupt_pin) : interrupt_pin_(interrupt_pin) {}
|
||||
|
||||
@@ -51,14 +59,6 @@ class FUSB302B : public PowerDelivery, public Component, public i2c::I2CDevice {
|
||||
this->request_failed_callback_.add(std::forward<F>(callback));
|
||||
}
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
void set_voltage_sensor(sensor::Sensor *sensor) { this->voltage_sensor_ = sensor; }
|
||||
void set_current_sensor(sensor::Sensor *sensor) { this->current_sensor_ = sensor; }
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
void set_contract_text_sensor(text_sensor::TextSensor *sensor) { this->contract_text_sensor_ = sensor; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
enum class SourceCapStep : uint8_t {
|
||||
SOURCE_CAP_STEP_WAIT,
|
||||
@@ -129,13 +129,6 @@ class FUSB302B : public PowerDelivery, public Component, public i2c::I2CDevice {
|
||||
|
||||
LazyCallbackManager<void(PdState, PdState)> state_callback_;
|
||||
LazyCallbackManager<void()> request_failed_callback_;
|
||||
#ifdef USE_SENSOR
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *contract_text_sensor_{nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace esphome::fusb302b
|
||||
|
||||
@@ -8,21 +8,20 @@
|
||||
namespace esphome::gcja5 {
|
||||
|
||||
class GCJA5Component final : public Component, public uart::UARTDevice {
|
||||
SUB_SENSOR(pm_1_0)
|
||||
SUB_SENSOR(pm_2_5)
|
||||
SUB_SENSOR(pm_10_0)
|
||||
SUB_SENSOR(pmc_0_3)
|
||||
SUB_SENSOR(pmc_0_5)
|
||||
SUB_SENSOR(pmc_1_0)
|
||||
SUB_SENSOR(pmc_2_5)
|
||||
SUB_SENSOR(pmc_5_0)
|
||||
SUB_SENSOR(pmc_10_0)
|
||||
|
||||
public:
|
||||
void dump_config() override;
|
||||
void loop() override;
|
||||
|
||||
void set_pm_1_0_sensor(sensor::Sensor *pm_1_0) { pm_1_0_sensor_ = pm_1_0; }
|
||||
void set_pm_2_5_sensor(sensor::Sensor *pm_2_5) { pm_2_5_sensor_ = pm_2_5; }
|
||||
void set_pm_10_0_sensor(sensor::Sensor *pm_10_0) { pm_10_0_sensor_ = pm_10_0; }
|
||||
|
||||
void set_pmc_0_3_sensor(sensor::Sensor *pmc_0_3) { pmc_0_3_sensor_ = pmc_0_3; }
|
||||
void set_pmc_0_5_sensor(sensor::Sensor *pmc_0_5) { pmc_0_5_sensor_ = pmc_0_5; }
|
||||
void set_pmc_1_0_sensor(sensor::Sensor *pmc_1_0) { pmc_1_0_sensor_ = pmc_1_0; }
|
||||
void set_pmc_2_5_sensor(sensor::Sensor *pmc_2_5) { pmc_2_5_sensor_ = pmc_2_5; }
|
||||
void set_pmc_5_0_sensor(sensor::Sensor *pmc_5_0) { pmc_5_0_sensor_ = pmc_5_0; }
|
||||
void set_pmc_10_0_sensor(sensor::Sensor *pmc_10_0) { pmc_10_0_sensor_ = pmc_10_0; }
|
||||
|
||||
protected:
|
||||
void parse_data_();
|
||||
bool calculate_checksum_();
|
||||
@@ -39,16 +38,6 @@ class GCJA5Component final : public Component, public uart::UARTDevice {
|
||||
|
||||
bool have_good_data_{false};
|
||||
bool first_status_log_{false};
|
||||
sensor::Sensor *pm_1_0_sensor_{nullptr};
|
||||
sensor::Sensor *pm_2_5_sensor_{nullptr};
|
||||
sensor::Sensor *pm_10_0_sensor_{nullptr};
|
||||
|
||||
sensor::Sensor *pmc_0_3_sensor_{nullptr};
|
||||
sensor::Sensor *pmc_0_5_sensor_{nullptr};
|
||||
sensor::Sensor *pmc_1_0_sensor_{nullptr};
|
||||
sensor::Sensor *pmc_2_5_sensor_{nullptr};
|
||||
sensor::Sensor *pmc_5_0_sensor_{nullptr};
|
||||
sensor::Sensor *pmc_10_0_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::gcja5
|
||||
@@ -22,15 +22,15 @@ class GPSListener {
|
||||
};
|
||||
|
||||
class GPS final : public PollingComponent, public uart::UARTDevice {
|
||||
public:
|
||||
void set_latitude_sensor(sensor::Sensor *latitude_sensor) { this->latitude_sensor_ = latitude_sensor; }
|
||||
void set_longitude_sensor(sensor::Sensor *longitude_sensor) { this->longitude_sensor_ = longitude_sensor; }
|
||||
void set_speed_sensor(sensor::Sensor *speed_sensor) { this->speed_sensor_ = speed_sensor; }
|
||||
void set_course_sensor(sensor::Sensor *course_sensor) { this->course_sensor_ = course_sensor; }
|
||||
void set_altitude_sensor(sensor::Sensor *altitude_sensor) { this->altitude_sensor_ = altitude_sensor; }
|
||||
void set_satellites_sensor(sensor::Sensor *satellites_sensor) { this->satellites_sensor_ = satellites_sensor; }
|
||||
void set_hdop_sensor(sensor::Sensor *hdop_sensor) { this->hdop_sensor_ = hdop_sensor; }
|
||||
SUB_SENSOR(latitude)
|
||||
SUB_SENSOR(longitude)
|
||||
SUB_SENSOR(speed)
|
||||
SUB_SENSOR(course)
|
||||
SUB_SENSOR(altitude)
|
||||
SUB_SENSOR(satellites)
|
||||
SUB_SENSOR(hdop)
|
||||
|
||||
public:
|
||||
#ifdef GPS_LISTENER_COUNT
|
||||
void register_listener(GPSListener *listener) {
|
||||
listener->parent_ = this;
|
||||
@@ -55,14 +55,6 @@ class GPS final : public PollingComponent, public uart::UARTDevice {
|
||||
uint16_t satellites_{0};
|
||||
bool has_time_{false};
|
||||
|
||||
sensor::Sensor *latitude_sensor_{nullptr};
|
||||
sensor::Sensor *longitude_sensor_{nullptr};
|
||||
sensor::Sensor *speed_sensor_{nullptr};
|
||||
sensor::Sensor *course_sensor_{nullptr};
|
||||
sensor::Sensor *altitude_sensor_{nullptr};
|
||||
sensor::Sensor *satellites_sensor_{nullptr};
|
||||
sensor::Sensor *hdop_sensor_{nullptr};
|
||||
|
||||
TinyGPSPlus tiny_gps_;
|
||||
#ifdef GPS_LISTENER_COUNT
|
||||
StaticVector<GPSListener *, GPS_LISTENER_COUNT> listeners_;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
namespace esphome::hc8 {
|
||||
|
||||
class HC8Component final : public PollingComponent, public uart::UARTDevice {
|
||||
SUB_SENSOR(co2)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
@@ -16,11 +18,9 @@ class HC8Component final : public PollingComponent, public uart::UARTDevice {
|
||||
|
||||
void calibrate(uint16_t baseline);
|
||||
|
||||
void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
|
||||
void set_warmup_seconds(uint32_t seconds) { warmup_seconds_ = seconds; }
|
||||
|
||||
protected:
|
||||
sensor::Sensor *co2_sensor_{nullptr};
|
||||
uint32_t warmup_seconds_{0};
|
||||
bool warmup_complete_{false};
|
||||
};
|
||||
|
||||
@@ -25,8 +25,8 @@ void HDC1080Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "HDC1080:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
}
|
||||
|
||||
void HDC1080Component::update() {
|
||||
@@ -47,10 +47,10 @@ void HDC1080Component::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->temperature_ != nullptr) {
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
raw_temperature = i2c::i2ctohs(raw_temperature);
|
||||
float temperature = raw_temperature * 0.0025177f - 40.0f; // raw * 2^-16 * 165 - 40
|
||||
this->temperature_->publish_state(temperature);
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
}
|
||||
|
||||
if (this->write(&HDC1080_CMD_HUMIDITY, 1) != i2c::ERROR_OK) {
|
||||
@@ -65,10 +65,10 @@ void HDC1080Component::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->humidity_ != nullptr) {
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
raw_humidity = i2c::i2ctohs(raw_humidity);
|
||||
float humidity = raw_humidity * 0.001525879f; // raw * 2^-16 * 100
|
||||
this->humidity_->publish_state(humidity);
|
||||
this->humidity_sensor_->publish_state(humidity);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,17 +7,13 @@
|
||||
namespace esphome::hdc1080 {
|
||||
|
||||
class HDC1080Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::hdc1080
|
||||
@@ -46,5 +46,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
@@ -7,11 +7,10 @@
|
||||
namespace esphome::hdc2010 {
|
||||
|
||||
class HDC2010Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void set_temperature_sensor(sensor::Sensor *temperature) { this->temperature_sensor_ = temperature; }
|
||||
|
||||
void set_humidity_sensor(sensor::Sensor *humidity) { this->humidity_sensor_ = humidity; }
|
||||
|
||||
/// Setup the sensor and check for connection.
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -21,10 +20,6 @@ class HDC2010Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
float read_temp();
|
||||
|
||||
float read_humidity();
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::hdc2010
|
||||
@@ -7,18 +7,14 @@
|
||||
namespace esphome::hdc2080 {
|
||||
|
||||
class HDC2080Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature(sensor::Sensor *temperature) { this->temperature_sensor_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { this->humidity_sensor_ = humidity; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
/// Setup the sensor and check for connection.
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::hdc2080
|
||||
@@ -47,5 +47,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
@@ -43,7 +43,7 @@ void HDC302XComponent::dump_config() {
|
||||
this->heater_active_ ? LOG_STR_LITERAL("active") : LOG_STR_LITERAL("inactive"));
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "Temperature", this->temp_sensor_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
}
|
||||
|
||||
@@ -137,11 +137,11 @@ void HDC302XComponent::read_data_() {
|
||||
if (!this->status_comm_result(crc_ok, LOG_STR("Read data: invalid CRC")))
|
||||
return;
|
||||
|
||||
if (this->temp_sensor_ != nullptr) {
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
uint16_t raw_t = encode_uint16(buf[0], buf[1]);
|
||||
// Calculate temperature in Celsius per datasheet section 7.3.3.
|
||||
float temp = -45 + 175 * (float(raw_t) / 65535.0f);
|
||||
this->temp_sensor_->publish_state(temp);
|
||||
this->temperature_sensor_->publish_state(temp);
|
||||
}
|
||||
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
|
||||
@@ -20,6 +20,9 @@ enum HDC302XPowerMode : uint8_t {
|
||||
https://www.ti.com/lit/ds/symlink/hdc3020.pdf
|
||||
*/
|
||||
class HDC302XComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -28,15 +31,9 @@ class HDC302XComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
void start_heater(uint16_t power, uint32_t duration_ms);
|
||||
void stop_heater();
|
||||
|
||||
void set_temp_sensor(sensor::Sensor *temp_sensor) { this->temp_sensor_ = temp_sensor; }
|
||||
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { this->humidity_sensor_ = humidity_sensor; }
|
||||
|
||||
void set_power_mode(HDC302XPowerMode power_mode) { this->power_mode_ = power_mode; }
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temp_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
|
||||
HDC302XPowerMode power_mode_{HDC302XPowerMode::HIGH_ACCURACY};
|
||||
bool heater_active_{false};
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temp_sensor)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
|
||||
cg.add(var.set_power_mode(config[CONF_POWER_MODE]))
|
||||
|
||||
@@ -72,25 +72,18 @@ enum HlkFm22xFaceDirection {
|
||||
};
|
||||
|
||||
class HlkFm22xComponent final : public PollingComponent, public uart::UARTDevice {
|
||||
SUB_SENSOR(face_count)
|
||||
SUB_SENSOR(status)
|
||||
SUB_SENSOR(last_face_id)
|
||||
SUB_TEXT_SENSOR(last_face_name)
|
||||
SUB_BINARY_SENSOR(enrolling)
|
||||
SUB_TEXT_SENSOR(version)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
||||
void set_face_count_sensor(sensor::Sensor *face_count_sensor) { this->face_count_sensor_ = face_count_sensor; }
|
||||
void set_status_sensor(sensor::Sensor *status_sensor) { this->status_sensor_ = status_sensor; }
|
||||
void set_last_face_id_sensor(sensor::Sensor *last_face_id_sensor) {
|
||||
this->last_face_id_sensor_ = last_face_id_sensor;
|
||||
}
|
||||
void set_last_face_name_text_sensor(text_sensor::TextSensor *last_face_name_text_sensor) {
|
||||
this->last_face_name_text_sensor_ = last_face_name_text_sensor;
|
||||
}
|
||||
void set_enrolling_binary_sensor(binary_sensor::BinarySensor *enrolling_binary_sensor) {
|
||||
this->enrolling_binary_sensor_ = enrolling_binary_sensor;
|
||||
}
|
||||
void set_version_text_sensor(text_sensor::TextSensor *version_text_sensor) {
|
||||
this->version_text_sensor_ = version_text_sensor;
|
||||
}
|
||||
template<typename F> void add_on_face_scan_matched_callback(F &&callback) {
|
||||
this->face_scan_matched_callback_.add(std::forward<F>(callback));
|
||||
}
|
||||
@@ -127,12 +120,6 @@ class HlkFm22xComponent final : public PollingComponent, public uart::UARTDevice
|
||||
std::array<uint8_t, HLK_FM22X_MAX_RESPONSE_SIZE> recv_buf_;
|
||||
HlkFm22xCommand active_command_ = HlkFm22xCommand::NONE;
|
||||
uint16_t wait_cycles_ = 0;
|
||||
sensor::Sensor *face_count_sensor_{nullptr};
|
||||
sensor::Sensor *status_sensor_{nullptr};
|
||||
sensor::Sensor *last_face_id_sensor_{nullptr};
|
||||
binary_sensor::BinarySensor *enrolling_binary_sensor_{nullptr};
|
||||
text_sensor::TextSensor *last_face_name_text_sensor_{nullptr};
|
||||
text_sensor::TextSensor *version_text_sensor_{nullptr};
|
||||
CallbackManager<void(uint8_t)> face_scan_invalid_callback_;
|
||||
CallbackManager<void(int16_t, std::string)> face_scan_matched_callback_;
|
||||
CallbackManager<void()> face_scan_unmatched_callback_;
|
||||
|
||||
@@ -24,6 +24,11 @@ enum HLW8012SensorModels {
|
||||
#endif
|
||||
|
||||
class HLW8012Component final : public PollingComponent {
|
||||
SUB_SENSOR(voltage)
|
||||
SUB_SENSOR(current)
|
||||
SUB_SENSOR(power)
|
||||
SUB_SENSOR(energy)
|
||||
|
||||
public:
|
||||
HLW8012Component()
|
||||
: cf_store_(*pulse_counter::get_storage(USE_PCNT)), cf1_store_(*pulse_counter::get_storage(USE_PCNT)) {}
|
||||
@@ -42,10 +47,6 @@ class HLW8012Component final : public PollingComponent {
|
||||
void set_sel_pin(GPIOPin *sel_pin) { sel_pin_ = sel_pin; }
|
||||
void set_cf_pin(InternalGPIOPin *cf_pin) { cf_pin_ = cf_pin; }
|
||||
void set_cf1_pin(InternalGPIOPin *cf1_pin) { cf1_pin_ = cf1_pin; }
|
||||
void set_voltage_sensor(sensor::Sensor *voltage_sensor) { voltage_sensor_ = voltage_sensor; }
|
||||
void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { power_sensor_ = power_sensor; }
|
||||
void set_energy_sensor(sensor::Sensor *energy_sensor) { energy_sensor_ = energy_sensor; }
|
||||
|
||||
protected:
|
||||
uint32_t nth_value_{0};
|
||||
@@ -61,10 +62,6 @@ class HLW8012Component final : public PollingComponent {
|
||||
pulse_counter::PulseCounterStorageBase &cf_store_;
|
||||
InternalGPIOPin *cf1_pin_;
|
||||
pulse_counter::PulseCounterStorageBase &cf1_store_;
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
sensor::Sensor *power_sensor_{nullptr};
|
||||
sensor::Sensor *energy_sensor_{nullptr};
|
||||
|
||||
float voltage_multiplier_{0.0f};
|
||||
float current_multiplier_{0.0f};
|
||||
|
||||
@@ -7,32 +7,23 @@
|
||||
namespace esphome::hlw8032 {
|
||||
|
||||
class HLW8032Component final : public Component, public uart::UARTDevice {
|
||||
SUB_SENSOR(voltage)
|
||||
SUB_SENSOR(current)
|
||||
SUB_SENSOR(power)
|
||||
SUB_SENSOR(apparent_power)
|
||||
SUB_SENSOR(power_factor)
|
||||
|
||||
public:
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
|
||||
void set_current_resistor(float current_resistor) { this->current_resistor_ = current_resistor; }
|
||||
void set_voltage_divider(float voltage_divider) { this->voltage_divider_ = voltage_divider; }
|
||||
void set_voltage_sensor(sensor::Sensor *voltage_sensor) { this->voltage_sensor_ = voltage_sensor; }
|
||||
void set_current_sensor(sensor::Sensor *current_sensor) { this->current_sensor_ = current_sensor; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { this->power_sensor_ = power_sensor; }
|
||||
void set_apparent_power_sensor(sensor::Sensor *apparent_power_sensor) {
|
||||
this->apparent_power_sensor_ = apparent_power_sensor;
|
||||
}
|
||||
void set_power_factor_sensor(sensor::Sensor *power_factor_sensor) {
|
||||
this->power_factor_sensor_ = power_factor_sensor;
|
||||
}
|
||||
|
||||
protected:
|
||||
void parse_data_();
|
||||
uint32_t read_uint24_(uint8_t offset);
|
||||
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
sensor::Sensor *power_sensor_{nullptr};
|
||||
sensor::Sensor *apparent_power_sensor_{nullptr};
|
||||
sensor::Sensor *power_factor_sensor_{nullptr};
|
||||
|
||||
float current_resistor_{0.001f};
|
||||
float voltage_divider_{1.720f};
|
||||
uint8_t raw_data_[24]{};
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace esphome::hm3301 {
|
||||
static const uint8_t SELECT_COMM_CMD = 0x88;
|
||||
|
||||
class HM3301Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(pm_1_0)
|
||||
SUB_SENSOR(pm_2_5)
|
||||
SUB_SENSOR(pm_10_0)
|
||||
SUB_SENSOR(aqi)
|
||||
|
||||
public:
|
||||
HM3301Component() = default;
|
||||
|
||||
void set_pm_1_0_sensor(sensor::Sensor *pm_1_0_sensor) { pm_1_0_sensor_ = pm_1_0_sensor; }
|
||||
void set_pm_2_5_sensor(sensor::Sensor *pm_2_5_sensor) { pm_2_5_sensor_ = pm_2_5_sensor; }
|
||||
void set_pm_10_0_sensor(sensor::Sensor *pm_10_0_sensor) { pm_10_0_sensor_ = pm_10_0_sensor; }
|
||||
void set_aqi_sensor(sensor::Sensor *aqi_sensor) { aqi_sensor_ = aqi_sensor; }
|
||||
|
||||
void set_aqi_calculation_type(aqi::AQICalculatorType aqi_calc_type) { aqi_calc_type_ = aqi_calc_type; }
|
||||
|
||||
void setup() override;
|
||||
@@ -34,11 +34,6 @@ class HM3301Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
|
||||
uint8_t data_buffer_[30];
|
||||
|
||||
sensor::Sensor *pm_1_0_sensor_{nullptr};
|
||||
sensor::Sensor *pm_2_5_sensor_{nullptr};
|
||||
sensor::Sensor *pm_10_0_sensor_{nullptr};
|
||||
sensor::Sensor *aqi_sensor_{nullptr};
|
||||
|
||||
aqi::AQICalculatorType aqi_calc_type_;
|
||||
aqi::AQICalculatorFactory aqi_calculator_factory_ = aqi::AQICalculatorFactory();
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ enum HMC5883LRange {
|
||||
};
|
||||
|
||||
class HMC5883LComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(x)
|
||||
SUB_SENSOR(y)
|
||||
SUB_SENSOR(z)
|
||||
SUB_SENSOR(heading)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -43,19 +48,11 @@ class HMC5883LComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
void set_oversampling(HMC5883LOversampling oversampling) { oversampling_ = oversampling; }
|
||||
void set_datarate(HMC5883LDatarate datarate) { datarate_ = datarate; }
|
||||
void set_range(HMC5883LRange range) { range_ = range; }
|
||||
void set_x_sensor(sensor::Sensor *x_sensor) { x_sensor_ = x_sensor; }
|
||||
void set_y_sensor(sensor::Sensor *y_sensor) { y_sensor_ = y_sensor; }
|
||||
void set_z_sensor(sensor::Sensor *z_sensor) { z_sensor_ = z_sensor; }
|
||||
void set_heading_sensor(sensor::Sensor *heading_sensor) { heading_sensor_ = heading_sensor; }
|
||||
|
||||
protected:
|
||||
HMC5883LOversampling oversampling_{HMC5883L_OVERSAMPLING_1};
|
||||
HMC5883LDatarate datarate_{HMC5883L_DATARATE_15_0_HZ};
|
||||
HMC5883LRange range_{HMC5883L_RANGE_130_UT};
|
||||
sensor::Sensor *x_sensor_{nullptr};
|
||||
sensor::Sensor *y_sensor_{nullptr};
|
||||
sensor::Sensor *z_sensor_{nullptr};
|
||||
sensor::Sensor *heading_sensor_{nullptr};
|
||||
HighFrequencyLoopRequester high_freq_;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,14 +13,10 @@ class HoneywellHIComponent final : public PollingComponent, public i2c::I2CDevic
|
||||
void loop() override;
|
||||
void update() override;
|
||||
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
|
||||
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { this->humidity_sensor_ = humidity_sensor; }
|
||||
|
||||
protected:
|
||||
bool measurement_running_{false};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
private:
|
||||
void read_sensor_data_();
|
||||
void start_measurement_();
|
||||
|
||||
@@ -11,9 +11,10 @@ namespace esphome::honeywellabp {
|
||||
class HONEYWELLABPSensor final : public PollingComponent,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
|
||||
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_200KHZ> {
|
||||
SUB_SENSOR(pressure)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void setup() override;
|
||||
void update() override;
|
||||
float get_setup_priority() const override;
|
||||
@@ -28,8 +29,6 @@ class HONEYWELLABPSensor final : public PollingComponent,
|
||||
uint8_t status_ = 0; // byte to hold status information.
|
||||
int pressure_count_ = 0; // hold raw pressure data (14 - bit, 0 - 16384)
|
||||
int temperature_count_ = 0; // hold raw temperature data (11 - bit, 0 - 2048)
|
||||
sensor::Sensor *pressure_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
uint8_t readsensor_();
|
||||
uint8_t readstatus_();
|
||||
int rawpressure_();
|
||||
|
||||
@@ -12,9 +12,10 @@ namespace esphome::honeywellabp2_i2c {
|
||||
enum ABP2TRANFERFUNCTION { ABP2_TRANS_FUNC_A = 0, ABP2_TRANS_FUNC_B = 1 };
|
||||
|
||||
class HONEYWELLABP2Sensor final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(pressure)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { this->pressure_sensor_ = pressure_sensor; };
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; };
|
||||
void loop() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
@@ -36,9 +37,6 @@ class HONEYWELLABP2Sensor final : public PollingComponent, public i2c::I2CDevice
|
||||
float max_pressure_ = 0.0;
|
||||
ABP2TRANFERFUNCTION transfer_function_ = ABP2_TRANS_FUNC_A;
|
||||
|
||||
sensor::Sensor *pressure_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
|
||||
const float max_count_a_ = 15099494.4; // (90% of 2^24 counts or 0xE66666)
|
||||
const float min_count_a_ = 1677721.6; // (10% of 2^24 counts or 0x19999A)
|
||||
const float max_count_b_ = 11744051.2; // (70% of 2^24 counts or 0xB33333)
|
||||
|
||||
@@ -8,18 +8,15 @@ namespace esphome::hte501 {
|
||||
|
||||
/// This class implements support for the hte501 of temperature i2c sensors.
|
||||
class HTE501Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *humidity_sensor_{nullptr};
|
||||
|
||||
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED, CRC_CHECK_FAILED } error_code_{NONE};
|
||||
};
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ RequestHeader = http_request_ns.struct("RequestHeader")
|
||||
HttpRequestSendAction = http_request_ns.class_(
|
||||
"HttpRequestSendAction", automation.Action
|
||||
)
|
||||
HttpRequestResponseTrigger = http_request_ns.class_(
|
||||
"HttpRequestResponseTrigger",
|
||||
automation.Trigger.template(
|
||||
cg.std_shared_ptr.template(HttpContainer), cg.std_string
|
||||
),
|
||||
)
|
||||
|
||||
CONF_HTTP_REQUEST_ID = "http_request_id"
|
||||
|
||||
|
||||
@@ -340,13 +340,6 @@ inline HttpReadResult http_read_fully(HttpContainer *container, uint8_t *buffer,
|
||||
return {HttpReadStatus::OK, 0};
|
||||
}
|
||||
|
||||
class HttpRequestResponseTrigger final : public Trigger<std::shared_ptr<HttpContainer>, std::string &> {
|
||||
public:
|
||||
void process(const std::shared_ptr<HttpContainer> &container, std::string &response_body) {
|
||||
this->trigger(container, response_body);
|
||||
}
|
||||
};
|
||||
|
||||
/// What HttpRequestComponent asks of the action that owns a request
|
||||
enum class RequestEvent : uint8_t {
|
||||
REQUEST_EVENT_START, ///< Build the request and call begin()
|
||||
|
||||
@@ -30,8 +30,8 @@ void HTU21DComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "HTU21D:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
}
|
||||
void HTU21DComponent::update() {
|
||||
if (this->write(&HTU21D_REGISTER_TEMPERATURE, 1) != i2c::ERROR_OK) {
|
||||
@@ -52,8 +52,8 @@ void HTU21DComponent::update() {
|
||||
|
||||
ESP_LOGD(TAG, "Got Temperature=%.1f°C", temperature);
|
||||
|
||||
if (this->temperature_ != nullptr)
|
||||
this->temperature_->publish_state(temperature);
|
||||
if (this->temperature_sensor_ != nullptr)
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
|
||||
if (this->write(&HTU21D_REGISTER_HUMIDITY, 1) != i2c::ERROR_OK) {
|
||||
this->status_set_warning();
|
||||
@@ -72,8 +72,8 @@ void HTU21DComponent::update() {
|
||||
|
||||
ESP_LOGD(TAG, "Got Humidity=%.1f%%", humidity);
|
||||
|
||||
if (this->humidity_ != nullptr)
|
||||
this->humidity_->publish_state(humidity);
|
||||
if (this->humidity_sensor_ != nullptr)
|
||||
this->humidity_sensor_->publish_state(humidity);
|
||||
|
||||
this->status_clear_warning();
|
||||
|
||||
@@ -92,8 +92,8 @@ void HTU21DComponent::update() {
|
||||
|
||||
ESP_LOGD(TAG, "Heater Level=%d", heater_level);
|
||||
|
||||
if (this->heater_ != nullptr)
|
||||
this->heater_->publish_state(heater_level);
|
||||
if (this->heater_sensor_ != nullptr)
|
||||
this->heater_sensor_->publish_state(heater_level);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace esphome::htu21d {
|
||||
enum HTU21DSensorModels { HTU21D_SENSOR_MODEL_HTU21D = 0, HTU21D_SENSOR_MODEL_SI7021, HTU21D_SENSOR_MODEL_SHT21 };
|
||||
|
||||
class HTU21DComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_heater(sensor::Sensor *heater) { heater_ = heater; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(heater)
|
||||
|
||||
public:
|
||||
/// Setup (reset) the sensor and check connection.
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -27,9 +27,6 @@ class HTU21DComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
uint8_t get_heater_level();
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *heater_{nullptr};
|
||||
HTU21DSensorModels sensor_model_{HTU21D_SENSOR_MODEL_HTU21D};
|
||||
};
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_HEATER, var.set_heater)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
await sensors(CONF_HEATER, var.set_heater_sensor)
|
||||
|
||||
cg.add(var.set_sensor_model(config[CONF_MODEL]))
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ void HTU31DComponent::update() {
|
||||
temperature *= 165;
|
||||
temperature -= 40;
|
||||
|
||||
if (this->temperature_ != nullptr) {
|
||||
this->temperature_->publish_state(temperature);
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
}
|
||||
|
||||
// Calculate humidty value.
|
||||
@@ -116,8 +116,8 @@ void HTU31DComponent::update() {
|
||||
humidity /= 65535.0f;
|
||||
humidity *= 100;
|
||||
|
||||
if (this->humidity_ != nullptr) {
|
||||
this->humidity_->publish_state(humidity);
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
this->humidity_sensor_->publish_state(humidity);
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity);
|
||||
@@ -132,8 +132,8 @@ void HTU31DComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "HTU31D:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,22 +8,19 @@
|
||||
namespace esphome::htu31d {
|
||||
|
||||
class HTU31DComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void setup() override; /// Setup (reset) the sensor and check connection.
|
||||
void update() override; /// Update the sensor values (temperature+humidity).
|
||||
void dump_config() override; /// Dumps the configuration values.
|
||||
|
||||
void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }
|
||||
|
||||
void set_heater_state(bool desired);
|
||||
bool is_heater_enabled();
|
||||
|
||||
protected:
|
||||
bool reset_();
|
||||
uint32_t read_serial_num_();
|
||||
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
};
|
||||
} // namespace esphome::htu31d
|
||||
@@ -46,5 +46,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
@@ -39,9 +39,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
await cg.register_component(bin_component, config)
|
||||
|
||||
mapping = {
|
||||
CONF_TOO_COLD: main_sensor.set_too_cold_sensor,
|
||||
CONF_LENS_BAD: main_sensor.set_lens_bad_sensor,
|
||||
CONF_EM_SAT: main_sensor.set_em_sat_sensor,
|
||||
CONF_TOO_COLD: main_sensor.set_too_cold_binary_sensor,
|
||||
CONF_LENS_BAD: main_sensor.set_lens_bad_binary_sensor,
|
||||
CONF_EM_SAT: main_sensor.set_em_sat_binary_sensor,
|
||||
}
|
||||
|
||||
for key, value in mapping.items():
|
||||
|
||||
@@ -88,14 +88,14 @@ void HydreonRGxxComponent::update() {
|
||||
}
|
||||
this->write_str("R\n");
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->too_cold_sensor_ != nullptr) {
|
||||
this->too_cold_sensor_->publish_state(this->too_cold_);
|
||||
if (this->too_cold_binary_sensor_ != nullptr) {
|
||||
this->too_cold_binary_sensor_->publish_state(this->too_cold_);
|
||||
}
|
||||
if (this->lens_bad_sensor_ != nullptr) {
|
||||
this->lens_bad_sensor_->publish_state(this->lens_bad_);
|
||||
if (this->lens_bad_binary_sensor_ != nullptr) {
|
||||
this->lens_bad_binary_sensor_->publish_state(this->lens_bad_);
|
||||
}
|
||||
if (this->em_sat_sensor_ != nullptr) {
|
||||
this->em_sat_sensor_->publish_state(this->em_sat_);
|
||||
if (this->em_sat_binary_sensor_ != nullptr) {
|
||||
this->em_sat_binary_sensor_->publish_state(this->em_sat_);
|
||||
}
|
||||
#endif
|
||||
this->too_cold_ = false;
|
||||
|
||||
@@ -35,13 +35,14 @@ static const uint8_t NUM_SENSORS = 1;
|
||||
#define HYDREON_RGXX_IGNORE_LIST(F, SEP) F("Emitters") SEP F("Event") SEP F("Reset")
|
||||
|
||||
class HydreonRGxxComponent final : public PollingComponent, public uart::UARTDevice {
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
SUB_BINARY_SENSOR(too_cold)
|
||||
SUB_BINARY_SENSOR(lens_bad)
|
||||
SUB_BINARY_SENSOR(em_sat)
|
||||
#endif
|
||||
|
||||
public:
|
||||
void set_sensor(sensor::Sensor *sensor, int index) { this->sensors_[index] = sensor; }
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
void set_too_cold_sensor(binary_sensor::BinarySensor *sensor) { this->too_cold_sensor_ = sensor; }
|
||||
void set_lens_bad_sensor(binary_sensor::BinarySensor *sensor) { this->lens_bad_sensor_ = sensor; }
|
||||
void set_em_sat_sensor(binary_sensor::BinarySensor *sensor) { this->em_sat_sensor_ = sensor; }
|
||||
#endif
|
||||
void set_model(RGModel model) { model_ = model; }
|
||||
void set_resolution(RG15Resolution resolution) { resolution_ = resolution; }
|
||||
void set_request_temperature(bool b) { request_temperature_ = b; }
|
||||
@@ -63,11 +64,6 @@ class HydreonRGxxComponent final : public PollingComponent, public uart::UARTDev
|
||||
int num_sensors_missing_();
|
||||
|
||||
sensor::Sensor *sensors_[NUM_SENSORS] = {nullptr};
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *too_cold_sensor_{nullptr};
|
||||
binary_sensor::BinarySensor *lens_bad_sensor_{nullptr};
|
||||
binary_sensor::BinarySensor *em_sat_sensor_{nullptr};
|
||||
#endif
|
||||
|
||||
int16_t boot_count_ = 0;
|
||||
int16_t no_response_count_ = 0;
|
||||
|
||||
@@ -14,8 +14,8 @@ void HYT271Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "HYT271:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
}
|
||||
void HYT271Component::update() {
|
||||
uint8_t raw_data[4] = {0, 0, 0, 0};
|
||||
@@ -40,10 +40,10 @@ void HYT271Component::update() {
|
||||
|
||||
ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity);
|
||||
|
||||
if (this->temperature_ != nullptr)
|
||||
this->temperature_->publish_state(temperature);
|
||||
if (this->humidity_ != nullptr)
|
||||
this->humidity_->publish_state(humidity);
|
||||
if (this->temperature_sensor_ != nullptr)
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
if (this->humidity_sensor_ != nullptr)
|
||||
this->humidity_sensor_->publish_state(humidity);
|
||||
this->status_clear_warning();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,17 +7,13 @@
|
||||
namespace esphome::hyt271 {
|
||||
|
||||
class HYT271Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
|
||||
public:
|
||||
void dump_config() override;
|
||||
/// Update the sensor values (temperature+humidity).
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::hyt271
|
||||
@@ -46,5 +46,5 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = await i2c.new_i2c_component(config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
@@ -103,7 +103,7 @@ void I2SAudioMicrophone::configure_stream_settings_() {
|
||||
}
|
||||
|
||||
void I2SAudioMicrophone::start() {
|
||||
if (this->is_failed())
|
||||
if (!this->is_ready())
|
||||
return;
|
||||
|
||||
xSemaphoreTake(this->active_listeners_semaphore_, 0);
|
||||
@@ -270,9 +270,10 @@ bool I2SAudioMicrophone::start_driver_() {
|
||||
}
|
||||
|
||||
void I2SAudioMicrophone::stop() {
|
||||
if (this->state_ == microphone::STATE_STOPPED || this->is_failed())
|
||||
if (!this->is_ready())
|
||||
return;
|
||||
|
||||
// Not gated on state_: a start() that loop() has not acted on yet must be given back too
|
||||
xSemaphoreGive(this->active_listeners_semaphore_);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,22 +65,22 @@ void IAQCore::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->co2_ != nullptr) {
|
||||
this->co2_->publish_state(data.co2);
|
||||
if (this->co2_sensor_ != nullptr) {
|
||||
this->co2_sensor_->publish_state(data.co2);
|
||||
}
|
||||
if (this->tvoc_ != nullptr) {
|
||||
this->tvoc_->publish_state(data.tvoc);
|
||||
if (this->tvoc_sensor_ != nullptr) {
|
||||
this->tvoc_sensor_->publish_state(data.tvoc);
|
||||
}
|
||||
|
||||
this->status_clear_warning();
|
||||
}
|
||||
|
||||
void IAQCore::publish_nans_() {
|
||||
if (this->co2_ != nullptr) {
|
||||
this->co2_->publish_state(NAN);
|
||||
if (this->co2_sensor_ != nullptr) {
|
||||
this->co2_sensor_->publish_state(NAN);
|
||||
}
|
||||
if (this->tvoc_ != nullptr) {
|
||||
this->tvoc_->publish_state(NAN);
|
||||
if (this->tvoc_sensor_ != nullptr) {
|
||||
this->tvoc_sensor_->publish_state(NAN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ void IAQCore::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "AMS iAQ Core:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "CO2", this->co2_);
|
||||
LOG_SENSOR(" ", "TVOC", this->tvoc_);
|
||||
LOG_SENSOR(" ", "CO2", this->co2_sensor_);
|
||||
LOG_SENSOR(" ", "TVOC", this->tvoc_sensor_);
|
||||
}
|
||||
|
||||
} // namespace esphome::iaqcore
|
||||
@@ -7,18 +7,15 @@
|
||||
namespace esphome::iaqcore {
|
||||
|
||||
class IAQCore final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_co2(sensor::Sensor *co2) { co2_ = co2; }
|
||||
void set_tvoc(sensor::Sensor *tvoc) { tvoc_ = tvoc; }
|
||||
SUB_SENSOR(co2)
|
||||
SUB_SENSOR(tvoc)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *co2_{nullptr};
|
||||
sensor::Sensor *tvoc_{nullptr};
|
||||
|
||||
void publish_nans_();
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
await cg.register_component(var, config)
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_CO2, var.set_co2)
|
||||
await sensors(CONF_TVOC, var.set_tvoc)
|
||||
await sensors(CONF_CO2, var.set_co2_sensor)
|
||||
await sensors(CONF_TVOC, var.set_tvoc_sensor)
|
||||
|
||||
await i2c.register_i2c_device(var, config)
|
||||
@@ -9,6 +9,11 @@
|
||||
namespace esphome::ina219 {
|
||||
|
||||
class INA219Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(bus_voltage)
|
||||
SUB_SENSOR(shunt_voltage)
|
||||
SUB_SENSOR(current)
|
||||
SUB_SENSOR(power)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -18,20 +23,12 @@ class INA219Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void set_shunt_resistance_ohm(float shunt_resistance_ohm) { shunt_resistance_ohm_ = shunt_resistance_ohm; }
|
||||
void set_max_current_a(float max_current_a) { max_current_a_ = max_current_a; }
|
||||
void set_max_voltage_v(float max_voltage_v) { max_voltage_v_ = max_voltage_v; }
|
||||
void set_bus_voltage_sensor(sensor::Sensor *bus_voltage_sensor) { bus_voltage_sensor_ = bus_voltage_sensor; }
|
||||
void set_shunt_voltage_sensor(sensor::Sensor *shunt_voltage_sensor) { shunt_voltage_sensor_ = shunt_voltage_sensor; }
|
||||
void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { power_sensor_ = power_sensor; }
|
||||
|
||||
protected:
|
||||
float shunt_resistance_ohm_;
|
||||
float max_current_a_;
|
||||
float max_voltage_v_;
|
||||
uint32_t calibration_lsb_;
|
||||
sensor::Sensor *bus_voltage_sensor_{nullptr};
|
||||
sensor::Sensor *shunt_voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
sensor::Sensor *power_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ina219
|
||||
@@ -41,6 +41,11 @@ union ConfigurationRegister {
|
||||
};
|
||||
|
||||
class INA226Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(bus_voltage)
|
||||
SUB_SENSOR(shunt_voltage)
|
||||
SUB_SENSOR(current)
|
||||
SUB_SENSOR(power)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -52,11 +57,6 @@ class INA226Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void set_adc_time_current(AdcTime time) { adc_time_current_ = time; }
|
||||
void set_adc_avg_samples(AdcAvgSamples samples) { adc_avg_samples_ = samples; }
|
||||
|
||||
void set_bus_voltage_sensor(sensor::Sensor *bus_voltage_sensor) { bus_voltage_sensor_ = bus_voltage_sensor; }
|
||||
void set_shunt_voltage_sensor(sensor::Sensor *shunt_voltage_sensor) { shunt_voltage_sensor_ = shunt_voltage_sensor; }
|
||||
void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { power_sensor_ = power_sensor; }
|
||||
|
||||
protected:
|
||||
float shunt_resistance_ohm_;
|
||||
float max_current_a_;
|
||||
@@ -64,10 +64,6 @@ class INA226Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
AdcTime adc_time_current_{AdcTime::ADC_TIME_1100US};
|
||||
AdcAvgSamples adc_avg_samples_{AdcAvgSamples::ADC_AVG_SAMPLES_4};
|
||||
uint32_t calibration_lsb_;
|
||||
sensor::Sensor *bus_voltage_sensor_{nullptr};
|
||||
sensor::Sensor *shunt_voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
sensor::Sensor *power_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ina226
|
||||
@@ -7,22 +7,18 @@
|
||||
namespace esphome::ina260 {
|
||||
|
||||
class INA260Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(bus_voltage)
|
||||
SUB_SENSOR(current)
|
||||
SUB_SENSOR(power)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
void set_bus_voltage_sensor(sensor::Sensor *bus_voltage_sensor) { this->bus_voltage_sensor_ = bus_voltage_sensor; }
|
||||
void set_current_sensor(sensor::Sensor *current_sensor) { this->current_sensor_ = current_sensor; }
|
||||
void set_power_sensor(sensor::Sensor *power_sensor) { this->power_sensor_ = power_sensor; }
|
||||
|
||||
protected:
|
||||
uint16_t manufacture_id_{0};
|
||||
uint16_t device_id_{0};
|
||||
|
||||
sensor::Sensor *bus_voltage_sensor_{nullptr};
|
||||
sensor::Sensor *current_sensor_{nullptr};
|
||||
sensor::Sensor *power_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::ina260
|
||||
@@ -7,10 +7,10 @@ ESPHOME_LOG_TAG(TAG, "inkbird_ibsth1_mini");
|
||||
|
||||
void InkbirdIbstH1Mini::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Inkbird IBS TH1 MINI");
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_);
|
||||
LOG_SENSOR(" ", "External Temperature", this->external_temperature_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "External Temperature", this->external_temperature_sensor_);
|
||||
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Level", this->battery_level_sensor_);
|
||||
}
|
||||
|
||||
bool InkbirdIbstH1Mini::parse_device(const ble_device_base::ESPBTDevice &device) {
|
||||
@@ -85,17 +85,17 @@ bool InkbirdIbstH1Mini::parse_device(const ble_device_base::ESPBTDevice &device)
|
||||
auto humidity = ((mnf_data.data[1] << 8) + mnf_data.data[0]) / 100.0f;
|
||||
|
||||
// Send temperature only if the value is set
|
||||
if (!std::isnan(temperature) && this->temperature_ != nullptr) {
|
||||
this->temperature_->publish_state(temperature);
|
||||
if (!std::isnan(temperature) && this->temperature_sensor_ != nullptr) {
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
}
|
||||
if (!std::isnan(external_temperature) && this->external_temperature_ != nullptr) {
|
||||
this->external_temperature_->publish_state(external_temperature);
|
||||
if (!std::isnan(external_temperature) && this->external_temperature_sensor_ != nullptr) {
|
||||
this->external_temperature_sensor_->publish_state(external_temperature);
|
||||
}
|
||||
if (this->humidity_ != nullptr) {
|
||||
this->humidity_->publish_state(humidity);
|
||||
if (this->humidity_sensor_ != nullptr) {
|
||||
this->humidity_sensor_->publish_state(humidity);
|
||||
}
|
||||
if (this->battery_level_ != nullptr) {
|
||||
this->battery_level_->publish_state(battery_level);
|
||||
if (this->battery_level_sensor_ != nullptr) {
|
||||
this->battery_level_sensor_->publish_state(battery_level);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -7,23 +7,20 @@
|
||||
namespace esphome::inkbird_ibsth1_mini {
|
||||
|
||||
class InkbirdIbstH1Mini final : public Component, public ble_device_base::ESPBTDeviceListener {
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(external_temperature)
|
||||
SUB_SENSOR(humidity)
|
||||
SUB_SENSOR(battery_level)
|
||||
|
||||
public:
|
||||
void set_address(uint64_t address) { address_ = address; }
|
||||
|
||||
bool parse_device(const ble_device_base::ESPBTDevice &device) override;
|
||||
|
||||
void dump_config() override;
|
||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
||||
void set_external_temperature(sensor::Sensor *external_temperature) { external_temperature_ = external_temperature; }
|
||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
||||
void set_battery_level(sensor::Sensor *battery_level) { battery_level_ = battery_level; }
|
||||
|
||||
protected:
|
||||
uint64_t address_;
|
||||
sensor::Sensor *temperature_{nullptr};
|
||||
sensor::Sensor *external_temperature_{nullptr};
|
||||
sensor::Sensor *humidity_{nullptr};
|
||||
sensor::Sensor *battery_level_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::inkbird_ibsth1_mini
|
||||
@@ -69,7 +69,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
|
||||
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature)
|
||||
await sensors(CONF_EXTERNAL_TEMPERATURE, var.set_external_temperature)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_EXTERNAL_TEMPERATURE, var.set_external_temperature_sensor)
|
||||
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
|
||||
await sensors(CONF_BATTERY_LEVEL, var.set_battery_level_sensor)
|
||||
@@ -9,18 +9,16 @@ namespace esphome::kmeteriso {
|
||||
|
||||
/// This class implements support for the KMeterISO thermocouple sensor.
|
||||
class KMeterISOComponent final : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature_sensor(sensor::Sensor *t) { this->temperature_sensor_ = t; }
|
||||
void set_internal_temperature_sensor(sensor::Sensor *t) { this->internal_temperature_sensor_ = t; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(internal_temperature)
|
||||
|
||||
public:
|
||||
// ========== INTERNAL METHODS ==========
|
||||
// (In most use cases you won't need these)
|
||||
void setup() override;
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *internal_temperature_sensor_{nullptr};
|
||||
enum ErrorCode {
|
||||
NONE = 0,
|
||||
COMMUNICATION_FAILED,
|
||||
|
||||
@@ -9,30 +9,21 @@
|
||||
namespace esphome::kuntze {
|
||||
|
||||
class Kuntze final : public PollingComponent, public modbus::ModbusClientDevice {
|
||||
public:
|
||||
void set_ph_sensor(sensor::Sensor *ph_sensor) { ph_sensor_ = ph_sensor; }
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void set_dis1_sensor(sensor::Sensor *dis1_sensor) { dis1_sensor_ = dis1_sensor; }
|
||||
void set_dis2_sensor(sensor::Sensor *dis2_sensor) { dis2_sensor_ = dis2_sensor; }
|
||||
void set_redox_sensor(sensor::Sensor *redox_sensor) { redox_sensor_ = redox_sensor; }
|
||||
void set_ec_sensor(sensor::Sensor *ec_sensor) { ec_sensor_ = ec_sensor; }
|
||||
void set_oci_sensor(sensor::Sensor *oci_sensor) { oci_sensor_ = oci_sensor; }
|
||||
SUB_SENSOR(ph)
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(dis1)
|
||||
SUB_SENSOR(dis2)
|
||||
SUB_SENSOR(redox)
|
||||
SUB_SENSOR(ec)
|
||||
SUB_SENSOR(oci)
|
||||
|
||||
public:
|
||||
void update() override;
|
||||
|
||||
void on_read_holding_registers(uint16_t start_address, std::span<const uint16_t> registers,
|
||||
modbus::ResponseStatus status) override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *ph_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *dis1_sensor_{nullptr};
|
||||
sensor::Sensor *dis2_sensor_{nullptr};
|
||||
sensor::Sensor *redox_sensor_{nullptr};
|
||||
sensor::Sensor *ec_sensor_{nullptr};
|
||||
sensor::Sensor *oci_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::kuntze
|
||||
@@ -20,6 +20,10 @@ enum LC709203FBatteryVoltage {
|
||||
};
|
||||
|
||||
class Lc709203f final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(voltage)
|
||||
SUB_SENSOR(battery_remaining)
|
||||
SUB_SENSOR(temperature)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
@@ -28,20 +32,12 @@ class Lc709203f final : public sensor::Sensor, public PollingComponent, public i
|
||||
void set_pack_size(uint16_t pack_size);
|
||||
void set_thermistor_b_constant(uint16_t b_constant) { this->b_constant_ = b_constant; }
|
||||
void set_pack_voltage(LC709203FBatteryVoltage pack_voltage) { this->pack_voltage_ = pack_voltage; }
|
||||
void set_voltage_sensor(sensor::Sensor *voltage_sensor) { voltage_sensor_ = voltage_sensor; }
|
||||
void set_battery_remaining_sensor(sensor::Sensor *battery_remaining_sensor) {
|
||||
battery_remaining_sensor_ = battery_remaining_sensor;
|
||||
}
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
|
||||
private:
|
||||
uint8_t get_register_(uint8_t register_to_read, uint16_t *register_value);
|
||||
uint8_t set_register_(uint8_t register_to_set, uint16_t value_to_set);
|
||||
|
||||
protected:
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *battery_remaining_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
uint16_t pack_size_;
|
||||
uint16_t apa_;
|
||||
uint16_t b_constant_;
|
||||
|
||||
@@ -56,8 +56,8 @@ void LTComponent::dump_config() {
|
||||
#endif
|
||||
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
if (this->version_ != nullptr) {
|
||||
this->version_->publish_state(<_BANNER_STR[10]);
|
||||
if (this->version_text_sensor_ != nullptr) {
|
||||
this->version_text_sensor_->publish_state(<_BANNER_STR[10]);
|
||||
}
|
||||
#endif // USE_TEXT_SENSOR
|
||||
}
|
||||
|
||||
@@ -15,18 +15,13 @@
|
||||
namespace esphome::libretiny {
|
||||
|
||||
class LTComponent final : public Component {
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
SUB_TEXT_SENSOR(version)
|
||||
#endif
|
||||
|
||||
public:
|
||||
float get_setup_priority() const override;
|
||||
void dump_config() override;
|
||||
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
void set_version_sensor(text_sensor::TextSensor *version) { version_ = version; }
|
||||
#endif // USE_TEXT_SENSOR
|
||||
|
||||
protected:
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *version_{nullptr};
|
||||
#endif // USE_TEXT_SENSOR
|
||||
};
|
||||
|
||||
} // namespace esphome::libretiny
|
||||
|
||||
@@ -28,4 +28,4 @@ async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_LIBRETINY])
|
||||
|
||||
text_sensors = text_sensor.sub_text_sensors(config)
|
||||
await text_sensors(CONF_VERSION, hub.set_version_sensor)
|
||||
await text_sensors(CONF_VERSION, hub.set_version_text_sensor)
|
||||
@@ -7,10 +7,10 @@
|
||||
namespace esphome::lps22 {
|
||||
|
||||
class LPS22Component final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
|
||||
void set_pressure_sensor(sensor::Sensor *pressure_sensor) { this->pressure_sensor_ = pressure_sensor; }
|
||||
SUB_SENSOR(temperature)
|
||||
SUB_SENSOR(pressure)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
@@ -18,8 +18,6 @@ class LPS22Component final : public sensor::Sensor, public PollingComponent, pub
|
||||
protected:
|
||||
void try_read_();
|
||||
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *pressure_sensor_{nullptr};
|
||||
uint8_t read_attempts_remaining_{0};
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,11 @@ enum LTR390RESOLUTION : uint8_t {
|
||||
};
|
||||
|
||||
class LTR390Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
SUB_SENSOR(light)
|
||||
SUB_SENSOR(als)
|
||||
SUB_SENSOR(uvi)
|
||||
SUB_SENSOR(uv)
|
||||
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
@@ -51,11 +56,6 @@ class LTR390Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void set_uv_res_value(LTR390RESOLUTION res) { this->res_uv_ = res; }
|
||||
void set_wfac_value(float wfac) { this->wfac_ = wfac; }
|
||||
|
||||
void set_light_sensor(sensor::Sensor *light_sensor) { this->light_sensor_ = light_sensor; }
|
||||
void set_als_sensor(sensor::Sensor *als_sensor) { this->als_sensor_ = als_sensor; }
|
||||
void set_uvi_sensor(sensor::Sensor *uvi_sensor) { this->uvi_sensor_ = uvi_sensor; }
|
||||
void set_uv_sensor(sensor::Sensor *uv_sensor) { this->uv_sensor_ = uv_sensor; }
|
||||
|
||||
protected:
|
||||
static constexpr uint8_t ENABLED_MODE_ALS = 1 << 0;
|
||||
static constexpr uint8_t ENABLED_MODE_UVS = 1 << 1;
|
||||
@@ -68,12 +68,6 @@ class LTR390Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
void read_mode_(LTR390MODE mode);
|
||||
void standby_();
|
||||
|
||||
sensor::Sensor *light_sensor_{nullptr};
|
||||
sensor::Sensor *als_sensor_{nullptr};
|
||||
|
||||
sensor::Sensor *uvi_sensor_{nullptr};
|
||||
sensor::Sensor *uv_sensor_{nullptr};
|
||||
|
||||
float wfac_;
|
||||
|
||||
LTR390GAIN gain_als_;
|
||||
|
||||
@@ -6,18 +6,12 @@
|
||||
namespace esphome::max17043 {
|
||||
|
||||
class MAX17043Component final : public max170xx::MAX170xxComponent<max170xx::Model::MODEL_MAX17043> {
|
||||
SUB_SENSOR(voltage)
|
||||
SUB_SENSOR(battery_remaining)
|
||||
|
||||
public:
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
void set_voltage_sensor(sensor::Sensor *voltage_sensor) { this->voltage_sensor_ = voltage_sensor; }
|
||||
void set_battery_remaining_sensor(sensor::Sensor *battery_remaining_sensor) {
|
||||
this->battery_remaining_sensor_ = battery_remaining_sensor;
|
||||
}
|
||||
|
||||
protected:
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *battery_remaining_sensor_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace esphome::max17043
|
||||
Loaded 100 of 301 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user