mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	Compare commits
	
		
			23 Commits
		
	
	
		
			2023.6.0b2
			...
			2023.6.0b7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					bc7c11be96 | ||
| 
						 | 
					a2734330e1 | ||
| 
						 | 
					ef8180c8a8 | ||
| 
						 | 
					cd773a1dec | ||
| 
						 | 
					244a212592 | ||
| 
						 | 
					98e3426769 | ||
| 
						 | 
					7ef8d67831 | ||
| 
						 | 
					c455a5dd6a | ||
| 
						 | 
					74daca668e | ||
| 
						 | 
					a40fa22055 | ||
| 
						 | 
					2047bba4f7 | ||
| 
						 | 
					a064ab5c2b | ||
| 
						 | 
					0c37d06936 | ||
| 
						 | 
					d919373853 | ||
| 
						 | 
					6c00be0a63 | ||
| 
						 | 
					0671287b80 | ||
| 
						 | 
					867b4719d1 | ||
| 
						 | 
					fc544dc389 | ||
| 
						 | 
					501fe83710 | ||
| 
						 | 
					5513b0e121 | ||
| 
						 | 
					959e7745a6 | ||
| 
						 | 
					76e947651d | ||
| 
						 | 
					5ba04eb620 | 
							
								
								
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							@@ -49,9 +49,11 @@ jobs:
 | 
			
		||||
        with:
 | 
			
		||||
          python-version: "3.x"
 | 
			
		||||
      - name: Set up python environment
 | 
			
		||||
        env:
 | 
			
		||||
          ESPHOME_NO_VENV: 1
 | 
			
		||||
        run: |
 | 
			
		||||
          script/setup
 | 
			
		||||
          pip install setuptools wheel twine
 | 
			
		||||
          pip install twine
 | 
			
		||||
      - name: Build
 | 
			
		||||
        run: python setup.py sdist bdist_wheel
 | 
			
		||||
      - name: Upload
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ esphome/components/adc/* @esphome/core
 | 
			
		||||
esphome/components/adc128s102/* @DeerMaximum
 | 
			
		||||
esphome/components/addressable_light/* @justfalter
 | 
			
		||||
esphome/components/airthings_ble/* @jeromelaban
 | 
			
		||||
esphome/components/airthings_wave_base/* @jeromelaban @ncareau
 | 
			
		||||
esphome/components/airthings_wave_mini/* @ncareau
 | 
			
		||||
esphome/components/airthings_wave_plus/* @jeromelaban
 | 
			
		||||
esphome/components/alarm_control_panel/* @grahambrown11
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										83
									
								
								esphome/components/airthings_wave_base/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								esphome/components/airthings_wave_base/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
from esphome.components import sensor, ble_client
 | 
			
		||||
 | 
			
		||||
from esphome.const import (
 | 
			
		||||
    DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
    DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
    DEVICE_CLASS_PRESSURE,
 | 
			
		||||
    STATE_CLASS_MEASUREMENT,
 | 
			
		||||
    UNIT_PERCENT,
 | 
			
		||||
    UNIT_CELSIUS,
 | 
			
		||||
    UNIT_HECTOPASCAL,
 | 
			
		||||
    CONF_HUMIDITY,
 | 
			
		||||
    CONF_TVOC,
 | 
			
		||||
    CONF_PRESSURE,
 | 
			
		||||
    CONF_TEMPERATURE,
 | 
			
		||||
    DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
    UNIT_PARTS_PER_BILLION,
 | 
			
		||||
    ICON_RADIATOR,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
CODEOWNERS = ["@ncareau", "@jeromelaban"]
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["ble_client"]
 | 
			
		||||
 | 
			
		||||
airthings_wave_base_ns = cg.esphome_ns.namespace("airthings_wave_base")
 | 
			
		||||
AirthingsWaveBase = airthings_wave_base_ns.class_(
 | 
			
		||||
    "AirthingsWaveBase", cg.PollingComponent, ble_client.BLEClientNode
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
BASE_SCHEMA = (
 | 
			
		||||
    sensor.SENSOR_SCHEMA.extend(
 | 
			
		||||
        {
 | 
			
		||||
            cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PERCENT,
 | 
			
		||||
                device_class=DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_CELSIUS,
 | 
			
		||||
                accuracy_decimals=2,
 | 
			
		||||
                device_class=DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_HECTOPASCAL,
 | 
			
		||||
                accuracy_decimals=1,
 | 
			
		||||
                device_class=DEVICE_CLASS_PRESSURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TVOC): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_BILLION,
 | 
			
		||||
                icon=ICON_RADIATOR,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
    .extend(cv.polling_component_schema("5min"))
 | 
			
		||||
    .extend(ble_client.BLE_CLIENT_SCHEMA)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def wave_base_to_code(var, config):
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
 | 
			
		||||
    await ble_client.register_ble_node(var, config)
 | 
			
		||||
 | 
			
		||||
    if CONF_HUMIDITY in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_HUMIDITY])
 | 
			
		||||
        cg.add(var.set_humidity(sens))
 | 
			
		||||
    if CONF_TEMPERATURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
 | 
			
		||||
        cg.add(var.set_temperature(sens))
 | 
			
		||||
    if CONF_PRESSURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_PRESSURE])
 | 
			
		||||
        cg.add(var.set_pressure(sens))
 | 
			
		||||
    if CONF_TVOC in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TVOC])
 | 
			
		||||
        cg.add(var.set_tvoc(sens))
 | 
			
		||||
@@ -0,0 +1,83 @@
 | 
			
		||||
#include "airthings_wave_base.h"
 | 
			
		||||
 | 
			
		||||
#ifdef USE_ESP32
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace airthings_wave_base {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "airthings_wave_base";
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveBase::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_OPEN_EVT: {
 | 
			
		||||
      if (param->open.status == ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGI(TAG, "Connected successfully!");
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_DISCONNECT_EVT: {
 | 
			
		||||
      ESP_LOGW(TAG, "Disconnected!");
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_SEARCH_CMPL_EVT: {
 | 
			
		||||
      this->handle_ = 0;
 | 
			
		||||
      auto *chr = this->parent()->get_characteristic(this->service_uuid_, this->sensors_data_characteristic_uuid_);
 | 
			
		||||
      if (chr == nullptr) {
 | 
			
		||||
        ESP_LOGW(TAG, "No sensor characteristic found at service %s char %s", this->service_uuid_.to_string().c_str(),
 | 
			
		||||
                 this->sensors_data_characteristic_uuid_.to_string().c_str());
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      this->handle_ = chr->handle;
 | 
			
		||||
      this->node_state = esp32_ble_tracker::ClientState::ESTABLISHED;
 | 
			
		||||
 | 
			
		||||
      this->request_read_values_();
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_READ_CHAR_EVT: {
 | 
			
		||||
      if (param->read.conn_id != this->parent()->get_conn_id())
 | 
			
		||||
        break;
 | 
			
		||||
      if (param->read.status != ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGW(TAG, "Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      if (param->read.handle == this->handle_) {
 | 
			
		||||
        this->read_sensors(param->read.value, param->read.value_len);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AirthingsWaveBase::is_valid_voc_value_(uint16_t voc) { return 0 <= voc && voc <= 16383; }
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveBase::update() {
 | 
			
		||||
  if (this->node_state != esp32_ble_tracker::ClientState::ESTABLISHED) {
 | 
			
		||||
    if (!this->parent()->enabled) {
 | 
			
		||||
      ESP_LOGW(TAG, "Reconnecting to device");
 | 
			
		||||
      this->parent()->set_enabled(true);
 | 
			
		||||
      this->parent()->connect();
 | 
			
		||||
    } else {
 | 
			
		||||
      ESP_LOGW(TAG, "Connection in progress");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveBase::request_read_values_() {
 | 
			
		||||
  auto status = esp_ble_gattc_read_char(this->parent()->get_gattc_if(), this->parent()->get_conn_id(), this->handle_,
 | 
			
		||||
                                        ESP_GATT_AUTH_REQ_NONE);
 | 
			
		||||
  if (status) {
 | 
			
		||||
    ESP_LOGW(TAG, "Error sending read request for sensor, status=%d", status);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace airthings_wave_base
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 | 
			
		||||
#endif  // USE_ESP32
 | 
			
		||||
							
								
								
									
										50
									
								
								esphome/components/airthings_wave_base/airthings_wave_base.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								esphome/components/airthings_wave_base/airthings_wave_base.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#ifdef USE_ESP32
 | 
			
		||||
 | 
			
		||||
#include <esp_gattc_api.h>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <iterator>
 | 
			
		||||
#include "esphome/components/ble_client/ble_client.h"
 | 
			
		||||
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
 | 
			
		||||
#include "esphome/components/sensor/sensor.h"
 | 
			
		||||
#include "esphome/core/component.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace airthings_wave_base {
 | 
			
		||||
 | 
			
		||||
class AirthingsWaveBase : public PollingComponent, public ble_client::BLEClientNode {
 | 
			
		||||
 public:
 | 
			
		||||
  AirthingsWaveBase() = default;
 | 
			
		||||
 | 
			
		||||
  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 set_temperature(sensor::Sensor *temperature) { temperature_sensor_ = temperature; }
 | 
			
		||||
  void set_humidity(sensor::Sensor *humidity) { humidity_sensor_ = humidity; }
 | 
			
		||||
  void set_pressure(sensor::Sensor *pressure) { pressure_sensor_ = pressure; }
 | 
			
		||||
  void set_tvoc(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; }
 | 
			
		||||
 | 
			
		||||
 protected:
 | 
			
		||||
  bool is_valid_voc_value_(uint16_t voc);
 | 
			
		||||
 | 
			
		||||
  virtual void read_sensors(uint8_t *value, uint16_t value_len) = 0;
 | 
			
		||||
  void request_read_values_();
 | 
			
		||||
 | 
			
		||||
  sensor::Sensor *temperature_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *humidity_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *pressure_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *tvoc_sensor_{nullptr};
 | 
			
		||||
 | 
			
		||||
  uint16_t handle_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID service_uuid_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID sensors_data_characteristic_uuid_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}  // namespace airthings_wave_base
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 | 
			
		||||
#endif  // USE_ESP32
 | 
			
		||||
@@ -7,105 +7,47 @@ namespace airthings_wave_mini {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "airthings_wave_mini";
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveMini::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_OPEN_EVT: {
 | 
			
		||||
      if (param->open.status == ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGI(TAG, "Connected successfully!");
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_DISCONNECT_EVT: {
 | 
			
		||||
      ESP_LOGW(TAG, "Disconnected!");
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_SEARCH_CMPL_EVT: {
 | 
			
		||||
      this->handle_ = 0;
 | 
			
		||||
      auto *chr = this->parent()->get_characteristic(service_uuid_, sensors_data_characteristic_uuid_);
 | 
			
		||||
      if (chr == nullptr) {
 | 
			
		||||
        ESP_LOGW(TAG, "No sensor characteristic found at service %s char %s", service_uuid_.to_string().c_str(),
 | 
			
		||||
                 sensors_data_characteristic_uuid_.to_string().c_str());
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      this->handle_ = chr->handle;
 | 
			
		||||
      this->node_state = esp32_ble_tracker::ClientState::ESTABLISHED;
 | 
			
		||||
 | 
			
		||||
      request_read_values_();
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_READ_CHAR_EVT: {
 | 
			
		||||
      if (param->read.conn_id != this->parent()->get_conn_id())
 | 
			
		||||
        break;
 | 
			
		||||
      if (param->read.status != ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGW(TAG, "Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      if (param->read.handle == this->handle_) {
 | 
			
		||||
        read_sensors_(param->read.value, param->read.value_len);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveMini::read_sensors_(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
void AirthingsWaveMini::read_sensors(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
  auto *value = (WaveMiniReadings *) raw_value;
 | 
			
		||||
 | 
			
		||||
  if (sizeof(WaveMiniReadings) <= value_len) {
 | 
			
		||||
    this->humidity_sensor_->publish_state(value->humidity / 100.0f);
 | 
			
		||||
    this->pressure_sensor_->publish_state(value->pressure / 50.0f);
 | 
			
		||||
    this->temperature_sensor_->publish_state(value->temperature / 100.0f - 273.15f);
 | 
			
		||||
    if (is_valid_voc_value_(value->voc)) {
 | 
			
		||||
    if (this->humidity_sensor_ != nullptr) {
 | 
			
		||||
      this->humidity_sensor_->publish_state(value->humidity / 100.0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (this->pressure_sensor_ != nullptr) {
 | 
			
		||||
      this->pressure_sensor_->publish_state(value->pressure / 50.0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (this->temperature_sensor_ != nullptr) {
 | 
			
		||||
      this->temperature_sensor_->publish_state(value->temperature / 100.0f - 273.15f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((this->tvoc_sensor_ != nullptr) && this->is_valid_voc_value_(value->voc)) {
 | 
			
		||||
      this->tvoc_sensor_->publish_state(value->voc);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // This instance must not stay connected
 | 
			
		||||
    // so other clients can connect to it (e.g. the
 | 
			
		||||
    // mobile app).
 | 
			
		||||
    parent()->set_enabled(false);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AirthingsWaveMini::is_valid_voc_value_(uint16_t voc) { return 0 <= voc && voc <= 16383; }
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveMini::update() {
 | 
			
		||||
  if (this->node_state != esp32_ble_tracker::ClientState::ESTABLISHED) {
 | 
			
		||||
    if (!parent()->enabled) {
 | 
			
		||||
      ESP_LOGW(TAG, "Reconnecting to device");
 | 
			
		||||
      parent()->set_enabled(true);
 | 
			
		||||
      parent()->connect();
 | 
			
		||||
    } else {
 | 
			
		||||
      ESP_LOGW(TAG, "Connection in progress");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveMini::request_read_values_() {
 | 
			
		||||
  auto status = esp_ble_gattc_read_char(this->parent()->get_gattc_if(), this->parent()->get_conn_id(), this->handle_,
 | 
			
		||||
                                        ESP_GATT_AUTH_REQ_NONE);
 | 
			
		||||
  if (status) {
 | 
			
		||||
    ESP_LOGW(TAG, "Error sending read request for sensor, status=%d", status);
 | 
			
		||||
    this->parent()->set_enabled(false);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWaveMini::dump_config() {
 | 
			
		||||
  // these really don't belong here, but there doesn't seem to be a
 | 
			
		||||
  // practical way to have the base class use LOG_SENSOR and include
 | 
			
		||||
  // the TAG from this component
 | 
			
		||||
  LOG_SENSOR("  ", "Humidity", this->humidity_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Temperature", this->temperature_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Pressure", this->pressure_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "TVOC", this->tvoc_sensor_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
AirthingsWaveMini::AirthingsWaveMini()
 | 
			
		||||
    : PollingComponent(10000),
 | 
			
		||||
      service_uuid_(esp32_ble_tracker::ESPBTUUID::from_raw(SERVICE_UUID)),
 | 
			
		||||
      sensors_data_characteristic_uuid_(esp32_ble_tracker::ESPBTUUID::from_raw(CHARACTERISTIC_UUID)) {}
 | 
			
		||||
AirthingsWaveMini::AirthingsWaveMini() {
 | 
			
		||||
  this->service_uuid_ = esp32_ble_tracker::ESPBTUUID::from_raw(SERVICE_UUID);
 | 
			
		||||
  this->sensors_data_characteristic_uuid_ = esp32_ble_tracker::ESPBTUUID::from_raw(CHARACTERISTIC_UUID);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace airthings_wave_mini
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,7 @@
 | 
			
		||||
 | 
			
		||||
#ifdef USE_ESP32
 | 
			
		||||
 | 
			
		||||
#include <esp_gattc_api.h>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <iterator>
 | 
			
		||||
#include "esphome/components/ble_client/ble_client.h"
 | 
			
		||||
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
 | 
			
		||||
#include "esphome/components/sensor/sensor.h"
 | 
			
		||||
#include "esphome/core/component.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
#include "esphome/components/airthings_wave_base/airthings_wave_base.h"
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace airthings_wave_mini {
 | 
			
		||||
@@ -17,35 +10,14 @@ namespace airthings_wave_mini {
 | 
			
		||||
static const char *const SERVICE_UUID = "b42e3882-ade7-11e4-89d3-123b93f75cba";
 | 
			
		||||
static const char *const CHARACTERISTIC_UUID = "b42e3b98-ade7-11e4-89d3-123b93f75cba";
 | 
			
		||||
 | 
			
		||||
class AirthingsWaveMini : public PollingComponent, public ble_client::BLEClientNode {
 | 
			
		||||
class AirthingsWaveMini : public airthings_wave_base::AirthingsWaveBase {
 | 
			
		||||
 public:
 | 
			
		||||
  AirthingsWaveMini();
 | 
			
		||||
 | 
			
		||||
  void dump_config() override;
 | 
			
		||||
  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 set_temperature(sensor::Sensor *temperature) { temperature_sensor_ = temperature; }
 | 
			
		||||
  void set_humidity(sensor::Sensor *humidity) { humidity_sensor_ = humidity; }
 | 
			
		||||
  void set_pressure(sensor::Sensor *pressure) { pressure_sensor_ = pressure; }
 | 
			
		||||
  void set_tvoc(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; }
 | 
			
		||||
 | 
			
		||||
 protected:
 | 
			
		||||
  bool is_valid_voc_value_(uint16_t voc);
 | 
			
		||||
 | 
			
		||||
  void read_sensors_(uint8_t *value, uint16_t value_len);
 | 
			
		||||
  void request_read_values_();
 | 
			
		||||
 | 
			
		||||
  sensor::Sensor *temperature_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *humidity_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *pressure_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *tvoc_sensor_{nullptr};
 | 
			
		||||
 | 
			
		||||
  uint16_t handle_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID service_uuid_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID sensors_data_characteristic_uuid_;
 | 
			
		||||
  void read_sensors(uint8_t *value, uint16_t value_len) override;
 | 
			
		||||
 | 
			
		||||
  struct WaveMiniReadings {
 | 
			
		||||
    uint16_t unused01;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,82 +1,28 @@
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
from esphome.components import sensor, ble_client
 | 
			
		||||
from esphome.components import airthings_wave_base
 | 
			
		||||
 | 
			
		||||
from esphome.const import (
 | 
			
		||||
    DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
    DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
    DEVICE_CLASS_PRESSURE,
 | 
			
		||||
    STATE_CLASS_MEASUREMENT,
 | 
			
		||||
    UNIT_PERCENT,
 | 
			
		||||
    UNIT_CELSIUS,
 | 
			
		||||
    UNIT_HECTOPASCAL,
 | 
			
		||||
    CONF_ID,
 | 
			
		||||
    CONF_HUMIDITY,
 | 
			
		||||
    CONF_TVOC,
 | 
			
		||||
    CONF_PRESSURE,
 | 
			
		||||
    CONF_TEMPERATURE,
 | 
			
		||||
    UNIT_PARTS_PER_BILLION,
 | 
			
		||||
    ICON_RADIATOR,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["ble_client"]
 | 
			
		||||
DEPENDENCIES = airthings_wave_base.DEPENDENCIES
 | 
			
		||||
 | 
			
		||||
AUTO_LOAD = ["airthings_wave_base"]
 | 
			
		||||
 | 
			
		||||
airthings_wave_mini_ns = cg.esphome_ns.namespace("airthings_wave_mini")
 | 
			
		||||
AirthingsWaveMini = airthings_wave_mini_ns.class_(
 | 
			
		||||
    "AirthingsWaveMini", cg.PollingComponent, ble_client.BLEClientNode
 | 
			
		||||
    "AirthingsWaveMini", airthings_wave_base.AirthingsWaveBase
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CONFIG_SCHEMA = cv.All(
 | 
			
		||||
    cv.Schema(
 | 
			
		||||
        {
 | 
			
		||||
            cv.GenerateID(): cv.declare_id(AirthingsWaveMini),
 | 
			
		||||
            cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PERCENT,
 | 
			
		||||
                device_class=DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
                accuracy_decimals=2,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_CELSIUS,
 | 
			
		||||
                accuracy_decimals=2,
 | 
			
		||||
                device_class=DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_HECTOPASCAL,
 | 
			
		||||
                accuracy_decimals=2,
 | 
			
		||||
                device_class=DEVICE_CLASS_PRESSURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TVOC): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_BILLION,
 | 
			
		||||
                icon=ICON_RADIATOR,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
    .extend(cv.polling_component_schema("5min"))
 | 
			
		||||
    .extend(ble_client.BLE_CLIENT_SCHEMA),
 | 
			
		||||
CONFIG_SCHEMA = airthings_wave_base.BASE_SCHEMA.extend(
 | 
			
		||||
    {
 | 
			
		||||
        cv.GenerateID(): cv.declare_id(AirthingsWaveMini),
 | 
			
		||||
    }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    var = cg.new_Pvariable(config[CONF_ID])
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
 | 
			
		||||
    await ble_client.register_ble_node(var, config)
 | 
			
		||||
 | 
			
		||||
    if CONF_HUMIDITY in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_HUMIDITY])
 | 
			
		||||
        cg.add(var.set_humidity(sens))
 | 
			
		||||
    if CONF_TEMPERATURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
 | 
			
		||||
        cg.add(var.set_temperature(sens))
 | 
			
		||||
    if CONF_PRESSURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_PRESSURE])
 | 
			
		||||
        cg.add(var.set_pressure(sens))
 | 
			
		||||
    if CONF_TVOC in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TVOC])
 | 
			
		||||
        cg.add(var.set_tvoc(sens))
 | 
			
		||||
    await airthings_wave_base.wave_base_to_code(var, config)
 | 
			
		||||
 
 | 
			
		||||
@@ -7,55 +7,7 @@ namespace airthings_wave_plus {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "airthings_wave_plus";
 | 
			
		||||
 | 
			
		||||
void AirthingsWavePlus::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_OPEN_EVT: {
 | 
			
		||||
      if (param->open.status == ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGI(TAG, "Connected successfully!");
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_DISCONNECT_EVT: {
 | 
			
		||||
      ESP_LOGW(TAG, "Disconnected!");
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_SEARCH_CMPL_EVT: {
 | 
			
		||||
      this->handle_ = 0;
 | 
			
		||||
      auto *chr = this->parent()->get_characteristic(service_uuid_, sensors_data_characteristic_uuid_);
 | 
			
		||||
      if (chr == nullptr) {
 | 
			
		||||
        ESP_LOGW(TAG, "No sensor characteristic found at service %s char %s", service_uuid_.to_string().c_str(),
 | 
			
		||||
                 sensors_data_characteristic_uuid_.to_string().c_str());
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      this->handle_ = chr->handle;
 | 
			
		||||
      this->node_state = esp32_ble_tracker::ClientState::ESTABLISHED;
 | 
			
		||||
 | 
			
		||||
      request_read_values_();
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case ESP_GATTC_READ_CHAR_EVT: {
 | 
			
		||||
      if (param->read.conn_id != this->parent()->get_conn_id())
 | 
			
		||||
        break;
 | 
			
		||||
      if (param->read.status != ESP_GATT_OK) {
 | 
			
		||||
        ESP_LOGW(TAG, "Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      if (param->read.handle == this->handle_) {
 | 
			
		||||
        read_sensors_(param->read.value, param->read.value_len);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWavePlus::read_sensors_(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
void AirthingsWavePlus::read_sensors(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
  auto *value = (WavePlusReadings *) raw_value;
 | 
			
		||||
 | 
			
		||||
  if (sizeof(WavePlusReadings) <= value_len) {
 | 
			
		||||
@@ -64,26 +16,38 @@ void AirthingsWavePlus::read_sensors_(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
    if (value->version == 1) {
 | 
			
		||||
      ESP_LOGD(TAG, "ambient light = %d", value->ambientLight);
 | 
			
		||||
 | 
			
		||||
      this->humidity_sensor_->publish_state(value->humidity / 2.0f);
 | 
			
		||||
      if (is_valid_radon_value_(value->radon)) {
 | 
			
		||||
      if (this->humidity_sensor_ != nullptr) {
 | 
			
		||||
        this->humidity_sensor_->publish_state(value->humidity / 2.0f);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if ((this->radon_sensor_ != nullptr) && this->is_valid_radon_value_(value->radon)) {
 | 
			
		||||
        this->radon_sensor_->publish_state(value->radon);
 | 
			
		||||
      }
 | 
			
		||||
      if (is_valid_radon_value_(value->radon_lt)) {
 | 
			
		||||
 | 
			
		||||
      if ((this->radon_long_term_sensor_ != nullptr) && this->is_valid_radon_value_(value->radon_lt)) {
 | 
			
		||||
        this->radon_long_term_sensor_->publish_state(value->radon_lt);
 | 
			
		||||
      }
 | 
			
		||||
      this->temperature_sensor_->publish_state(value->temperature / 100.0f);
 | 
			
		||||
      this->pressure_sensor_->publish_state(value->pressure / 50.0f);
 | 
			
		||||
      if (is_valid_co2_value_(value->co2)) {
 | 
			
		||||
 | 
			
		||||
      if (this->temperature_sensor_ != nullptr) {
 | 
			
		||||
        this->temperature_sensor_->publish_state(value->temperature / 100.0f);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (this->pressure_sensor_ != nullptr) {
 | 
			
		||||
        this->pressure_sensor_->publish_state(value->pressure / 50.0f);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if ((this->co2_sensor_ != nullptr) && this->is_valid_co2_value_(value->co2)) {
 | 
			
		||||
        this->co2_sensor_->publish_state(value->co2);
 | 
			
		||||
      }
 | 
			
		||||
      if (is_valid_voc_value_(value->voc)) {
 | 
			
		||||
 | 
			
		||||
      if ((this->tvoc_sensor_ != nullptr) && this->is_valid_voc_value_(value->voc)) {
 | 
			
		||||
        this->tvoc_sensor_->publish_state(value->voc);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // This instance must not stay connected
 | 
			
		||||
      // so other clients can connect to it (e.g. the
 | 
			
		||||
      // mobile app).
 | 
			
		||||
      parent()->set_enabled(false);
 | 
			
		||||
      this->parent()->set_enabled(false);
 | 
			
		||||
    } else {
 | 
			
		||||
      ESP_LOGE(TAG, "Invalid payload version (%d != 1, newer version or not a Wave Plus?)", value->version);
 | 
			
		||||
    }
 | 
			
		||||
@@ -92,44 +56,26 @@ void AirthingsWavePlus::read_sensors_(uint8_t *raw_value, uint16_t value_len) {
 | 
			
		||||
 | 
			
		||||
bool AirthingsWavePlus::is_valid_radon_value_(uint16_t radon) { return 0 <= radon && radon <= 16383; }
 | 
			
		||||
 | 
			
		||||
bool AirthingsWavePlus::is_valid_voc_value_(uint16_t voc) { return 0 <= voc && voc <= 16383; }
 | 
			
		||||
 | 
			
		||||
bool AirthingsWavePlus::is_valid_co2_value_(uint16_t co2) { return 0 <= co2 && co2 <= 16383; }
 | 
			
		||||
 | 
			
		||||
void AirthingsWavePlus::update() {
 | 
			
		||||
  if (this->node_state != esp32_ble_tracker::ClientState::ESTABLISHED) {
 | 
			
		||||
    if (!parent()->enabled) {
 | 
			
		||||
      ESP_LOGW(TAG, "Reconnecting to device");
 | 
			
		||||
      parent()->set_enabled(true);
 | 
			
		||||
      parent()->connect();
 | 
			
		||||
    } else {
 | 
			
		||||
      ESP_LOGW(TAG, "Connection in progress");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWavePlus::request_read_values_() {
 | 
			
		||||
  auto status = esp_ble_gattc_read_char(this->parent()->get_gattc_if(), this->parent()->get_conn_id(), this->handle_,
 | 
			
		||||
                                        ESP_GATT_AUTH_REQ_NONE);
 | 
			
		||||
  if (status) {
 | 
			
		||||
    ESP_LOGW(TAG, "Error sending read request for sensor, status=%d", status);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AirthingsWavePlus::dump_config() {
 | 
			
		||||
  // these really don't belong here, but there doesn't seem to be a
 | 
			
		||||
  // practical way to have the base class use LOG_SENSOR and include
 | 
			
		||||
  // the TAG from this component
 | 
			
		||||
  LOG_SENSOR("  ", "Humidity", this->humidity_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Radon", this->radon_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Radon Long Term", this->radon_long_term_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Temperature", this->temperature_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Pressure", this->pressure_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "CO2", this->co2_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "TVOC", this->tvoc_sensor_);
 | 
			
		||||
 | 
			
		||||
  LOG_SENSOR("  ", "Radon", this->radon_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "Radon Long Term", this->radon_long_term_sensor_);
 | 
			
		||||
  LOG_SENSOR("  ", "CO2", this->co2_sensor_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
AirthingsWavePlus::AirthingsWavePlus()
 | 
			
		||||
    : PollingComponent(10000),
 | 
			
		||||
      service_uuid_(esp32_ble_tracker::ESPBTUUID::from_raw(SERVICE_UUID)),
 | 
			
		||||
      sensors_data_characteristic_uuid_(esp32_ble_tracker::ESPBTUUID::from_raw(CHARACTERISTIC_UUID)) {}
 | 
			
		||||
AirthingsWavePlus::AirthingsWavePlus() {
 | 
			
		||||
  this->service_uuid_ = esp32_ble_tracker::ESPBTUUID::from_raw(SERVICE_UUID);
 | 
			
		||||
  this->sensors_data_characteristic_uuid_ = esp32_ble_tracker::ESPBTUUID::from_raw(CHARACTERISTIC_UUID);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace airthings_wave_plus
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,7 @@
 | 
			
		||||
 | 
			
		||||
#ifdef USE_ESP32
 | 
			
		||||
 | 
			
		||||
#include <esp_gattc_api.h>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <iterator>
 | 
			
		||||
#include "esphome/components/ble_client/ble_client.h"
 | 
			
		||||
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
 | 
			
		||||
#include "esphome/components/sensor/sensor.h"
 | 
			
		||||
#include "esphome/core/component.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
#include "esphome/components/airthings_wave_base/airthings_wave_base.h"
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace airthings_wave_plus {
 | 
			
		||||
@@ -17,43 +10,25 @@ namespace airthings_wave_plus {
 | 
			
		||||
static const char *const SERVICE_UUID = "b42e1c08-ade7-11e4-89d3-123b93f75cba";
 | 
			
		||||
static const char *const CHARACTERISTIC_UUID = "b42e2a68-ade7-11e4-89d3-123b93f75cba";
 | 
			
		||||
 | 
			
		||||
class AirthingsWavePlus : public PollingComponent, public ble_client::BLEClientNode {
 | 
			
		||||
class AirthingsWavePlus : public airthings_wave_base::AirthingsWaveBase {
 | 
			
		||||
 public:
 | 
			
		||||
  AirthingsWavePlus();
 | 
			
		||||
 | 
			
		||||
  void dump_config() override;
 | 
			
		||||
  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 set_temperature(sensor::Sensor *temperature) { temperature_sensor_ = temperature; }
 | 
			
		||||
  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_humidity(sensor::Sensor *humidity) { humidity_sensor_ = humidity; }
 | 
			
		||||
  void set_pressure(sensor::Sensor *pressure) { pressure_sensor_ = pressure; }
 | 
			
		||||
  void set_co2(sensor::Sensor *co2) { co2_sensor_ = co2; }
 | 
			
		||||
  void set_tvoc(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; }
 | 
			
		||||
 | 
			
		||||
 protected:
 | 
			
		||||
  bool is_valid_radon_value_(uint16_t radon);
 | 
			
		||||
  bool is_valid_voc_value_(uint16_t voc);
 | 
			
		||||
  bool is_valid_co2_value_(uint16_t co2);
 | 
			
		||||
 | 
			
		||||
  void read_sensors_(uint8_t *value, uint16_t value_len);
 | 
			
		||||
  void request_read_values_();
 | 
			
		||||
  void read_sensors(uint8_t *value, uint16_t value_len) override;
 | 
			
		||||
 | 
			
		||||
  sensor::Sensor *temperature_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *radon_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *radon_long_term_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *humidity_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *pressure_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *co2_sensor_{nullptr};
 | 
			
		||||
  sensor::Sensor *tvoc_sensor_{nullptr};
 | 
			
		||||
 | 
			
		||||
  uint16_t handle_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID service_uuid_;
 | 
			
		||||
  esp32_ble_tracker::ESPBTUUID sensors_data_characteristic_uuid_;
 | 
			
		||||
 | 
			
		||||
  struct WavePlusReadings {
 | 
			
		||||
    uint8_t version;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,116 +1,64 @@
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
from esphome.components import sensor, ble_client
 | 
			
		||||
from esphome.components import sensor, airthings_wave_base
 | 
			
		||||
 | 
			
		||||
from esphome.const import (
 | 
			
		||||
    DEVICE_CLASS_CARBON_DIOXIDE,
 | 
			
		||||
    DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
    DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
    DEVICE_CLASS_PRESSURE,
 | 
			
		||||
    STATE_CLASS_MEASUREMENT,
 | 
			
		||||
    UNIT_PERCENT,
 | 
			
		||||
    UNIT_CELSIUS,
 | 
			
		||||
    UNIT_HECTOPASCAL,
 | 
			
		||||
    ICON_RADIOACTIVE,
 | 
			
		||||
    CONF_ID,
 | 
			
		||||
    CONF_RADON,
 | 
			
		||||
    CONF_RADON_LONG_TERM,
 | 
			
		||||
    CONF_HUMIDITY,
 | 
			
		||||
    CONF_TVOC,
 | 
			
		||||
    CONF_CO2,
 | 
			
		||||
    CONF_PRESSURE,
 | 
			
		||||
    CONF_TEMPERATURE,
 | 
			
		||||
    UNIT_BECQUEREL_PER_CUBIC_METER,
 | 
			
		||||
    UNIT_PARTS_PER_MILLION,
 | 
			
		||||
    UNIT_PARTS_PER_BILLION,
 | 
			
		||||
    ICON_RADIATOR,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES = ["ble_client"]
 | 
			
		||||
DEPENDENCIES = airthings_wave_base.DEPENDENCIES
 | 
			
		||||
 | 
			
		||||
AUTO_LOAD = ["airthings_wave_base"]
 | 
			
		||||
 | 
			
		||||
airthings_wave_plus_ns = cg.esphome_ns.namespace("airthings_wave_plus")
 | 
			
		||||
AirthingsWavePlus = airthings_wave_plus_ns.class_(
 | 
			
		||||
    "AirthingsWavePlus", cg.PollingComponent, ble_client.BLEClientNode
 | 
			
		||||
    "AirthingsWavePlus", airthings_wave_base.AirthingsWaveBase
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CONFIG_SCHEMA = cv.All(
 | 
			
		||||
    cv.Schema(
 | 
			
		||||
        {
 | 
			
		||||
            cv.GenerateID(): cv.declare_id(AirthingsWavePlus),
 | 
			
		||||
            cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PERCENT,
 | 
			
		||||
                device_class=DEVICE_CLASS_HUMIDITY,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_RADON): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_BECQUEREL_PER_CUBIC_METER,
 | 
			
		||||
                icon=ICON_RADIOACTIVE,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_RADON_LONG_TERM): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_BECQUEREL_PER_CUBIC_METER,
 | 
			
		||||
                icon=ICON_RADIOACTIVE,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_CELSIUS,
 | 
			
		||||
                accuracy_decimals=2,
 | 
			
		||||
                device_class=DEVICE_CLASS_TEMPERATURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_HECTOPASCAL,
 | 
			
		||||
                accuracy_decimals=1,
 | 
			
		||||
                device_class=DEVICE_CLASS_PRESSURE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_CO2): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_MILLION,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                device_class=DEVICE_CLASS_CARBON_DIOXIDE,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_TVOC): sensor.sensor_schema(
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_BILLION,
 | 
			
		||||
                icon=ICON_RADIATOR,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
    .extend(cv.polling_component_schema("5min"))
 | 
			
		||||
    .extend(ble_client.BLE_CLIENT_SCHEMA),
 | 
			
		||||
CONFIG_SCHEMA = airthings_wave_base.BASE_SCHEMA.extend(
 | 
			
		||||
    {
 | 
			
		||||
        cv.GenerateID(): cv.declare_id(AirthingsWavePlus),
 | 
			
		||||
        cv.Optional(CONF_RADON): sensor.sensor_schema(
 | 
			
		||||
            unit_of_measurement=UNIT_BECQUEREL_PER_CUBIC_METER,
 | 
			
		||||
            icon=ICON_RADIOACTIVE,
 | 
			
		||||
            accuracy_decimals=0,
 | 
			
		||||
            state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
        ),
 | 
			
		||||
        cv.Optional(CONF_RADON_LONG_TERM): sensor.sensor_schema(
 | 
			
		||||
            unit_of_measurement=UNIT_BECQUEREL_PER_CUBIC_METER,
 | 
			
		||||
            icon=ICON_RADIOACTIVE,
 | 
			
		||||
            accuracy_decimals=0,
 | 
			
		||||
            state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
        ),
 | 
			
		||||
        cv.Optional(CONF_CO2): sensor.sensor_schema(
 | 
			
		||||
            unit_of_measurement=UNIT_PARTS_PER_MILLION,
 | 
			
		||||
            accuracy_decimals=0,
 | 
			
		||||
            device_class=DEVICE_CLASS_CARBON_DIOXIDE,
 | 
			
		||||
            state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
        ),
 | 
			
		||||
    }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    var = cg.new_Pvariable(config[CONF_ID])
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
    await airthings_wave_base.wave_base_to_code(var, config)
 | 
			
		||||
 | 
			
		||||
    await ble_client.register_ble_node(var, config)
 | 
			
		||||
 | 
			
		||||
    if CONF_HUMIDITY in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_HUMIDITY])
 | 
			
		||||
        cg.add(var.set_humidity(sens))
 | 
			
		||||
    if CONF_RADON in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_RADON])
 | 
			
		||||
        cg.add(var.set_radon(sens))
 | 
			
		||||
    if CONF_RADON_LONG_TERM in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_RADON_LONG_TERM])
 | 
			
		||||
        cg.add(var.set_radon_long_term(sens))
 | 
			
		||||
    if CONF_TEMPERATURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
 | 
			
		||||
        cg.add(var.set_temperature(sens))
 | 
			
		||||
    if CONF_PRESSURE in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_PRESSURE])
 | 
			
		||||
        cg.add(var.set_pressure(sens))
 | 
			
		||||
    if CONF_CO2 in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_CO2])
 | 
			
		||||
        cg.add(var.set_co2(sens))
 | 
			
		||||
    if CONF_TVOC in config:
 | 
			
		||||
        sens = await sensor.new_sensor(config[CONF_TVOC])
 | 
			
		||||
        cg.add(var.set_tvoc(sens))
 | 
			
		||||
 
 | 
			
		||||
@@ -94,3 +94,5 @@ async def to_code(config):
 | 
			
		||||
        sens = await sensor.new_sensor(conf)
 | 
			
		||||
        cg.add(var.set_pressure_sensor(sens))
 | 
			
		||||
        cg.add(var.set_pressure_oversampling(conf[CONF_OVERSAMPLING]))
 | 
			
		||||
 | 
			
		||||
    cg.add(var.set_iir_filter(config[CONF_IIR_FILTER]))
 | 
			
		||||
 
 | 
			
		||||
@@ -6,102 +6,100 @@ namespace esphome {
 | 
			
		||||
namespace captive_portal {
 | 
			
		||||
 | 
			
		||||
const uint8_t INDEX_GZ[] PROGMEM = {
 | 
			
		||||
    0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xdd, 0x58, 0x09, 0x6f, 0xdc, 0x36, 0x16, 0xfe, 0x2b,
 | 
			
		||||
    0xac, 0x92, 0x74, 0x34, 0x8d, 0xc5, 0xd1, 0x31, 0x97, 0x35, 0xd2, 0x14, 0x89, 0x37, 0x45, 0x0b, 0x24, 0x69, 0x00,
 | 
			
		||||
    0xbb, 0x5d, 0x14, 0x69, 0x00, 0x73, 0x24, 0x6a, 0xc4, 0x58, 0xa2, 0x54, 0x91, 0x9a, 0x23, 0x83, 0xd9, 0xdf, 0xde,
 | 
			
		||||
    0x47, 0x52, 0x73, 0x38, 0x6b, 0x2f, 0x90, 0x62, 0x8b, 0xa2, 0x4d, 0x6c, 0x9a, 0xc7, 0x3b, 0x3f, 0xf2, 0xf1, 0x3d,
 | 
			
		||||
    0x2a, 0xfa, 0x2a, 0xad, 0x12, 0xb9, 0xad, 0x29, 0xca, 0x65, 0x59, 0xcc, 0x23, 0xd5, 0xa2, 0x82, 0xf0, 0x65, 0x4c,
 | 
			
		||||
    0x39, 0x8c, 0x28, 0x49, 0xe7, 0x51, 0x49, 0x25, 0x41, 0x49, 0x4e, 0x1a, 0x41, 0x65, 0xfc, 0xd3, 0xcd, 0x77, 0xce,
 | 
			
		||||
    0x14, 0x0d, 0xe6, 0x51, 0xc1, 0xf8, 0x1d, 0x6a, 0x68, 0x11, 0xb3, 0xa4, 0xe2, 0x28, 0x6f, 0x68, 0x16, 0xa7, 0x44,
 | 
			
		||||
    0x92, 0x90, 0x95, 0x64, 0x49, 0x15, 0x81, 0x66, 0xe3, 0xa4, 0xa4, 0xf1, 0x8a, 0xd1, 0x75, 0x5d, 0x35, 0x12, 0x01,
 | 
			
		||||
    0xa5, 0xa4, 0x5c, 0xc6, 0xd6, 0x9a, 0xa5, 0x32, 0x8f, 0x53, 0xba, 0x62, 0x09, 0x75, 0xf4, 0xe0, 0x82, 0x71, 0x26,
 | 
			
		||||
    0x19, 0x29, 0x1c, 0x91, 0x90, 0x82, 0xc6, 0xde, 0x45, 0x2b, 0x68, 0xa3, 0x07, 0x64, 0x01, 0x63, 0x5e, 0x59, 0x20,
 | 
			
		||||
    0x52, 0x24, 0x0d, 0xab, 0x25, 0x52, 0xf6, 0xc6, 0x65, 0x95, 0xb6, 0x05, 0x9d, 0x67, 0x2d, 0x4f, 0x24, 0x03, 0x0b,
 | 
			
		||||
    0x84, 0xcd, 0xfb, 0xbb, 0x82, 0x4a, 0x44, 0xe3, 0x37, 0x44, 0xe6, 0xb8, 0x24, 0x1b, 0xdb, 0x74, 0x18, 0xb7, 0xfd,
 | 
			
		||||
    0x6f, 0x6c, 0xfe, 0xdc, 0x73, 0xdd, 0xfe, 0x85, 0x6e, 0xdc, 0xfe, 0x00, 0xfe, 0xce, 0x1a, 0x2a, 0xdb, 0x86, 0x23,
 | 
			
		||||
    0x62, 0xdf, 0x46, 0x35, 0x50, 0xa2, 0x34, 0xb6, 0x4a, 0xcf, 0xc7, 0xae, 0x3b, 0x45, 0xde, 0x25, 0xf6, 0x47, 0x8e,
 | 
			
		||||
    0xe7, 0xe1, 0xc0, 0xf1, 0x46, 0xc9, 0xc4, 0x19, 0x21, 0x6f, 0x08, 0x8d, 0xef, 0xe3, 0x11, 0x72, 0x3f, 0x59, 0x28,
 | 
			
		||||
    0x63, 0x45, 0x11, 0x5b, 0xbc, 0xe2, 0xd4, 0x42, 0x42, 0x36, 0xd5, 0x1d, 0x8d, 0xad, 0xa4, 0x6d, 0x1a, 0xf0, 0xee,
 | 
			
		||||
    0xaa, 0x2a, 0xaa, 0x06, 0xac, 0xfd, 0x95, 0xa3, 0x7b, 0xff, 0xbe, 0x58, 0x87, 0x6c, 0x08, 0x17, 0x59, 0xd5, 0x94,
 | 
			
		||||
    0xb1, 0xa5, 0x41, 0xb1, 0x9f, 0xee, 0xe8, 0x1e, 0xa9, 0xa6, 0x7f, 0xb6, 0xe8, 0x54, 0x0d, 0x5b, 0x32, 0x1e, 0x5b,
 | 
			
		||||
    0x9e, 0x8f, 0xbc, 0x29, 0xe8, 0xbd, 0xed, 0xef, 0x8f, 0xa0, 0x10, 0x05, 0x4a, 0xe7, 0x66, 0x65, 0xbf, 0xbf, 0x8d,
 | 
			
		||||
    0xc4, 0x6a, 0x89, 0x36, 0x65, 0xc1, 0x45, 0x6c, 0xe5, 0x52, 0xd6, 0xe1, 0x60, 0xb0, 0x5e, 0xaf, 0xf1, 0x3a, 0xc0,
 | 
			
		||||
    0x55, 0xb3, 0x1c, 0xf8, 0xae, 0xeb, 0x0e, 0x80, 0xc2, 0x42, 0x66, 0x7f, 0x2c, 0x7f, 0x68, 0xa1, 0x9c, 0xb2, 0x65,
 | 
			
		||||
    0x2e, 0x75, 0x7f, 0xfe, 0x74, 0xc7, 0xf7, 0x91, 0xa2, 0x98, 0xdf, 0x7e, 0x38, 0xd3, 0xd2, 0x9c, 0x69, 0xe1, 0xdf,
 | 
			
		||||
    0x12, 0xdb, 0x3a, 0xb8, 0xda, 0x7b, 0xa3, 0x8c, 0x9a, 0x10, 0x1f, 0xf9, 0xc8, 0xd5, 0xff, 0x7d, 0x47, 0xf5, 0xbb,
 | 
			
		||||
    0x91, 0xf3, 0xd9, 0x08, 0x9d, 0x8d, 0xe0, 0xaf, 0x02, 0xd0, 0x2f, 0xc7, 0xce, 0xe5, 0x91, 0xdf, 0x53, 0xeb, 0x2b,
 | 
			
		||||
    0xcf, 0x3d, 0x4d, 0x28, 0xa6, 0xef, 0xc7, 0xe7, 0x63, 0xc7, 0xff, 0x59, 0x11, 0x68, 0xf4, 0x8f, 0x5c, 0x8e, 0x9f,
 | 
			
		||||
    0x7b, 0x3f, 0x8f, 0xc9, 0x08, 0x8d, 0xba, 0x99, 0x91, 0xa3, 0xfa, 0xc7, 0x91, 0xd6, 0x85, 0x46, 0x2b, 0x20, 0x2b,
 | 
			
		||||
    0x9d, 0xb1, 0x33, 0x22, 0x01, 0x0a, 0x3a, 0xab, 0xa0, 0x07, 0xd3, 0x63, 0xe0, 0x3e, 0x9b, 0x73, 0x82, 0x4f, 0xbd,
 | 
			
		||||
    0xc1, 0xdc, 0xea, 0x87, 0x96, 0x75, 0x82, 0xa1, 0x3a, 0x87, 0x01, 0x7f, 0xac, 0xe0, 0xdc, 0x59, 0x56, 0x7f, 0x6f,
 | 
			
		||||
    0x7d, 0x2b, 0xc8, 0x8a, 0x5a, 0x71, 0x1c, 0x43, 0xa8, 0xb5, 0x25, 0x9c, 0x10, 0x5c, 0x54, 0x09, 0x51, 0x2c, 0x58,
 | 
			
		||||
    0x50, 0xd2, 0x24, 0xf9, 0xd7, 0x5f, 0xdb, 0xc7, 0xa5, 0x25, 0x95, 0xaf, 0x0a, 0xaa, 0xba, 0xe2, 0xe5, 0xf6, 0x86,
 | 
			
		||||
    0x2c, 0xdf, 0x42, 0x00, 0xd9, 0x16, 0x11, 0x2c, 0xa5, 0x56, 0xff, 0xbd, 0xfb, 0x01, 0x0b, 0xb9, 0x2d, 0x28, 0x4e,
 | 
			
		||||
    0x99, 0xa8, 0x0b, 0xb2, 0x8d, 0xad, 0x05, 0xc8, 0xba, 0xb3, 0xfa, 0x17, 0x19, 0x95, 0x49, 0x6e, 0x5b, 0x03, 0x08,
 | 
			
		||||
    0xb1, 0x8c, 0x2d, 0xf1, 0x47, 0x51, 0x71, 0xab, 0x8f, 0x65, 0x4e, 0xb9, 0x6d, 0x1f, 0x2c, 0x54, 0xf6, 0x71, 0xbd,
 | 
			
		||||
    0x64, 0x3f, 0xb4, 0x74, 0xb4, 0x41, 0x32, 0xa9, 0x42, 0x0e, 0xab, 0xe0, 0xbd, 0x38, 0xce, 0x2e, 0xaa, 0x74, 0xfb,
 | 
			
		||||
    0x88, 0x79, 0xb9, 0x67, 0x6c, 0x63, 0x9c, 0xd3, 0xe6, 0x86, 0x6e, 0xe0, 0xb8, 0xfc, 0x9b, 0x7d, 0xc7, 0xd0, 0x5b,
 | 
			
		||||
    0x2a, 0xd7, 0x55, 0x73, 0x27, 0x42, 0x64, 0x3d, 0x37, 0xe2, 0x66, 0x26, 0x42, 0x39, 0x26, 0xb5, 0xc0, 0xa2, 0x80,
 | 
			
		||||
    0xf0, 0xb7, 0xbd, 0x3e, 0xc4, 0x6a, 0x7d, 0xdf, 0x14, 0x83, 0xe2, 0x6d, 0x94, 0xb2, 0x15, 0x4a, 0x0a, 0x22, 0xe0,
 | 
			
		||||
    0xb8, 0x72, 0x23, 0xcb, 0x42, 0x87, 0xb8, 0xaa, 0x78, 0x02, 0xfc, 0x77, 0xb1, 0xf5, 0x00, 0x76, 0x2f, 0xb7, 0x3f,
 | 
			
		||||
    0xa4, 0x76, 0x4f, 0x00, 0x6a, 0xbd, 0x3e, 0x5e, 0x91, 0xa2, 0xa5, 0x28, 0x46, 0x32, 0x67, 0xe2, 0x64, 0xe2, 0xec,
 | 
			
		||||
    0x51, 0xb6, 0x5a, 0xdc, 0x01, 0x57, 0x06, 0xcb, 0xc2, 0xee, 0x5b, 0xc7, 0x38, 0x8e, 0x88, 0xb9, 0xe5, 0xac, 0x27,
 | 
			
		||||
    0xd6, 0x67, 0x36, 0x39, 0x05, 0xcd, 0xa4, 0x75, 0x16, 0xf0, 0x4f, 0x77, 0x70, 0x1b, 0xe1, 0x06, 0xf4, 0xf7, 0xf7,
 | 
			
		||||
    0xa7, 0xd9, 0x48, 0xd4, 0x84, 0x7f, 0xce, 0xaa, 0x6c, 0xd4, 0x81, 0x85, 0x55, 0x4f, 0x45, 0x17, 0x10, 0x9d, 0x74,
 | 
			
		||||
    0x0e, 0xc8, 0xb1, 0xff, 0x74, 0x07, 0x71, 0xa6, 0x8e, 0xce, 0xdd, 0x49, 0x68, 0x34, 0x00, 0x84, 0xe6, 0xb7, 0xfb,
 | 
			
		||||
    0x7e, 0xff, 0xe4, 0xce, 0x6f, 0x2d, 0x6d, 0xb6, 0xd7, 0xb4, 0xa0, 0x89, 0xac, 0x1a, 0xdb, 0x7a, 0x02, 0x9a, 0xe0,
 | 
			
		||||
    0x24, 0x68, 0xbf, 0xbf, 0xbf, 0x79, 0xf3, 0x3a, 0xae, 0x6c, 0xda, 0xbf, 0x78, 0x8c, 0x5a, 0xdd, 0xea, 0xef, 0xe1,
 | 
			
		||||
    0x56, 0xff, 0x4f, 0xdc, 0x53, 0xf7, 0x7a, 0xef, 0x03, 0xb0, 0x1a, 0xaf, 0x4f, 0x97, 0xbb, 0xba, 0x00, 0x9e, 0xc3,
 | 
			
		||||
    0x25, 0x72, 0x61, 0x3d, 0x17, 0xb6, 0x33, 0x1e, 0xf5, 0x41, 0x3d, 0xfc, 0x80, 0xe9, 0xfa, 0x7a, 0x86, 0x6b, 0x5a,
 | 
			
		||||
    0x1d, 0xd1, 0xf9, 0x37, 0xbb, 0x45, 0xb5, 0x71, 0x04, 0xfb, 0xc4, 0xf8, 0x32, 0x64, 0x3c, 0xa7, 0x0d, 0x93, 0x7b,
 | 
			
		||||
    0x30, 0x17, 0x6e, 0xfa, 0xba, 0x95, 0xbb, 0x9a, 0xa4, 0xa9, 0x5a, 0x19, 0xd5, 0x9b, 0x59, 0x06, 0x79, 0x41, 0x51,
 | 
			
		||||
    0xd2, 0xd0, 0xa3, 0xe5, 0xde, 0xac, 0xeb, 0x2b, 0x28, 0xbc, 0x1c, 0x3d, 0xdb, 0xab, 0x83, 0xb7, 0x93, 0xb0, 0x65,
 | 
			
		||||
    0x0e, 0x29, 0xd8, 0x92, 0x87, 0x09, 0xd8, 0x4d, 0x1b, 0xc3, 0x94, 0x91, 0x92, 0x15, 0xdb, 0x50, 0xc0, 0x65, 0xe8,
 | 
			
		||||
    0x40, 0xc2, 0x60, 0xd9, 0x7e, 0xd1, 0x4a, 0x59, 0x71, 0xd0, 0xdd, 0xa4, 0xb4, 0x09, 0xdd, 0x99, 0xe9, 0x38, 0x0d,
 | 
			
		||||
    0x49, 0x59, 0x2b, 0x42, 0x1c, 0x34, 0xb4, 0x9c, 0x2d, 0x48, 0x72, 0xb7, 0x6c, 0xaa, 0x96, 0xa7, 0x4e, 0xa2, 0x6e,
 | 
			
		||||
    0xeb, 0xf0, 0x89, 0x97, 0x91, 0x80, 0x26, 0xb3, 0x6e, 0x94, 0x65, 0xd9, 0x0c, 0x90, 0xa0, 0x8e, 0xb9, 0xfc, 0x42,
 | 
			
		||||
    0x1f, 0x0f, 0x15, 0xdb, 0x99, 0x99, 0xd8, 0x57, 0x13, 0xc6, 0x46, 0x48, 0x25, 0xcf, 0x66, 0x07, 0x77, 0xdc, 0x19,
 | 
			
		||||
    0xa4, 0x01, 0x01, 0x42, 0x6a, 0x88, 0x7f, 0x30, 0x73, 0x5f, 0x12, 0xc6, 0xcf, 0xad, 0x57, 0x67, 0x65, 0xd6, 0x85,
 | 
			
		||||
    0x2f, 0xc0, 0xa2, 0xd5, 0xe8, 0x20, 0x9e, 0x41, 0xa2, 0x32, 0xb9, 0x30, 0xf4, 0xc7, 0x6e, 0xbd, 0xd9, 0xe3, 0xee,
 | 
			
		||||
    0x8c, 0xec, 0x0e, 0xd4, 0x59, 0x41, 0x37, 0xb3, 0x8f, 0xad, 0x90, 0x2c, 0xdb, 0x3a, 0x5d, 0x2e, 0x0d, 0xe1, 0xbc,
 | 
			
		||||
    0x40, 0x0e, 0x5d, 0x00, 0x29, 0xa5, 0x7c, 0xa6, 0x75, 0x38, 0x4c, 0xd2, 0x52, 0x74, 0x38, 0x1d, 0xc5, 0xe8, 0x53,
 | 
			
		||||
    0x7a, 0x5f, 0xd6, 0xff, 0xa2, 0x56, 0xc7, 0x71, 0x57, 0x92, 0x06, 0x72, 0x8b, 0xb3, 0xa8, 0x00, 0xd3, 0x32, 0x74,
 | 
			
		||||
    0x26, 0xb0, 0x57, 0xdd, 0x94, 0x12, 0x06, 0x9e, 0x83, 0x99, 0xfa, 0x6e, 0x3a, 0xe0, 0xed, 0xd5, 0x1b, 0x24, 0xaa,
 | 
			
		||||
    0x82, 0xa5, 0x1d, 0x9d, 0x26, 0x41, 0xee, 0x11, 0x1e, 0x0f, 0xb6, 0x1b, 0xa9, 0xb9, 0x03, 0xd4, 0xc3, 0x6c, 0x4a,
 | 
			
		||||
    0x3c, 0xf7, 0x81, 0x1d, 0x49, 0xb3, 0xcc, 0x5f, 0x64, 0x47, 0xa4, 0x54, 0xaa, 0xdd, 0xb3, 0xee, 0x54, 0xf8, 0x43,
 | 
			
		||||
    0x10, 0x70, 0xd8, 0x1b, 0xe8, 0xef, 0x99, 0x8e, 0x8b, 0xdd, 0x99, 0x14, 0x7d, 0x52, 0xc3, 0xb6, 0x29, 0xec, 0x87,
 | 
			
		||||
    0x4e, 0xee, 0xb3, 0xe0, 0xea, 0x94, 0x09, 0x7b, 0x8f, 0x67, 0xc2, 0x1e, 0x52, 0xb5, 0xcb, 0xcb, 0x6a, 0x13, 0xf7,
 | 
			
		||||
    0x74, 0x4e, 0x1a, 0xc2, 0x4f, 0xef, 0x59, 0xf0, 0x0a, 0xf8, 0xff, 0x2f, 0x29, 0xee, 0x0f, 0xa7, 0xb7, 0x2f, 0x48,
 | 
			
		||||
    0x6d, 0x5f, 0x98, 0xd5, 0x8c, 0x77, 0xca, 0x79, 0xe8, 0x41, 0xfa, 0x62, 0x58, 0xb0, 0xa5, 0xf7, 0x67, 0x40, 0xfb,
 | 
			
		||||
    0xdf, 0x38, 0x06, 0x2f, 0xbc, 0x29, 0xbe, 0x44, 0xba, 0x31, 0x10, 0xe1, 0x60, 0x8a, 0x26, 0x57, 0x43, 0x3c, 0xf4,
 | 
			
		||||
    0x90, 0xaa, 0x9a, 0xc6, 0x68, 0x82, 0xa7, 0x40, 0x30, 0xc6, 0xc1, 0x04, 0x26, 0x90, 0xef, 0xe1, 0xd1, 0x6b, 0x3f,
 | 
			
		||||
    0xc0, 0xe3, 0x11, 0x50, 0xf9, 0x2e, 0x0e, 0x7c, 0x64, 0x68, 0xc7, 0xd8, 0x07, 0x71, 0x8a, 0x24, 0x28, 0x01, 0xe8,
 | 
			
		||||
    0x24, 0xc0, 0xee, 0x04, 0xc4, 0x8d, 0xb1, 0x7b, 0x89, 0xa7, 0x63, 0x34, 0xc5, 0x13, 0x80, 0x0e, 0x0f, 0x47, 0x85,
 | 
			
		||||
    0x33, 0xc2, 0x1e, 0x4c, 0x07, 0x63, 0x32, 0xc5, 0xc3, 0x00, 0xe9, 0xc6, 0xc0, 0x31, 0x01, 0x11, 0x0e, 0x76, 0xbd,
 | 
			
		||||
    0xd7, 0x01, 0xf6, 0x27, 0xa0, 0x77, 0x38, 0x7c, 0x01, 0x62, 0x2f, 0x87, 0xc8, 0xb4, 0x06, 0x5e, 0x50, 0x30, 0x7a,
 | 
			
		||||
    0x0c, 0x34, 0xff, 0x9f, 0x0b, 0x1a, 0x40, 0xe2, 0xa1, 0x00, 0x5f, 0x42, 0xec, 0x7a, 0x8a, 0xdf, 0xb4, 0x06, 0x37,
 | 
			
		||||
    0xcf, 0x43, 0xee, 0x1f, 0xc6, 0x2c, 0xf8, 0xe7, 0x62, 0xe6, 0x29, 0x04, 0xa0, 0x0b, 0xba, 0x41, 0x0e, 0xd2, 0x8d,
 | 
			
		||||
    0xd1, 0x0d, 0xcc, 0xd3, 0xab, 0x4b, 0x34, 0x05, 0xae, 0xf1, 0x14, 0x5d, 0xa2, 0x91, 0x42, 0x17, 0xd8, 0x87, 0x86,
 | 
			
		||||
    0xc9, 0x01, 0xa6, 0x2f, 0x84, 0x71, 0xf8, 0x37, 0x86, 0xf1, 0x31, 0x9f, 0xfe, 0xc6, 0x2e, 0xfd, 0x15, 0x57, 0x10,
 | 
			
		||||
    0x94, 0x63, 0xba, 0x0c, 0x8b, 0x06, 0xe6, 0x15, 0xaf, 0xaa, 0x28, 0x78, 0x94, 0x43, 0x35, 0x02, 0xef, 0x7a, 0x0f,
 | 
			
		||||
    0xb1, 0x34, 0xce, 0xbd, 0xf9, 0xbd, 0x2a, 0x1d, 0x28, 0xbd, 0x79, 0xa4, 0xd3, 0xf9, 0xfc, 0x26, 0xa7, 0xe8, 0xd5,
 | 
			
		||||
    0xf5, 0x3b, 0x78, 0x08, 0x16, 0x05, 0xe2, 0xd5, 0x1a, 0xde, 0x9b, 0x5b, 0x24, 0x2b, 0xf5, 0x82, 0xe7, 0x50, 0x2a,
 | 
			
		||||
    0xaa, 0x2e, 0x3c, 0x20, 0x50, 0x57, 0x2c, 0x60, 0x8c, 0xa3, 0x45, 0x33, 0x7f, 0x57, 0x50, 0x22, 0x28, 0x5a, 0xb2,
 | 
			
		||||
    0x15, 0x45, 0x4c, 0x42, 0x1d, 0x50, 0x52, 0x24, 0x99, 0x6a, 0x8e, 0x8c, 0x9a, 0xee, 0x6d, 0x25, 0x69, 0x88, 0xae,
 | 
			
		||||
    0xaa, 0x7a, 0xab, 0x85, 0x24, 0x39, 0xe1, 0x4b, 0x9a, 0x1e, 0x84, 0x29, 0xea, 0x6d, 0xd5, 0x36, 0xe8, 0x97, 0x17,
 | 
			
		||||
    0x6f, 0x5e, 0xab, 0x87, 0x36, 0x45, 0x4e, 0xa7, 0x6c, 0x23, 0xd1, 0x8f, 0x37, 0x2f, 0x50, 0x5b, 0xc3, 0xa6, 0x53,
 | 
			
		||||
    0x63, 0x5b, 0xb5, 0xa2, 0xcd, 0x1a, 0x2a, 0x4b, 0xaa, 0x48, 0x40, 0xb9, 0xa0, 0x52, 0x42, 0xa1, 0x21, 0x30, 0x94,
 | 
			
		||||
    0xce, 0xda, 0x13, 0x53, 0x75, 0x83, 0xbb, 0x20, 0x7e, 0xde, 0x95, 0xd7, 0x51, 0x1e, 0x18, 0xd7, 0xaf, 0x3b, 0x6a,
 | 
			
		||||
    0x70, 0x3d, 0x98, 0x47, 0xea, 0x39, 0x8d, 0x88, 0x7e, 0x84, 0xc4, 0x83, 0x35, 0xcb, 0x98, 0x7a, 0xb8, 0xcd, 0x23,
 | 
			
		||||
    0x5d, 0x8f, 0x2a, 0x09, 0xaa, 0x24, 0x32, 0x5f, 0x34, 0x74, 0xaf, 0xa0, 0x7c, 0x09, 0xaf, 0x64, 0xd8, 0x70, 0xa8,
 | 
			
		||||
    0x50, 0x12, 0x9a, 0x57, 0x05, 0x54, 0x40, 0xf1, 0xf5, 0xf5, 0x0f, 0xff, 0x52, 0x9f, 0x3f, 0xc0, 0xcf, 0x13, 0x27,
 | 
			
		||||
    0x3c, 0x29, 0x0c, 0xa3, 0xea, 0x74, 0x7c, 0xe3, 0xa1, 0xf9, 0x90, 0x51, 0xc3, 0x7b, 0x00, 0xfc, 0x4e, 0xef, 0x49,
 | 
			
		||||
    0x79, 0x77, 0x98, 0xec, 0x24, 0xe9, 0x5f, 0x5d, 0xd9, 0x1a, 0x26, 0xd1, 0x2e, 0x4a, 0x26, 0xe7, 0xd7, 0x60, 0x60,
 | 
			
		||||
    0x34, 0x30, 0x0b, 0xe0, 0x9c, 0x72, 0xc0, 0xd0, 0xe6, 0x1d, 0x0f, 0xec, 0xa8, 0x42, 0xec, 0x27, 0x8d, 0x98, 0xd9,
 | 
			
		||||
    0x60, 0xed, 0x65, 0x49, 0x65, 0x5e, 0xa5, 0xf1, 0xbb, 0x1f, 0xaf, 0x6f, 0x8e, 0x1e, 0x77, 0xb0, 0x52, 0x9e, 0x98,
 | 
			
		||||
    0x0f, 0x2c, 0x6d, 0x21, 0x59, 0x4d, 0x1a, 0xa9, 0xc5, 0x3a, 0x2a, 0xce, 0x0e, 0x1e, 0xe9, 0x75, 0xbd, 0x33, 0xda,
 | 
			
		||||
    0xa9, 0x8e, 0x71, 0x30, 0x47, 0x0f, 0xd9, 0x78, 0xd0, 0xfd, 0x99, 0x95, 0x03, 0x73, 0x14, 0x07, 0xe6, 0x5c, 0x0e,
 | 
			
		||||
    0xf4, 0xe7, 0xa7, 0xdf, 0x01, 0xf1, 0x69, 0xfc, 0xac, 0x8e, 0x12, 0x00, 0x00};
 | 
			
		||||
    0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xdd, 0x58, 0x5b, 0x8f, 0xdb, 0x36, 0x16, 0x7e, 0xef,
 | 
			
		||||
    0xaf, 0xe0, 0x2a, 0x49, 0x2d, 0x37, 0x23, 0xea, 0x66, 0xf9, 0x2a, 0xa9, 0x48, 0xb2, 0x29, 0x5a, 0x20, 0x69, 0x03,
 | 
			
		||||
    0xcc, 0xb4, 0xfb, 0x10, 0x04, 0x18, 0x5a, 0xa2, 0x2c, 0x66, 0x24, 0x4a, 0x15, 0xe9, 0x5b, 0x0c, 0xef, 0x6f, 0xdf,
 | 
			
		||||
    0x43, 0x52, 0xf6, 0x38, 0xb3, 0x99, 0x05, 0x52, 0xec, 0x62, 0xd1, 0x4e, 0x26, 0x1c, 0x92, 0x3a, 0xd7, 0x4f, 0x3c,
 | 
			
		||||
    0x17, 0x2a, 0xfe, 0x5b, 0xde, 0x64, 0x72, 0xdf, 0x52, 0x54, 0xca, 0xba, 0x4a, 0x63, 0x35, 0xa2, 0x8a, 0xf0, 0x55,
 | 
			
		||||
    0x42, 0x39, 0xac, 0x28, 0xc9, 0xd3, 0xb8, 0xa6, 0x92, 0xa0, 0xac, 0x24, 0x9d, 0xa0, 0x32, 0xf9, 0xf5, 0xe6, 0x07,
 | 
			
		||||
    0x67, 0x8a, 0xdc, 0x34, 0xae, 0x18, 0xbf, 0x43, 0x1d, 0xad, 0x12, 0x96, 0x35, 0x1c, 0x95, 0x1d, 0x2d, 0x92, 0x9c,
 | 
			
		||||
    0x48, 0x32, 0x67, 0x35, 0x59, 0x51, 0x45, 0xa0, 0xd9, 0x38, 0xa9, 0x69, 0xb2, 0x61, 0x74, 0xdb, 0x36, 0x9d, 0x44,
 | 
			
		||||
    0x40, 0x29, 0x29, 0x97, 0x89, 0xb5, 0x65, 0xb9, 0x2c, 0x93, 0x9c, 0x6e, 0x58, 0x46, 0x1d, 0xbd, 0xb8, 0x62, 0x9c,
 | 
			
		||||
    0x49, 0x46, 0x2a, 0x47, 0x64, 0xa4, 0xa2, 0x89, 0x7f, 0xb5, 0x16, 0xb4, 0xd3, 0x0b, 0xb2, 0x84, 0x35, 0x6f, 0x2c,
 | 
			
		||||
    0x10, 0x29, 0xb2, 0x8e, 0xb5, 0x12, 0x29, 0x7b, 0x93, 0xba, 0xc9, 0xd7, 0x15, 0x4d, 0x5d, 0x97, 0x08, 0xb0, 0x4b,
 | 
			
		||||
    0xb8, 0x8c, 0xe7, 0x74, 0x87, 0xa7, 0xb3, 0x68, 0x32, 0x9e, 0xe6, 0x13, 0xfc, 0x51, 0x7c, 0x03, 0x9e, 0xad, 0x6b,
 | 
			
		||||
    0x50, 0x87, 0xab, 0x26, 0x23, 0x92, 0x35, 0x1c, 0x0b, 0x4a, 0xba, 0xac, 0x4c, 0x92, 0xc4, 0xfa, 0x5e, 0x90, 0x0d,
 | 
			
		||||
    0xb5, 0xbe, 0xfd, 0xd6, 0x3e, 0x13, 0xad, 0xa8, 0x7c, 0x5d, 0x51, 0x35, 0x15, 0x2f, 0xf7, 0x37, 0x64, 0xf5, 0x33,
 | 
			
		||||
    0x58, 0x6e, 0x5b, 0x44, 0xb0, 0x9c, 0x5a, 0xc3, 0xf7, 0xde, 0x07, 0x2c, 0xe4, 0xbe, 0xa2, 0x38, 0x67, 0xa2, 0xad,
 | 
			
		||||
    0xc8, 0x3e, 0xb1, 0x96, 0x20, 0xf5, 0xce, 0x1a, 0x2e, 0x8a, 0x35, 0xcf, 0x94, 0x70, 0x24, 0x6c, 0x3a, 0x3c, 0x54,
 | 
			
		||||
    0x14, 0xcc, 0x4b, 0xde, 0x12, 0x59, 0xe2, 0x9a, 0xec, 0x6c, 0x33, 0x61, 0xdc, 0x0e, 0xbe, 0xb3, 0xe9, 0x73, 0xdf,
 | 
			
		||||
    0xf3, 0x86, 0x57, 0x7a, 0xf0, 0x86, 0x2e, 0xfc, 0x5d, 0x74, 0x54, 0xae, 0x3b, 0x8e, 0x88, 0x7d, 0x1b, 0xb7, 0x40,
 | 
			
		||||
    0x89, 0xf2, 0xc4, 0xaa, 0xfd, 0x00, 0x7b, 0xde, 0x14, 0xf9, 0x33, 0x1c, 0x44, 0x8e, 0xef, 0xe3, 0xd0, 0xf1, 0xa3,
 | 
			
		||||
    0x6c, 0xe2, 0x44, 0xc8, 0x1f, 0xc1, 0x10, 0x04, 0x38, 0x42, 0xde, 0x27, 0x0b, 0x15, 0xac, 0xaa, 0x12, 0x8b, 0x37,
 | 
			
		||||
    0x9c, 0x5a, 0x48, 0xc8, 0xae, 0xb9, 0xa3, 0x89, 0x95, 0xad, 0xbb, 0x0e, 0xec, 0x7f, 0xd5, 0x54, 0x4d, 0x07, 0x70,
 | 
			
		||||
    0x7d, 0x83, 0x3e, 0xfb, 0xf9, 0x6a, 0x15, 0xb2, 0x23, 0x5c, 0x14, 0x4d, 0x57, 0x27, 0x96, 0x7e, 0x29, 0xf6, 0xd3,
 | 
			
		||||
    0x83, 0x3c, 0x22, 0x35, 0x0c, 0x2f, 0x1e, 0x3a, 0x4d, 0xc7, 0x56, 0x8c, 0x27, 0x96, 0x1f, 0x20, 0x7f, 0x0a, 0x6a,
 | 
			
		||||
    0x6f, 0x87, 0xc7, 0x33, 0x26, 0x44, 0x61, 0xd2, 0x7b, 0xd9, 0xd8, 0xef, 0x6f, 0x63, 0xb1, 0x59, 0xa1, 0x5d, 0x5d,
 | 
			
		||||
    0x71, 0x91, 0x58, 0xa5, 0x94, 0xed, 0xdc, 0x75, 0xb7, 0xdb, 0x2d, 0xde, 0x86, 0xb8, 0xe9, 0x56, 0x6e, 0xe0, 0x79,
 | 
			
		||||
    0x9e, 0x0b, 0x14, 0x16, 0x32, 0xe7, 0xc3, 0x0a, 0x46, 0x16, 0x2a, 0x29, 0x5b, 0x95, 0x52, 0xcf, 0xd3, 0xa7, 0x07,
 | 
			
		||||
    0x7a, 0x8c, 0x15, 0x45, 0x7a, 0xfb, 0xe1, 0x42, 0x4b, 0x77, 0xa1, 0x85, 0x7e, 0x7f, 0x81, 0xe6, 0xe0, 0xad, 0x32,
 | 
			
		||||
    0x6a, 0x42, 0x02, 0x14, 0x20, 0x4f, 0xff, 0x0b, 0x1c, 0x35, 0xef, 0x57, 0xce, 0x83, 0x15, 0xba, 0x58, 0xc1, 0x5f,
 | 
			
		||||
    0xc0, 0x2f, 0xa8, 0xc7, 0xce, 0xec, 0xcc, 0xee, 0xab, 0xc7, 0x1b, 0xdf, 0xbb, 0xdf, 0x50, 0x3c, 0x3f, 0x8e, 0x2f,
 | 
			
		||||
    0xd7, 0x4e, 0xf0, 0x9b, 0x22, 0x50, 0xd8, 0x9f, 0x99, 0x9c, 0xa0, 0xf4, 0x7f, 0x1b, 0x93, 0x08, 0x45, 0xfd, 0x4e,
 | 
			
		||||
    0xe4, 0xa8, 0xf9, 0x79, 0xa5, 0x34, 0xa1, 0x68, 0x03, 0x54, 0xb5, 0x33, 0x76, 0x22, 0x12, 0xa2, 0xb0, 0x37, 0x09,
 | 
			
		||||
    0x66, 0xb0, 0x3d, 0x06, 0xe6, 0x8b, 0x3d, 0x27, 0xfc, 0x34, 0x50, 0x30, 0xcf, 0x2d, 0xeb, 0x1e, 0x83, 0xe6, 0x12,
 | 
			
		||||
    0x03, 0xfc, 0xb1, 0x81, 0x33, 0x67, 0x59, 0x80, 0x11, 0x95, 0x59, 0x69, 0x5b, 0x2e, 0x44, 0x5e, 0xc1, 0x56, 0x10,
 | 
			
		||||
    0x15, 0x0d, 0xb7, 0x86, 0x58, 0x96, 0x94, 0xdb, 0x27, 0x56, 0xc5, 0x48, 0xf5, 0x13, 0xfb, 0xe1, 0x13, 0x39, 0x3c,
 | 
			
		||||
    0x9c, 0xe3, 0x43, 0x32, 0x09, 0x71, 0x28, 0xb1, 0x8a, 0xe8, 0xab, 0xf3, 0xee, 0xb2, 0xc9, 0xf7, 0x8f, 0x84, 0x4e,
 | 
			
		||||
    0xe9, 0x9b, 0xb8, 0x61, 0x9c, 0xd3, 0xee, 0x86, 0xee, 0xe0, 0x1d, 0xfe, 0x83, 0xfd, 0xc0, 0xd0, 0xcf, 0x54, 0x6e,
 | 
			
		||||
    0x9b, 0xee, 0x4e, 0xcc, 0x91, 0xf5, 0xdc, 0x88, 0x5b, 0xa8, 0xa8, 0x61, 0x20, 0x9b, 0xb4, 0x02, 0x8b, 0x0a, 0x72,
 | 
			
		||||
    0x82, 0xed, 0x0f, 0x21, 0x7e, 0xda, 0x7b, 0x4b, 0xf8, 0xc9, 0xb9, 0xdb, 0x38, 0x67, 0x1b, 0x94, 0x55, 0x10, 0xf5,
 | 
			
		||||
    0x70, 0xfc, 0x8d, 0x28, 0x0b, 0xf5, 0x47, 0xbd, 0xe1, 0x19, 0x70, 0xdf, 0x25, 0xd6, 0x17, 0xa2, 0xfa, 0xe5, 0xfe,
 | 
			
		||||
    0xa7, 0xdc, 0x1e, 0x08, 0x88, 0xe7, 0xc1, 0x10, 0x6f, 0x48, 0xb5, 0xa6, 0x28, 0x41, 0xb2, 0x64, 0xe2, 0xde, 0xc0,
 | 
			
		||||
    0xc5, 0xa3, 0x6c, 0xad, 0xb8, 0x03, 0xae, 0x02, 0x1e, 0x0b, 0x7b, 0x68, 0x9d, 0x22, 0x2b, 0x26, 0x26, 0xef, 0x59,
 | 
			
		||||
    0x4f, 0xac, 0x07, 0x16, 0x39, 0x15, 0x2d, 0xa4, 0x75, 0x1f, 0x81, 0x4f, 0x0f, 0xc2, 0xe6, 0xb8, 0x03, 0xed, 0xc3,
 | 
			
		||||
    0xe3, 0x79, 0x33, 0x16, 0x2d, 0xe1, 0x0f, 0x19, 0x95, 0x81, 0xea, 0xa0, 0x43, 0xb2, 0x82, 0x99, 0x3a, 0xed, 0x40,
 | 
			
		||||
    0x74, 0x56, 0xe8, 0x92, 0xd3, 0xf4, 0xe9, 0xa1, 0x03, 0x89, 0x2a, 0x07, 0x9d, 0x25, 0xc6, 0x2e, 0x40, 0x93, 0xde,
 | 
			
		||||
    0x1e, 0x87, 0xf7, 0x7e, 0xfc, 0xbe, 0xa6, 0xdd, 0xfe, 0x9a, 0x56, 0x34, 0x93, 0x4d, 0x67, 0x5b, 0x4f, 0x40, 0x0b,
 | 
			
		||||
    0xbc, 0x7e, 0xed, 0xf0, 0x8f, 0x37, 0x6f, 0xdf, 0x24, 0x8d, 0xcd, 0x86, 0x57, 0x8f, 0x51, 0xab, 0x0c, 0xff, 0x1e,
 | 
			
		||||
    0x32, 0xfc, 0x3f, 0x93, 0x81, 0xca, 0xf1, 0x83, 0x0f, 0xc0, 0xaa, 0xfd, 0xbd, 0xbd, 0x4f, 0xf4, 0x2a, 0x18, 0x9f,
 | 
			
		||||
    0x43, 0x40, 0x5f, 0x29, 0x0f, 0x9d, 0x71, 0x34, 0x3c, 0x82, 0x7e, 0xb0, 0x00, 0xec, 0xd6, 0xb9, 0x1a, 0x72, 0xb6,
 | 
			
		||||
    0x4a, 0x9b, 0xe9, 0x77, 0x87, 0x65, 0xb3, 0x73, 0x04, 0xfb, 0xc4, 0xf8, 0x6a, 0xce, 0x78, 0x49, 0x3b, 0x26, 0x8f,
 | 
			
		||||
    0x60, 0x2e, 0xa4, 0xfd, 0x76, 0x2d, 0x0f, 0x2d, 0xc9, 0x73, 0xf5, 0x24, 0x6a, 0x77, 0x8b, 0x02, 0x8a, 0x84, 0xa2,
 | 
			
		||||
    0xa4, 0x73, 0x9f, 0xd6, 0x47, 0xf3, 0x5c, 0xe7, 0x83, 0xf9, 0x2c, 0x7a, 0x76, 0x54, 0x07, 0xee, 0x20, 0xe1, 0x65,
 | 
			
		||||
    0x39, 0xa4, 0x62, 0x2b, 0x3e, 0xcf, 0xc0, 0x70, 0xda, 0x19, 0xa6, 0x82, 0xd4, 0xac, 0xda, 0xcf, 0x05, 0x64, 0x26,
 | 
			
		||||
    0x07, 0xaa, 0x07, 0x2b, 0x8e, 0xcb, 0xb5, 0x94, 0x0d, 0x07, 0xdd, 0x5d, 0x4e, 0xbb, 0xb9, 0xb7, 0x30, 0x13, 0xa7,
 | 
			
		||||
    0x23, 0x39, 0x5b, 0x8b, 0x39, 0x0e, 0x3b, 0x5a, 0x2f, 0x96, 0x24, 0xbb, 0x5b, 0x75, 0xcd, 0x9a, 0xe7, 0x4e, 0xa6,
 | 
			
		||||
    0x32, 0xe7, 0xfc, 0x89, 0x5f, 0x90, 0x90, 0x66, 0x8b, 0x7e, 0x55, 0x14, 0xc5, 0x02, 0xa0, 0xa0, 0x8e, 0xc9, 0x44,
 | 
			
		||||
    0xf3, 0x00, 0x8f, 0x14, 0xdb, 0x85, 0x99, 0x38, 0x50, 0x1b, 0xc6, 0x46, 0x48, 0xeb, 0xcf, 0x16, 0x27, 0x77, 0xbc,
 | 
			
		||||
    0x05, 0xa4, 0x64, 0x01, 0x42, 0x5a, 0x88, 0x47, 0x30, 0xf3, 0x58, 0x13, 0xc6, 0x2f, 0xad, 0x57, 0xc7, 0x64, 0xd1,
 | 
			
		||||
    0x97, 0x14, 0x80, 0x45, 0xab, 0xd1, 0x85, 0x65, 0x01, 0x45, 0xc3, 0x14, 0xc6, 0x79, 0x30, 0xf6, 0xda, 0xdd, 0x11,
 | 
			
		||||
    0xf7, 0x07, 0xe4, 0x70, 0xa2, 0x2e, 0x2a, 0xba, 0x5b, 0x7c, 0x5c, 0x0b, 0xc9, 0x8a, 0xbd, 0xd3, 0x17, 0xd6, 0x39,
 | 
			
		||||
    0x1c, 0x16, 0x28, 0xa8, 0x4b, 0x20, 0xa5, 0x94, 0x2f, 0xb4, 0x0e, 0x87, 0x49, 0x5a, 0x8b, 0x1e, 0xa7, 0xb3, 0x18,
 | 
			
		||||
    0x7d, 0x40, 0x3f, 0x97, 0xf5, 0x9f, 0xa8, 0xd5, 0x59, 0x3c, 0xd4, 0xa4, 0x83, 0x44, 0xef, 0x2c, 0x1b, 0xc0, 0xb4,
 | 
			
		||||
    0x9e, 0x3b, 0x13, 0x78, 0x57, 0xfd, 0x96, 0x12, 0x06, 0x9e, 0x83, 0x99, 0xba, 0x5e, 0x9e, 0xf0, 0xf6, 0xdb, 0x1d,
 | 
			
		||||
    0x12, 0x4d, 0xc5, 0xf2, 0x9e, 0x4e, 0x93, 0x20, 0xef, 0x0c, 0x8f, 0x0f, 0xaf, 0x1b, 0xa9, 0xbd, 0x13, 0xd4, 0xa3,
 | 
			
		||||
    0x62, 0x4a, 0x7c, 0xef, 0x0b, 0x6f, 0x24, 0x2f, 0x8a, 0x60, 0x59, 0x9c, 0x91, 0x52, 0x65, 0xef, 0xc8, 0xfa, 0x53,
 | 
			
		||||
    0x11, 0x8c, 0x40, 0xc0, 0xe9, 0xdd, 0xc0, 0xfc, 0xc8, 0x74, 0x58, 0x1c, 0x2e, 0xa4, 0xe8, 0xa3, 0x3a, 0x5f, 0x77,
 | 
			
		||||
    0x95, 0x6d, 0x7d, 0xe1, 0xe8, 0x3e, 0x0b, 0x5f, 0xdd, 0x97, 0xa5, 0xc1, 0xe3, 0x65, 0x69, 0x80, 0x54, 0x23, 0xf3,
 | 
			
		||||
    0xb2, 0xd9, 0x25, 0x03, 0x5d, 0x20, 0x46, 0xf0, 0x3b, 0x78, 0x16, 0xbe, 0x06, 0xfe, 0xff, 0x4a, 0xbd, 0xf9, 0xc3,
 | 
			
		||||
    0xc5, 0xe6, 0x2b, 0x2a, 0xcd, 0x57, 0x56, 0x19, 0xe3, 0x9d, 0x72, 0x1e, 0x66, 0x50, 0x4e, 0x18, 0x16, 0x6c, 0xe5,
 | 
			
		||||
    0xff, 0x2f, 0xa0, 0xfd, 0x77, 0x1c, 0xc3, 0x17, 0xfe, 0x14, 0xcf, 0x90, 0x1e, 0x0c, 0x44, 0x38, 0x9c, 0xa2, 0xc9,
 | 
			
		||||
    0xab, 0x11, 0x1e, 0xf9, 0x48, 0xb5, 0x30, 0x63, 0x34, 0x81, 0x7e, 0x0f, 0xf9, 0x63, 0x1c, 0x4e, 0x60, 0x03, 0x05,
 | 
			
		||||
    0x3e, 0x8e, 0xde, 0x04, 0x21, 0x1e, 0x47, 0x40, 0x15, 0x78, 0x38, 0x0c, 0x90, 0xa1, 0x1d, 0xe3, 0x00, 0xc4, 0x29,
 | 
			
		||||
    0x92, 0xb0, 0x06, 0xa0, 0xb3, 0x10, 0x7b, 0x13, 0x10, 0x37, 0xc6, 0xde, 0x0c, 0x4f, 0xc7, 0x68, 0x8a, 0x27, 0x00,
 | 
			
		||||
    0x1d, 0x1e, 0x45, 0x95, 0x13, 0x61, 0x1f, 0xb6, 0xc3, 0x31, 0x99, 0xe2, 0x51, 0x88, 0xf4, 0x60, 0xe0, 0x98, 0x80,
 | 
			
		||||
    0x08, 0x07, 0x7b, 0xfe, 0x9b, 0x10, 0x07, 0x13, 0xd0, 0x3b, 0x1a, 0xbd, 0x00, 0xb1, 0xb3, 0x11, 0x32, 0xa3, 0x81,
 | 
			
		||||
    0x17, 0x14, 0x44, 0x8f, 0x81, 0x16, 0xfc, 0x75, 0x41, 0x03, 0x48, 0x7c, 0x14, 0xe2, 0x19, 0xc4, 0xae, 0xaf, 0xf8,
 | 
			
		||||
    0xcd, 0x68, 0x70, 0xf3, 0x7d, 0xe4, 0xfd, 0x61, 0xcc, 0xc2, 0xbf, 0x2e, 0x66, 0xbe, 0x42, 0x00, 0xa6, 0xa0, 0x1b,
 | 
			
		||||
    0xe4, 0x20, 0x3d, 0x18, 0xdd, 0xc0, 0x3c, 0x7d, 0x35, 0x43, 0x53, 0xe0, 0x1a, 0x4f, 0xd1, 0x0c, 0x45, 0x0a, 0x5d,
 | 
			
		||||
    0x60, 0x1f, 0x19, 0x26, 0x07, 0x98, 0xbe, 0x12, 0xc6, 0xd1, 0x9f, 0x18, 0xc6, 0xc7, 0x7c, 0xfa, 0x13, 0xbb, 0xf4,
 | 
			
		||||
    0xff, 0x48, 0x41, 0xd0, 0x8e, 0xe9, 0x36, 0x2c, 0x76, 0xcd, 0x95, 0x5e, 0x75, 0x51, 0x70, 0x43, 0x87, 0x6e, 0x04,
 | 
			
		||||
    0x2e, 0xf9, 0x3e, 0x62, 0x79, 0x52, 0xfa, 0xe9, 0x67, 0xdd, 0x39, 0x50, 0xfa, 0x69, 0xac, 0xcb, 0x79, 0x7a, 0x53,
 | 
			
		||||
    0x52, 0xf4, 0xfa, 0xfa, 0x1d, 0xdc, 0xca, 0xaa, 0x0a, 0xf1, 0x66, 0x0b, 0x97, 0xbf, 0x3d, 0x92, 0x8d, 0xba, 0xce,
 | 
			
		||||
    0x73, 0xe8, 0x15, 0xd5, 0x14, 0xee, 0x0d, 0xa8, 0x6f, 0x16, 0x30, 0xc6, 0xf1, 0xb2, 0x4b, 0xdf, 0x55, 0x94, 0x08,
 | 
			
		||||
    0x8a, 0x56, 0x6c, 0x43, 0x11, 0x93, 0xd0, 0x07, 0xd4, 0x14, 0x49, 0xa6, 0x86, 0x33, 0xa3, 0xa6, 0x83, 0x9e, 0x56,
 | 
			
		||||
    0x2b, 0x31, 0xdd, 0x30, 0x58, 0x02, 0x62, 0xd2, 0xbe, 0xed, 0x8d, 0xcb, 0xd0, 0x58, 0x75, 0x4d, 0xa5, 0x84, 0x8e,
 | 
			
		||||
    0x41, 0x59, 0x15, 0xa6, 0xb1, 0xba, 0x76, 0x22, 0xa2, 0x2f, 0x06, 0x89, 0xbb, 0x65, 0x05, 0x53, 0x97, 0xf9, 0x34,
 | 
			
		||||
    0xd6, 0xad, 0xa2, 0x92, 0xa0, 0xba, 0x15, 0xf3, 0xe5, 0x41, 0xcf, 0x2a, 0xca, 0x57, 0x70, 0x9b, 0x84, 0x77, 0x01,
 | 
			
		||||
    0xcd, 0x43, 0x46, 0xcb, 0xa6, 0x82, 0xe6, 0x24, 0xb9, 0xbe, 0xfe, 0xe9, 0xef, 0xea, 0x33, 0x85, 0x32, 0xe1, 0xcc,
 | 
			
		||||
    0x09, 0x7d, 0xbe, 0x61, 0x54, 0x93, 0x9e, 0x6f, 0x3c, 0x32, 0x1f, 0x1c, 0x5a, 0xe8, 0xd3, 0xc1, 0xbf, 0xfc, 0x33,
 | 
			
		||||
    0x29, 0xef, 0x4e, 0x9b, 0xbd, 0x24, 0xfd, 0x5f, 0x37, 0x9d, 0x86, 0x49, 0xac, 0x97, 0x35, 0x93, 0xe9, 0x35, 0x18,
 | 
			
		||||
    0x18, 0xbb, 0xe6, 0x01, 0x38, 0xa7, 0x1c, 0x30, 0xb4, 0x65, 0xcf, 0x03, 0x60, 0xff, 0x72, 0xf3, 0x02, 0xfd, 0xda,
 | 
			
		||||
    0xc2, 0x09, 0xa6, 0x06, 0x7b, 0xed, 0x65, 0x4d, 0x65, 0xd9, 0xe4, 0xc9, 0xbb, 0x5f, 0xae, 0x6f, 0xce, 0x1e, 0xaf,
 | 
			
		||||
    0x35, 0x11, 0xa2, 0x3c, 0x33, 0x1f, 0x42, 0xd6, 0x95, 0x64, 0x2d, 0xe9, 0xa4, 0x16, 0xeb, 0xa8, 0x10, 0x38, 0x79,
 | 
			
		||||
    0xa4, 0x9f, 0x17, 0xac, 0xa2, 0xc6, 0xa9, 0x9e, 0xd1, 0x4d, 0xd1, 0x97, 0x6c, 0x3c, 0xe9, 0x7e, 0x60, 0xa5, 0x6b,
 | 
			
		||||
    0x4e, 0x89, 0x6b, 0x8e, 0x8c, 0xab, 0x3f, 0x13, 0xfd, 0x0b, 0x65, 0x37, 0xa3, 0x8e, 0x36, 0x12, 0x00, 0x00};
 | 
			
		||||
 | 
			
		||||
}  // namespace captive_portal
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ from esphome.const import (
 | 
			
		||||
    ICON_RADIATOR,
 | 
			
		||||
    ICON_RESTART,
 | 
			
		||||
    DEVICE_CLASS_CARBON_DIOXIDE,
 | 
			
		||||
    DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
 | 
			
		||||
    DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
    STATE_CLASS_MEASUREMENT,
 | 
			
		||||
    UNIT_PARTS_PER_MILLION,
 | 
			
		||||
    UNIT_PARTS_PER_BILLION,
 | 
			
		||||
@@ -43,7 +43,7 @@ CONFIG_SCHEMA = (
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_BILLION,
 | 
			
		||||
                icon=ICON_RADIATOR,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
 | 
			
		||||
                device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_VERSION): text_sensor.text_sensor_schema(
 | 
			
		||||
 
 | 
			
		||||
@@ -151,11 +151,13 @@ void FujitsuGeneralClimate::transmit_state() {
 | 
			
		||||
    case climate::CLIMATE_FAN_LOW:
 | 
			
		||||
      SET_NIBBLE(remote_state, FUJITSU_GENERAL_FAN_NIBBLE, FUJITSU_GENERAL_FAN_LOW);
 | 
			
		||||
      break;
 | 
			
		||||
    case climate::CLIMATE_FAN_QUIET:
 | 
			
		||||
      SET_NIBBLE(remote_state, FUJITSU_GENERAL_FAN_NIBBLE, FUJITSU_GENERAL_FAN_SILENT);
 | 
			
		||||
      break;
 | 
			
		||||
    case climate::CLIMATE_FAN_AUTO:
 | 
			
		||||
    default:
 | 
			
		||||
      SET_NIBBLE(remote_state, FUJITSU_GENERAL_FAN_NIBBLE, FUJITSU_GENERAL_FAN_AUTO);
 | 
			
		||||
      break;
 | 
			
		||||
      // TODO Quiet / Silent
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Set swing
 | 
			
		||||
@@ -345,8 +347,9 @@ bool FujitsuGeneralClimate::on_receive(remote_base::RemoteReceiveData data) {
 | 
			
		||||
    const uint8_t recv_fan_mode = GET_NIBBLE(recv_message, FUJITSU_GENERAL_FAN_NIBBLE);
 | 
			
		||||
    ESP_LOGV(TAG, "Received fan mode %X", recv_fan_mode);
 | 
			
		||||
    switch (recv_fan_mode) {
 | 
			
		||||
      // TODO No Quiet / Silent in ESPH
 | 
			
		||||
      case FUJITSU_GENERAL_FAN_SILENT:
 | 
			
		||||
        this->fan_mode = climate::CLIMATE_FAN_QUIET;
 | 
			
		||||
        break;
 | 
			
		||||
      case FUJITSU_GENERAL_FAN_LOW:
 | 
			
		||||
        this->fan_mode = climate::CLIMATE_FAN_LOW;
 | 
			
		||||
        break;
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ class FujitsuGeneralClimate : public climate_ir::ClimateIR {
 | 
			
		||||
  FujitsuGeneralClimate()
 | 
			
		||||
      : ClimateIR(FUJITSU_GENERAL_TEMP_MIN, FUJITSU_GENERAL_TEMP_MAX, 1.0f, true, true,
 | 
			
		||||
                  {climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, climate::CLIMATE_FAN_MEDIUM,
 | 
			
		||||
                   climate::CLIMATE_FAN_HIGH},
 | 
			
		||||
                   climate::CLIMATE_FAN_HIGH, climate::CLIMATE_FAN_QUIET},
 | 
			
		||||
                  {climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL, climate::CLIMATE_SWING_HORIZONTAL,
 | 
			
		||||
                   climate::CLIMATE_SWING_BOTH}) {}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,11 +9,42 @@ static const char *const TAG = "growatt_solar";
 | 
			
		||||
static const uint8_t MODBUS_CMD_READ_IN_REGISTERS = 0x04;
 | 
			
		||||
static const uint8_t MODBUS_REGISTER_COUNT[] = {33, 95};  // indexed with enum GrowattProtocolVersion
 | 
			
		||||
 | 
			
		||||
void GrowattSolar::loop() {
 | 
			
		||||
  // If update() was unable to send we retry until we can send.
 | 
			
		||||
  if (!this->waiting_to_update_)
 | 
			
		||||
    return;
 | 
			
		||||
  update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GrowattSolar::update() {
 | 
			
		||||
  // If our last send has had no reply yet, and it wasn't that long ago, do nothing.
 | 
			
		||||
  uint32_t now = millis();
 | 
			
		||||
  if (now - this->last_send_ < this->get_update_interval() / 2) {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // The bus might be slow, or there might be other devices, or other components might be talking to our device.
 | 
			
		||||
  if (this->waiting_for_response()) {
 | 
			
		||||
    this->waiting_to_update_ = true;
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  this->waiting_to_update_ = false;
 | 
			
		||||
  this->send(MODBUS_CMD_READ_IN_REGISTERS, 0, MODBUS_REGISTER_COUNT[this->protocol_version_]);
 | 
			
		||||
  this->last_send_ = millis();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GrowattSolar::on_modbus_data(const std::vector<uint8_t> &data) {
 | 
			
		||||
  // Other components might be sending commands to our device. But we don't get called with enough
 | 
			
		||||
  // context to know what is what. So if we didn't do a send, we ignore the data.
 | 
			
		||||
  if (!this->last_send_)
 | 
			
		||||
    return;
 | 
			
		||||
  this->last_send_ = 0;
 | 
			
		||||
 | 
			
		||||
  // Also ignore the data if the message is too short. Otherwise we will publish invalid values.
 | 
			
		||||
  if (data.size() < MODBUS_REGISTER_COUNT[this->protocol_version_] * 2)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  auto publish_1_reg_sensor_state = [&](sensor::Sensor *sensor, size_t i, float unit) -> void {
 | 
			
		||||
    if (sensor == nullptr)
 | 
			
		||||
      return;
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ enum GrowattProtocolVersion {
 | 
			
		||||
 | 
			
		||||
class GrowattSolar : public PollingComponent, public modbus::ModbusDevice {
 | 
			
		||||
 public:
 | 
			
		||||
  void loop() override;
 | 
			
		||||
  void update() override;
 | 
			
		||||
  void on_modbus_data(const std::vector<uint8_t> &data) override;
 | 
			
		||||
  void dump_config() override;
 | 
			
		||||
@@ -55,6 +56,9 @@ class GrowattSolar : public PollingComponent, public modbus::ModbusDevice {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 protected:
 | 
			
		||||
  bool waiting_to_update_;
 | 
			
		||||
  uint32_t last_send_;
 | 
			
		||||
 | 
			
		||||
  struct GrowattPhase {
 | 
			
		||||
    sensor::Sensor *voltage_sensor_{nullptr};
 | 
			
		||||
    sensor::Sensor *current_sensor_{nullptr};
 | 
			
		||||
 
 | 
			
		||||
@@ -29,13 +29,10 @@ void PCA9685Output::setup() {
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "Setting up PCA9685OutputComponent...");
 | 
			
		||||
 | 
			
		||||
  ESP_LOGV(TAG, "  Resetting devices...");
 | 
			
		||||
  uint8_t address_tmp = this->address_;
 | 
			
		||||
  this->set_i2c_address(0x00);
 | 
			
		||||
  if (!this->write_bytes(PCA9685_REGISTER_SOFTWARE_RESET, nullptr, 0)) {
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  this->set_i2c_address(address_tmp);
 | 
			
		||||
 | 
			
		||||
  if (!this->write_byte(PCA9685_REGISTER_MODE1, PCA9685_MODE1_RESTART | PCA9685_MODE1_AUTOINC)) {
 | 
			
		||||
    this->mark_failed();
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ from esphome.const import (
 | 
			
		||||
    CONF_TVOC,
 | 
			
		||||
    ICON_RADIATOR,
 | 
			
		||||
    DEVICE_CLASS_CARBON_DIOXIDE,
 | 
			
		||||
    DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
 | 
			
		||||
    DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
    STATE_CLASS_MEASUREMENT,
 | 
			
		||||
    UNIT_PARTS_PER_MILLION,
 | 
			
		||||
    UNIT_PARTS_PER_BILLION,
 | 
			
		||||
@@ -49,7 +49,7 @@ CONFIG_SCHEMA = (
 | 
			
		||||
                unit_of_measurement=UNIT_PARTS_PER_BILLION,
 | 
			
		||||
                icon=ICON_RADIATOR,
 | 
			
		||||
                accuracy_decimals=0,
 | 
			
		||||
                device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
 | 
			
		||||
                device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
 | 
			
		||||
                state_class=STATE_CLASS_MEASUREMENT,
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_ECO2_BASELINE): sensor.sensor_schema(
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ from esphome.const import (
 | 
			
		||||
    CONF_PASSWORD,
 | 
			
		||||
    CONF_INCLUDE_INTERNAL,
 | 
			
		||||
    CONF_OTA,
 | 
			
		||||
    CONF_LOG,
 | 
			
		||||
    CONF_VERSION,
 | 
			
		||||
    CONF_LOCAL,
 | 
			
		||||
)
 | 
			
		||||
@@ -71,6 +72,7 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_INCLUDE_INTERNAL, default=False): cv.boolean,
 | 
			
		||||
            cv.Optional(CONF_OTA, default=True): cv.boolean,
 | 
			
		||||
            cv.Optional(CONF_LOG, default=True): cv.boolean,
 | 
			
		||||
            cv.Optional(CONF_LOCAL): cv.boolean,
 | 
			
		||||
        }
 | 
			
		||||
    ).extend(cv.COMPONENT_SCHEMA),
 | 
			
		||||
@@ -81,6 +83,37 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def build_index_html(config) -> str:
 | 
			
		||||
    html = "<!DOCTYPE html><html><head><meta charset=UTF-8><link rel=icon href=data:>"
 | 
			
		||||
    css_include = config.get(CONF_CSS_INCLUDE)
 | 
			
		||||
    js_include = config.get(CONF_JS_INCLUDE)
 | 
			
		||||
    if css_include:
 | 
			
		||||
        html += "<link rel=stylesheet href=/0.css>"
 | 
			
		||||
    if config[CONF_CSS_URL]:
 | 
			
		||||
        html += f'<link rel=stylesheet href="{config[CONF_CSS_URL]}">'
 | 
			
		||||
    html += "</head><body>"
 | 
			
		||||
    if js_include:
 | 
			
		||||
        html += "<script type=module src=/0.js></script>"
 | 
			
		||||
    html += "<esp-app></esp-app>"
 | 
			
		||||
    if config[CONF_JS_URL]:
 | 
			
		||||
        html += f'<script src="{config[CONF_JS_URL]}"></script>'
 | 
			
		||||
    html += "</body></html>"
 | 
			
		||||
    return html
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def add_resource_as_progmem(resource_name: str, content: str) -> None:
 | 
			
		||||
    """Add a resource to progmem."""
 | 
			
		||||
    content_encoded = content.encode("utf-8")
 | 
			
		||||
    content_encoded_size = len(content_encoded)
 | 
			
		||||
    bytes_as_int = ", ".join(str(x) for x in content_encoded)
 | 
			
		||||
    uint8_t = f"const uint8_t ESPHOME_WEBSERVER_{resource_name}[{content_encoded_size}] PROGMEM = {{{bytes_as_int}}}"
 | 
			
		||||
    size_t = (
 | 
			
		||||
        f"const size_t ESPHOME_WEBSERVER_{resource_name}_SIZE = {content_encoded_size}"
 | 
			
		||||
    )
 | 
			
		||||
    cg.add_global(cg.RawExpression(uint8_t))
 | 
			
		||||
    cg.add_global(cg.RawExpression(size_t))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@coroutine_with_priority(40.0)
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    paren = await cg.get_variable(config[CONF_WEB_SERVER_BASE_ID])
 | 
			
		||||
@@ -89,27 +122,32 @@ async def to_code(config):
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
 | 
			
		||||
    cg.add_define("USE_WEBSERVER")
 | 
			
		||||
    version = config[CONF_VERSION]
 | 
			
		||||
 | 
			
		||||
    cg.add(paren.set_port(config[CONF_PORT]))
 | 
			
		||||
    cg.add_define("USE_WEBSERVER")
 | 
			
		||||
    cg.add_define("USE_WEBSERVER_PORT", config[CONF_PORT])
 | 
			
		||||
    cg.add_define("USE_WEBSERVER_VERSION", config[CONF_VERSION])
 | 
			
		||||
    cg.add(var.set_css_url(config[CONF_CSS_URL]))
 | 
			
		||||
    cg.add(var.set_js_url(config[CONF_JS_URL]))
 | 
			
		||||
    cg.add_define("USE_WEBSERVER_VERSION", version)
 | 
			
		||||
    if version == 2:
 | 
			
		||||
        add_resource_as_progmem("INDEX_HTML", build_index_html(config))
 | 
			
		||||
    else:
 | 
			
		||||
        cg.add(var.set_css_url(config[CONF_CSS_URL]))
 | 
			
		||||
        cg.add(var.set_js_url(config[CONF_JS_URL]))
 | 
			
		||||
    cg.add(var.set_allow_ota(config[CONF_OTA]))
 | 
			
		||||
    cg.add(var.set_expose_log(config[CONF_LOG]))
 | 
			
		||||
    if CONF_AUTH in config:
 | 
			
		||||
        cg.add(paren.set_auth_username(config[CONF_AUTH][CONF_USERNAME]))
 | 
			
		||||
        cg.add(paren.set_auth_password(config[CONF_AUTH][CONF_PASSWORD]))
 | 
			
		||||
    if CONF_CSS_INCLUDE in config:
 | 
			
		||||
        cg.add_define("USE_WEBSERVER_CSS_INCLUDE")
 | 
			
		||||
        path = CORE.relative_config_path(config[CONF_CSS_INCLUDE])
 | 
			
		||||
        with open(file=path, encoding="utf-8") as myfile:
 | 
			
		||||
            cg.add(var.set_css_include(myfile.read()))
 | 
			
		||||
        with open(file=path, encoding="utf-8") as css_file:
 | 
			
		||||
            add_resource_as_progmem("CSS_INCLUDE", css_file.read())
 | 
			
		||||
    if CONF_JS_INCLUDE in config:
 | 
			
		||||
        cg.add_define("USE_WEBSERVER_JS_INCLUDE")
 | 
			
		||||
        path = CORE.relative_config_path(config[CONF_JS_INCLUDE])
 | 
			
		||||
        with open(file=path, encoding="utf-8") as myfile:
 | 
			
		||||
            cg.add(var.set_js_include(myfile.read()))
 | 
			
		||||
        with open(file=path, encoding="utf-8") as js_file:
 | 
			
		||||
            add_resource_as_progmem("JS_INCLUDE", js_file.read())
 | 
			
		||||
    cg.add(var.set_include_internal(config[CONF_INCLUDE_INTERNAL]))
 | 
			
		||||
    if CONF_LOCAL in config and config[CONF_LOCAL]:
 | 
			
		||||
        cg.add_define("USE_WEBSERVER_LOCAL")
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -90,10 +90,27 @@ WebServer::WebServer(web_server_base::WebServerBase *base)
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
void WebServer::set_css_url(const char *css_url) { this->css_url_ = css_url; }
 | 
			
		||||
void WebServer::set_css_include(const char *css_include) { this->css_include_ = css_include; }
 | 
			
		||||
void WebServer::set_js_url(const char *js_url) { this->js_url_ = js_url; }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
void WebServer::set_css_include(const char *css_include) { this->css_include_ = css_include; }
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
void WebServer::set_js_include(const char *js_include) { this->js_include_ = js_include; }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
std::string WebServer::get_config_json() {
 | 
			
		||||
  return json::build_json([this](JsonObject root) {
 | 
			
		||||
    root["title"] = App.get_friendly_name().empty() ? App.get_name() : App.get_friendly_name();
 | 
			
		||||
    root["comment"] = App.get_comment();
 | 
			
		||||
    root["ota"] = this->allow_ota_;
 | 
			
		||||
    root["log"] = this->expose_log_;
 | 
			
		||||
    root["lang"] = "en";
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WebServer::setup() {
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "Setting up web server...");
 | 
			
		||||
@@ -102,20 +119,13 @@ void WebServer::setup() {
 | 
			
		||||
 | 
			
		||||
  this->events_.onConnect([this](AsyncEventSourceClient *client) {
 | 
			
		||||
    // Configure reconnect timeout and send config
 | 
			
		||||
 | 
			
		||||
    client->send(json::build_json([this](JsonObject root) {
 | 
			
		||||
                   root["title"] = App.get_friendly_name().empty() ? App.get_name() : App.get_friendly_name();
 | 
			
		||||
                   root["comment"] = App.get_comment();
 | 
			
		||||
                   root["ota"] = this->allow_ota_;
 | 
			
		||||
                   root["lang"] = "en";
 | 
			
		||||
                 }).c_str(),
 | 
			
		||||
                 "ping", millis(), 30000);
 | 
			
		||||
    client->send(this->get_config_json().c_str(), "ping", millis(), 30000);
 | 
			
		||||
 | 
			
		||||
    this->entities_iterator_.begin(this->include_internal_);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
#ifdef USE_LOGGER
 | 
			
		||||
  if (logger::global_logger != nullptr) {
 | 
			
		||||
  if (logger::global_logger != nullptr && this->expose_log_) {
 | 
			
		||||
    logger::global_logger->add_on_log_callback(
 | 
			
		||||
        [this](int level, const char *tag, const char *message) { this->events_.send(message, "log", millis()); });
 | 
			
		||||
  }
 | 
			
		||||
@@ -159,20 +169,14 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
 | 
			
		||||
  response->addHeader("Content-Encoding", "gzip");
 | 
			
		||||
  request->send(response);
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
#elif USE_WEBSERVER_VERSION == 1
 | 
			
		||||
void WebServer::handle_index_request(AsyncWebServerRequest *request) {
 | 
			
		||||
  AsyncResponseStream *stream = request->beginResponseStream("text/html");
 | 
			
		||||
  // All content is controlled and created by user - so allowing all origins is fine here.
 | 
			
		||||
  stream->addHeader("Access-Control-Allow-Origin", "*");
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
  const std::string &title = App.get_name();
 | 
			
		||||
  stream->print(F("<!DOCTYPE html><html lang=\"en\"><head><meta charset=UTF-8><meta "
 | 
			
		||||
                  "name=viewport content=\"width=device-width, initial-scale=1,user-scalable=no\"><title>"));
 | 
			
		||||
  stream->print(title.c_str());
 | 
			
		||||
  stream->print(F("</title>"));
 | 
			
		||||
#else
 | 
			
		||||
  stream->print(F("<!DOCTYPE html><html><head><meta charset=UTF-8><link rel=icon href=data:>"));
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
  stream->print(F("<link rel=\"stylesheet\" href=\"/0.css\">"));
 | 
			
		||||
#endif
 | 
			
		||||
@@ -182,7 +186,6 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
 | 
			
		||||
    stream->print(F("\">"));
 | 
			
		||||
  }
 | 
			
		||||
  stream->print(F("</head><body>"));
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
  stream->print(F("<article class=\"markdown-body\"><h1>"));
 | 
			
		||||
  stream->print(title.c_str());
 | 
			
		||||
  stream->print(F("</h1>"));
 | 
			
		||||
@@ -308,49 +311,40 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
 | 
			
		||||
          "type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"));
 | 
			
		||||
  }
 | 
			
		||||
  stream->print(F("<h2>Debug Log</h2><pre id=\"log\"></pre>"));
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
  if (this->js_include_ != nullptr) {
 | 
			
		||||
    stream->print(F("<script type=\"module\" src=\"/0.js\"></script>"));
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 2
 | 
			
		||||
  stream->print(F("<esp-app></esp-app>"));
 | 
			
		||||
#endif
 | 
			
		||||
  if (strlen(this->js_url_) > 0) {
 | 
			
		||||
    stream->print(F("<script src=\""));
 | 
			
		||||
    stream->print(this->js_url_);
 | 
			
		||||
    stream->print(F("\"></script>"));
 | 
			
		||||
  }
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
  stream->print(F("</article></body></html>"));
 | 
			
		||||
#else
 | 
			
		||||
  stream->print(F("</body></html>"));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  request->send(stream);
 | 
			
		||||
}
 | 
			
		||||
#elif USE_WEBSERVER_VERSION == 2
 | 
			
		||||
void WebServer::handle_index_request(AsyncWebServerRequest *request) {
 | 
			
		||||
  AsyncWebServerResponse *response =
 | 
			
		||||
      request->beginResponse_P(200, "text/html", ESPHOME_WEBSERVER_INDEX_HTML, ESPHOME_WEBSERVER_INDEX_HTML_SIZE);
 | 
			
		||||
  request->send(response);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
void WebServer::handle_css_request(AsyncWebServerRequest *request) {
 | 
			
		||||
  AsyncResponseStream *stream = request->beginResponseStream("text/css");
 | 
			
		||||
  if (this->css_include_ != nullptr) {
 | 
			
		||||
    stream->print(this->css_include_);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  request->send(stream);
 | 
			
		||||
  AsyncWebServerResponse *response =
 | 
			
		||||
      request->beginResponse_P(200, "text/css", ESPHOME_WEBSERVER_CSS_INCLUDE, ESPHOME_WEBSERVER_CSS_INCLUDE_SIZE);
 | 
			
		||||
  request->send(response);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
void WebServer::handle_js_request(AsyncWebServerRequest *request) {
 | 
			
		||||
  AsyncResponseStream *stream = request->beginResponseStream("text/javascript");
 | 
			
		||||
  if (this->js_include_ != nullptr) {
 | 
			
		||||
    stream->addHeader("Access-Control-Allow-Origin", "*");
 | 
			
		||||
    stream->print(this->js_include_);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  request->send(stream);
 | 
			
		||||
  AsyncWebServerResponse *response =
 | 
			
		||||
      request->beginResponse_P(200, "text/javascript", ESPHOME_WEBSERVER_JS_INCLUDE, ESPHOME_WEBSERVER_JS_INCLUDE_SIZE);
 | 
			
		||||
  request->send(response);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,22 @@
 | 
			
		||||
#include <freertos/FreeRTOS.h>
 | 
			
		||||
#include <freertos/semphr.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 2
 | 
			
		||||
extern const uint8_t ESPHOME_WEBSERVER_INDEX_HTML[] PROGMEM;
 | 
			
		||||
extern const size_t ESPHOME_WEBSERVER_INDEX_HTML_SIZE;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
extern const uint8_t ESPHOME_WEBSERVER_CSS_INCLUDE[] PROGMEM;
 | 
			
		||||
extern const size_t ESPHOME_WEBSERVER_CSS_INCLUDE_SIZE;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
extern const uint8_t ESPHOME_WEBSERVER_JS_INCLUDE[] PROGMEM;
 | 
			
		||||
extern const size_t ESPHOME_WEBSERVER_JS_INCLUDE_SIZE;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace web_server {
 | 
			
		||||
 | 
			
		||||
@@ -40,6 +56,7 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
 | 
			
		||||
 public:
 | 
			
		||||
  WebServer(web_server_base::WebServerBase *base);
 | 
			
		||||
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
  /** Set the URL to the CSS <link> that's sent to each client. Defaults to
 | 
			
		||||
   * https://esphome.io/_static/webserver-v1.min.css
 | 
			
		||||
   *
 | 
			
		||||
@@ -47,24 +64,29 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
 | 
			
		||||
   */
 | 
			
		||||
  void set_css_url(const char *css_url);
 | 
			
		||||
 | 
			
		||||
  /** Set local path to the script that's embedded in the index page. Defaults to
 | 
			
		||||
   *
 | 
			
		||||
   * @param css_include Local path to web server script.
 | 
			
		||||
   */
 | 
			
		||||
  void set_css_include(const char *css_include);
 | 
			
		||||
 | 
			
		||||
  /** Set the URL to the script that's embedded in the index page. Defaults to
 | 
			
		||||
   * https://esphome.io/_static/webserver-v1.min.js
 | 
			
		||||
   *
 | 
			
		||||
   * @param js_url The url to the web server script.
 | 
			
		||||
   */
 | 
			
		||||
  void set_js_url(const char *js_url);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
  /** Set local path to the script that's embedded in the index page. Defaults to
 | 
			
		||||
   *
 | 
			
		||||
   * @param css_include Local path to web server script.
 | 
			
		||||
   */
 | 
			
		||||
  void set_css_include(const char *css_include);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
  /** Set local path to the script that's embedded in the index page. Defaults to
 | 
			
		||||
   *
 | 
			
		||||
   * @param js_include Local path to web server script.
 | 
			
		||||
   */
 | 
			
		||||
  void set_js_include(const char *js_include);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /** Determine whether internal components should be displayed on the web server.
 | 
			
		||||
   * Defaults to false.
 | 
			
		||||
@@ -77,6 +99,11 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
 | 
			
		||||
   * @param allow_ota.
 | 
			
		||||
   */
 | 
			
		||||
  void set_allow_ota(bool allow_ota) { this->allow_ota_ = allow_ota; }
 | 
			
		||||
  /** Set whether or not the webserver should expose the Log.
 | 
			
		||||
   *
 | 
			
		||||
   * @param expose_log.
 | 
			
		||||
   */
 | 
			
		||||
  void set_expose_log(bool expose_log) { this->expose_log_ = expose_log; }
 | 
			
		||||
 | 
			
		||||
  // ========== INTERNAL METHODS ==========
 | 
			
		||||
  // (In most use cases you won't need these)
 | 
			
		||||
