Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 58 additions & 43 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-msr-2
version: "26.7.14.1"
version: "26.10.12.1"
device_description: ${name} made by Apollo Automation - version ${version}.
# Default update channel on first boot (no stored user choice yet, i.e. a
# fresh flash). The beta-channel builds override this to "Beta" (see
Expand All @@ -17,6 +17,12 @@ substitutions:
ota_stable_manifest: "${stable_manifest_base}/firmware/manifest.json"
ota_beta_manifest: "${beta_manifest_base}/manifest-standard.json"

# Bluetooth Proxy switch state on a device with no stored preference yet
# (first boot after this switch was added, or after a factory reset). The
# unified image ships the proxy off; MSR-2_BLE.yaml overrides this to ON so
# legacy BLE devices keep proxying instead of going quiet after an update.
bluetooth_proxy_restore_mode: RESTORE_DEFAULT_OFF

esphome:
# List form so package merging concatenates with each variant's own on_boot
# entries (mapping form would be replaced by the variant's block instead).
Expand All @@ -25,7 +31,7 @@ esphome:
then:
- script.execute: apply_ota_source
# Re-apply the Bluetooth Proxy switch after all components set up, so BLE
# scanning matches the persisted switch (proxy stays off by default).
# scanning matches the switch state restored from flash.
- priority: -300
then:
- if:
Expand Down Expand Up @@ -427,22 +433,24 @@ sensor:
id: sys_esp_temperature
filters:
- lambda: |-
static float last_reported_value = -6.0;
static float last_reported_value = NAN;
static uint32_t last_report_time = 0;
float current_value = x;

// Check if the reduce_db_reporting switch is on
// Reduce DB Reporting: report on a meaningful change, but at least hourly so the sensor never looks frozen
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 5 or more
if (abs(current_value - last_reported_value) >= 5.0) {
last_reported_value = current_value; // Update the last reported value
uint32_t now = millis();
if (isnan(last_reported_value) ||
abs(current_value - last_reported_value) >= 5.0 ||
(now - last_report_time) >= 3600000UL) {
last_reported_value = current_value;
last_report_time = now;
return current_value;
} else {
// Return the last reported value without updating if change is less than 5
return {}; // Discard the update
}
return {}; // Within delta and under the hourly heartbeat -> discard
} else {
// If reduce_db_reporting is off, report the current value normally
last_reported_value = current_value;
last_report_time = millis();
return current_value;
}

Expand Down Expand Up @@ -645,45 +653,49 @@ sensor:
id: ltr390light
filters:
- lambda: |-
static float last_reported_value = -21.0;
static float last_reported_value = NAN;
static uint32_t last_report_time = 0;
float current_value = x;

// Check if the reduce_db_reporting switch is on
// Reduce DB Reporting: report on a meaningful change, but at least hourly so the sensor never looks frozen
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 5 or more
if (abs(current_value - last_reported_value) >= 5.0) {
last_reported_value = current_value; // Update the last reported value
uint32_t now = millis();
if (isnan(last_reported_value) ||
abs(current_value - last_reported_value) >= 5.0 ||
(now - last_report_time) >= 3600000UL) {
last_reported_value = current_value;
last_report_time = now;
return current_value;
} else {
// Return the last reported value without updating if change is less than 20
return {}; // Discard the update
}
return {}; // Within delta and under the hourly heartbeat -> discard
} else {
// If reduce_db_reporting is off, report the current value normally
last_reported_value = current_value;
last_report_time = millis();
return current_value;
}
uv_index:
name: "LTR390 UV Index"
id: ltr390uvindex
filters:
- lambda: |-
static float last_reported_value = -21.0;
static float last_reported_value = NAN;
static uint32_t last_report_time = 0;
float current_value = x;

// Check if the reduce_db_reporting switch is on
// Reduce DB Reporting: report on a meaningful change, but at least hourly so the sensor never looks frozen
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 1 or more
if (abs(current_value - last_reported_value) >= 1.0) {
last_reported_value = current_value; // Update the last reported value
uint32_t now = millis();
if (isnan(last_reported_value) ||
abs(current_value - last_reported_value) >= 1.0 ||
(now - last_report_time) >= 3600000UL) {
last_reported_value = current_value;
last_report_time = now;
return current_value;
} else {
// Return the last reported value without updating if change is less than 20
return {}; // Discard the update
}
return {}; // Within delta and under the hourly heartbeat -> discard
} else {
// If reduce_db_reporting is off, report the current value normally
last_reported_value = current_value;
last_report_time = millis();
return current_value;
}