@@ -92,6 +119,9 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
 | 
			
		||||
  /// Handle an index request under '/'.
 | 
			
		||||
  void handle_index_request(AsyncWebServerRequest *request);
 | 
			
		||||
 | 
			
		||||
  /// Return the webserver configuration as JSON.
 | 
			
		||||
  std::string get_config_json();
 | 
			
		||||
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
  /// Handle included css request under '/0.css'.
 | 
			
		||||
  void handle_css_request(AsyncWebServerRequest *request);
 | 
			
		||||
@@ -240,12 +270,19 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
 | 
			
		||||
  web_server_base::WebServerBase *base_;
 | 
			
		||||
  AsyncEventSource events_{"/events"};
 | 
			
		||||
  ListEntitiesIterator entities_iterator_;
 | 
			
		||||
#if USE_WEBSERVER_VERSION == 1
 | 
			
		||||
  const char *css_url_{nullptr};
 | 
			
		||||
  const char *css_include_{nullptr};
 | 
			
		||||
  const char *js_url_{nullptr};
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef USE_WEBSERVER_CSS_INCLUDE
 | 
			
		||||
  const char *css_include_{nullptr};
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef USE_WEBSERVER_JS_INCLUDE
 | 
			
		||||
  const char *js_include_{nullptr};
 | 
			
		||||