Expand All @@ -694,34 +706,37 @@ sensor:
id: dps310pressure
filters:
- lambda: |-
static float last_reported_value = -6.0;
static float last_reported_value = NAN;
static uint32_t last_report_time = 0;
float current_value = x;
float offset = id(dps310_pressure_offset).state;
if (!isnan(offset)) {
current_value += offset;
}

// Check if the reduce_db_reporting switch is on
// Reduce DB Reporting: report on a meaningful change, but at least hourly so the sensor never looks frozen.
// Barometric pressure normally drifts only 1-3 hPa a day, so the old 5 hPa delta could freeze the reading for hours.
if (id(reduce_db_reporting).state) {
// Apply delta filter: only report if the value has changed by 5 or more
if (abs(current_value - last_reported_value) >= 5.0) {
last_reported_value = current_value; // Update the last reported value
uint32_t now = millis();
if (isnan(last_reported_value) ||
abs(current_value - last_reported_value) >= 0.5 ||
(now - last_report_time) >= 3600000UL) {
last_reported_value = current_value;
last_report_time = now;
return current_value;
} else {
// Return the last reported value without updating if change is less than 5
return {}; // Discard the update
}
return {}; // Within delta and under the hourly heartbeat -> discard
} else {
// If reduce_db_reporting is off, report the current value normally
last_reported_value = current_value;
last_report_time = millis();
return current_value;
}
temperature:
name: "DPS310 Temperature"
id: dps310temperature
filters:
- lambda: return x - id(dps310_temperature_offset).state;
update_interval: 30s
update_interval: 60s
i2c_id: bus_a


Expand All @@ -733,7 +748,7 @@ light:
default_transition_length: 0s
chipset: WS2812
num_leds: 3
rgb_order: grb
channel_colors: GRB
effects:
- pulse:
name: "Slow Pulse"
Expand Down Expand Up @@ -858,7 +873,7 @@ switch:
id: bluetooth_proxy_switch
icon: mdi:bluetooth
entity_category: "config"
restore_mode: RESTORE_DEFAULT_OFF
restore_mode: ${bluetooth_proxy_restore_mode}
optimistic: true
on_turn_on:
- esp32_ble_tracker.start_scan:
Expand Down Expand Up @@ -918,8 +933,8 @@ script:
then:
- lambda: |-
const bool beta = id(firmware_channel).current_option() == "Beta";
std::string url = beta ? "${ota_beta_manifest}" : "${ota_stable_manifest}";
ESP_LOGI("firmware", "OTA manifest set to: %s", url.c_str());
const char *url = beta ? "${ota_beta_manifest}" : "${ota_stable_manifest}";
ESP_LOGI("firmware", "OTA manifest set to: %s", url);
id(update_http_request).set_source_url(url);
- component.update: update_http_request

Expand Down
2 changes: 1 addition & 1 deletion Integrations/ESPHome/MSR-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ esphome:
name: "ApolloAutomation.MSR-2"
version: "${version}"

min_version: 2025.11.0
min_version: 2026.8.0

dashboard_import:
package_import_url: github://ApolloAutomation/MSR-2/Integrations/ESPHome/MSR-2.yaml
Expand Down
6 changes: 5 additions & 1 deletion Integrations/ESPHome/MSR-2_BLE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ substitutions:
ota_stable_manifest: "https://apolloautomation.github.io/MSR-2/firmware-ble/manifest.json"
ota_beta_manifest: "https://github.com/ApolloAutomation/MSR-2/releases/download/beta-fw/manifest-ble.json"

# Legacy BLE devices proxied unconditionally before the Bluetooth Proxy
# switch existed, so default it on rather than dropping the proxy on update.
bluetooth_proxy_restore_mode: RESTORE_DEFAULT_ON

esphome:
name: "${name}"
friendly_name: Apollo MSR-2
Expand Down Expand Up @@ -30,7 +34,7 @@ esphome:
name: "ApolloAutomation.MSR-2_BLE"
version: "${version}"

min_version: 2025.11.0
min_version: 2026.8.0

logger:

Expand Down
2 changes: 1 addition & 1 deletion Integrations/ESPHome/MSR-2_Factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ esphome:
name: "ApolloAutomation.MSR-2_Factory"
version: "${version}"

min_version: 2025.11.0
min_version: 2026.8.0


dashboard_import:
Expand Down
Loading