#endif
 | 
			
		||||
  bool include_internal_{false};
 | 
			
		||||
  bool allow_ota_{true};
 | 
			
		||||
  bool expose_log_{true};
 | 
			
		||||
#ifdef USE_ESP32
 | 
			
		||||
  std::deque<std::function<void()>> to_schedule_;
 | 
			
		||||
  SemaphoreHandle_t to_schedule_lock_;
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,7 @@ class WebServerBase : public Component {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    this->server_ = std::make_shared<AsyncWebServer>(this->port_);
 | 
			
		||||
    // All content is controlled and created by user - so allowing all origins is fine here.
 | 
			
		||||
    DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
 | 
			
		||||
    this->server_->begin();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
"""Constants used by esphome."""
 | 
			
		||||
 | 
			
		||||
__version__ = "2023.6.0b2"
 | 
			
		||||
__version__ = "2023.6.0b7"
 | 
			
		||||
 | 
			
		||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
VALID_SUBSTITUTIONS_CHARACTERS = (
 | 
			
		||||
@@ -368,6 +368,7 @@ CONF_LINE_TYPE = "line_type"
 | 
			
		||||
CONF_LOADED_INTEGRATIONS = "loaded_integrations"
 | 
			
		||||
CONF_LOCAL = "local"
 | 
			
		||||
CONF_LOCK_ACTION = "lock_action"
 | 
			
		||||
CONF_LOG = "log"
 | 
			
		||||
CONF_LOG_TOPIC = "log_topic"
 | 
			
		||||
CONF_LOGGER = "logger"
 | 
			
		||||
CONF_LOGS = "logs"
 | 
			
		||||
 
 | 
			
		||||
@@ -99,7 +99,7 @@ void Application::loop() {
 | 
			
		||||
 | 
			
		||||
  if (this->dump_config_at_ < this->components_.size()) {
 | 
			
		||||
    if (this->dump_config_at_ == 0) {
 | 
			
		||||
      ESP_LOGI(TAG, "ESPHome version " ESPHOME_VERSION " compiled on %s", this->compilation_time_.c_str());
 | 
			
		||||
      ESP_LOGI(TAG, "ESPHome version " ESPHOME_VERSION " compiled on %s", this->compilation_time_);
 | 
			
		||||
#ifdef ESPHOME_PROJECT_NAME
 | 
			
		||||
      ESP_LOGI(TAG, "Project " ESPHOME_PROJECT_NAME " version " ESPHOME_PROJECT_VERSION);
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ namespace esphome {
 | 
			
		||||
 | 
			
		||||
class Application {
 | 
			
		||||
 public:
 | 
			
		||||
  void pre_setup(const std::string &name, const std::string &friendly_name, const std::string &comment,
 | 
			
		||||
  void pre_setup(const std::string &name, const std::string &friendly_name, const char *comment,
 | 
			
		||||
                 const char *compilation_time, bool name_add_mac_suffix) {
 | 
			
		||||
    arch_init();
 | 
			
		||||
    this->name_add_mac_suffix_ = name_add_mac_suffix;
 | 
			
		||||
@@ -154,11 +154,11 @@ class Application {
 | 
			
		||||
  /// Get the friendly name of this Application set by pre_setup().
 | 
			
		||||
  const std::string &get_friendly_name() const { return this->friendly_name_; }
 | 
			
		||||
  /// Get the comment of this Application set by pre_setup().
 | 
			
		||||
  const std::string &get_comment() const { return this->comment_; }
 | 
			
		||||
  std::string get_comment() const { return this->comment_; }
 | 
			
		||||
 | 
			
		||||
  bool is_name_add_mac_suffix_enabled() const { return this->name_add_mac_suffix_; }
 | 
			
		||||
 | 
			
		||||
  const std::string &get_compilation_time() const { return this->compilation_time_; }
 | 
			
		||||
  std::string get_compilation_time() const { return this->compilation_time_; }
 | 
			
		||||
 | 
			
		||||
  /** Set the target interval with which to run the loop() calls.
 | 
			
		||||
   * If the loop() method takes longer than the target interval, ESPHome won't
 | 
			
		||||
@@ -376,8 +376,8 @@ class Application {
 | 
			
		||||
 | 
			
		||||
  std::string name_;
 | 
			
		||||
  std::string friendly_name_;
 | 
			
		||||
  std::string comment_;
 | 
			
		||||
  std::string compilation_time_;
 | 
			
		||||
  const char *comment_{nullptr};
 | 
			
		||||
  const char *compilation_time_{nullptr};
 | 
			
		||||
  bool name_add_mac_suffix_;
 | 
			
		||||
  uint32_t last_loop_{0};
 | 
			
		||||
  uint32_t loop_interval_{16};
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ import binascii
 | 
			
		||||
import codecs
 | 
			
		||||
import collections
 | 
			
		||||
import functools
 | 
			
		||||
import gzip
 | 
			
		||||
import hashlib
 | 
			
		||||
import hmac
 | 
			
		||||
import json
 | 
			
		||||
@@ -485,6 +486,7 @@ class DownloadBinaryRequestHandler(BaseHandler):
 | 
			
		||||
    @bind_config
 | 
			
		||||
    def get(self, configuration=None):
 | 
			
		||||
        type = self.get_argument("type", "firmware.bin")
 | 
			
		||||
        compressed = self.get_argument("compressed", "0") == "1"
 | 
			
		||||
 | 
			
		||||
        storage_path = ext_storage_path(settings.config_dir, configuration)
 | 
			
		||||
        storage_json = StorageJSON.load(storage_path)
 | 
			
		||||
@@ -534,6 +536,8 @@ class DownloadBinaryRequestHandler(BaseHandler):
 | 
			
		||||
                self.send_error(404)
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
        filename = filename + ".gz" if compressed else filename
 | 
			
		||||
 | 
			
		||||
        self.set_header("Content-Type", "application/octet-stream")
 | 
			
		||||
        self.set_header("Content-Disposition", f'attachment; filename="{filename}"')
 | 
			
		||||
        self.set_header("Cache-Control", "no-cache")
 | 
			
		||||
@@ -543,9 +547,20 @@ class DownloadBinaryRequestHandler(BaseHandler):
 | 
			
		||||
 | 
			
		||||
        with open(path, "rb") as f:
 | 
			
		||||
            while True:
 | 
			
		||||
                data = f.read(16384)
 | 
			
		||||
                # For a 528KB image used as benchmark:
 | 
			
		||||
                #   - using 256KB blocks resulted in the smallest file size.
 | 
			
		||||
                #   - blocks larger than 256KB didn't improve the size of compressed file.
 | 
			
		||||
                #   - blocks smaller than 256KB hindered compression, making the output file larger.
 | 
			
		||||
 | 
			
		||||
                # Read file in blocks of 256KB.
 | 
			
		||||
                data = f.read(256 * 1024)
 | 
			
		||||
 | 
			
		||||
                if not data:
 | 
			
		||||
                    break
 | 
			
		||||
 | 
			
		||||
                if compressed:
 | 
			
		||||
                    data = gzip.compress(data, 9)
 | 
			
		||||
 | 
			
		||||
                self.write(data)
 | 
			
		||||
        self.finish()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ pyserial==3.5
 | 
			
		||||
platformio==6.1.7  # When updating platformio, also update Dockerfile
 | 
			
		||||
esptool==4.6
 | 
			
		||||
click==8.1.3
 | 
			
		||||
esphome-dashboard==20230516.0
 | 
			
		||||
esphome-dashboard==20230621.0
 | 
			
		||||
aioesphomeapi==14.0.0
 | 
			
		||||
zeroconf==0.63.0
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,12 +5,13 @@ set -e
 | 
			
		||||
 | 
			
		||||
cd "$(dirname "$0")/.."
 | 
			
		||||
 | 
			
		||||
if [ ! -n "$DEVCONTAINER" ] && [ ! -n "$VIRTUAL_ENV" ]; then
 | 
			
		||||
if [ ! -n "$DEVCONTAINER" ] && [ ! -n "$VIRTUAL_ENV" ] && [ ! "$ESPHOME_NO_VENV" ]; then
 | 
			
		||||
  python3 -m venv venv
 | 
			
		||||
  source venv/bin/activate
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
pip3 install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt
 | 
			
		||||
pip3 install setuptools wheel
 | 
			
		||||
pip3 install --no-use-pep517 -e .
 | 
			
		||||
 | 
			
		||||
pre-commit install
 | 
			
		||||
 
 | 
			
		||||
@@ -312,7 +312,8 @@ sensor:
 | 
			
		||||
    id: freezer_temp_source
 | 
			
		||||
    reference_voltage: 3.19
 | 
			
		||||
    number: 0
 | 
			
		||||
  - platform: airthings_wave_plus
 | 
			
		||||
  - id: airthingswp
 | 
			
		||||
    platform: airthings_wave_plus
 | 
			
		||||
    ble_client_id: airthings01
 | 
			
		||||
    update_interval: 5min
 | 
			
		||||
    temperature:
 | 
			
		||||
@@ -329,7 +330,8 @@ sensor:
 | 
			
		||||
      name: Wave Plus CO2
 | 
			
		||||
    tvoc:
 | 
			
		||||
      name: Wave Plus VOC
 | 
			
		||||
  - platform: airthings_wave_mini
 | 
			
		||||
  - id: airthingswm
 | 
			
		||||
    platform: airthings_wave_mini
 | 
			
		||||
    ble_client_id: airthingsmini01
 | 
			
		||||
    update_interval: 5min
 | 
			
		||||
    temperature:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user