Skip to content

Commit a1b33df

Browse files
Merge pull request #68 from ApolloAutomation/beta
Release 26.3.2.1 - New sensors, ESPHome modernisation, and bug fixes
2 parents afe8348 + e4c7f95 commit a1b33df

File tree

4 files changed

+140
-44
lines changed

4 files changed

+140
-44
lines changed

Integrations/ESPHome/Core.yaml

Lines changed: 123 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
substitutions:
22
name: apollo-msr-2
3-
version: "25.8.6.1"
3+
version: "26.3.2.1"
44
device_description: ${name} made by Apollo Automation - version ${version}.
55

66
esp32:
7-
board: esp32-c3-devkitm-1
7+
variant: esp32c3
8+
flash_size: 4MB
89
framework:
910
type: esp-idf
1011

@@ -43,20 +44,24 @@ globals:
4344
restore_value: no
4445
type: bool
4546
initial_value: "false"
47+
- id: ltr390_last_update
48+
restore_value: no
49+
type: uint32_t
50+
initial_value: '0'
4651

4752
# Enable Home Assistant API
48-
# Also Add Buzzer Service Connection
53+
# Also Add Buzzer Action Connection
4954
api:
50-
services:
51-
- service: play_buzzer
55+
actions:
56+
- action: play_buzzer
5257
variables:
5358
song_str: string
5459
then:
5560
- rtttl.play:
5661
rtttl: !lambda 'return song_str;'
5762

58-
#Co2 Calibration Service
59-
- service: calibrate_co2_value
63+
#Co2 Calibration Action
64+
- action: calibrate_co2_value
6065
variables:
6166
co2_ppm: float
6267
then:
@@ -65,7 +70,7 @@ api:
6570
id: scd40
6671

6772
#Setting HLK Password
68-
- service: set_ld2410_bluetooth_password
73+
- action: set_ld2410_bluetooth_password
6974
variables:
7075
password: string
7176
then:
@@ -144,6 +149,21 @@ number:
144149
name: g8 still threshold
145150

146151

152+
- platform: template
153+
name: "DPS310 Pressure Offset"
154+
id: dps310_pressure_offset
155+
disabled_by_default: true
156+
restore_value: true
157+
initial_value: 0.0
158+
min_value: -100.0
159+
max_value: 100.0
160+
entity_category: "CONFIG"
161+
unit_of_measurement: "hPa"
162+
optimistic: true
163+
update_interval: never
164+
step: 0.1
165+
mode: box
166+
147167
- platform: template
148168
name: DPS Temperature Offset
149169
id: dps310_temperature_offset
@@ -157,6 +177,20 @@ number:
157177
update_interval: never
158178
step: 0.1
159179
mode: box
180+
- platform: template
181+
name: LTR390 Update Interval
182+
id: ltr390_update_interval
183+
disabled_by_default: true
184+
restore_value: true
185+
initial_value: 60
186+
min_value: 1
187+
max_value: 300
188+
entity_category: "CONFIG"
189+
unit_of_measurement: "s"
190+
optimistic: true
191+
update_interval: never
192+
step: 1
193+
mode: box
160194
# Setting start of zone 1 occupancy
161195
- platform: template
162196
name: "Radar Zone 1 Start"
@@ -320,6 +354,17 @@ binary_sensor:
320354
id(testScript).execute();
321355
}
322356
357+
- platform: template
358+
name: "Radar Zone Occupancy"
359+
id: "radar_zone_occupancy"
360+
device_class: occupancy
361+
icon: mdi:motion-sensor
362+
lambda: |-
363+
bool zone1 = id(radar_zone_1_occupancy).state;
364+
bool zone2 = id(radar_zone_2_occupancy).state;
365+
bool zone3 = id(radar_zone_3_occupancy).state;
366+
return zone1 || zone2 || zone3;
367+
323368
ld2410:
324369
id: ld2410_radar
325370

@@ -329,17 +374,17 @@ sensor:
329374
id: sys_esp_temperature
330375
filters:
331376
- lambda: |-
332-
static float last_reported_value = 0.0;
377+
static float last_reported_value = -6.0;
333378
float current_value = x;
334379
335380
// Check if the reduce_db_reporting switch is on
336381
if (id(reduce_db_reporting).state) {
337-
// Apply delta filter: only report if the value has changed by 2 or more
382+
// Apply delta filter: only report if the value has changed by 5 or more
338383
if (abs(current_value - last_reported_value) >= 5.0) {
339384
last_reported_value = current_value; // Update the last reported value
340385
return current_value;
341386
} else {
342-
// Return the last reported value without updating if change is less than 2
387+
// Return the last reported value without updating if change is less than 5
343388
return {}; // Discard the update
344389
}
345390
} else {
@@ -376,8 +421,9 @@ sensor:
376421
name: Radar Moving Distance
377422
id: moving_distance
378423
filters:
424+
- throttle_with_priority: 1000ms
379425
- lambda: |-
380-
static float last_reported_value = 0.0;
426+
static float last_reported_value = -6.0;
381427
float current_value = x;
382428
383429
// Check if the radar_has_moving_target sensor is off
@@ -387,12 +433,12 @@ sensor:
387433
388434
// Check if the reduce_db_reporting switch is on
389435
if (id(reduce_db_reporting).state) {
390-
// Apply delta filter: only report if the value has changed by 2 or more
436+
// Apply delta filter: only report if the value has changed by 5 or more
391437
if (abs(current_value - last_reported_value) >= 5.0) {
392438
last_reported_value = current_value; // Update the last reported value
393439
return current_value;
394440
} else {
395-
// Return the last reported value without updating if change is less than 2
441+
// Return the last reported value without updating if change is less than 5
396442
return {}; // Discard the update
397443
}
398444
} else {
@@ -404,8 +450,9 @@ sensor:
404450
name: Radar Still Distance
405451
id: still_distance
406452
filters:
453+
- throttle_with_priority: 1000ms
407454
- lambda: |-
408-
static float last_reported_value = 0.0;
455+
static float last_reported_value = -6.0;
409456
float current_value = x;
410457
411458
// Check if the radar_has_still_target sensor is off
@@ -415,12 +462,12 @@ sensor:
415462
416463
// Check if the reduce_db_reporting switch is on
417464
if (id(reduce_db_reporting).state) {
418-
// Apply delta filter: only report if the value has changed by 2 or more
465+
// Apply delta filter: only report if the value has changed by 5 or more
419466
if (abs(current_value - last_reported_value) >= 5.0) {
420467
last_reported_value = current_value; // Update the last reported value
421468
return current_value;
422469
} else {
423-
// Return the last reported value without updating if change is less than 2
470+
// Return the last reported value without updating if change is less than 5
424471
return {}; // Discard the update
425472
}
426473
} else {
@@ -432,22 +479,25 @@ sensor:
432479
name: Radar Move Energy
433480
id: radar_moving_energy
434481
filters:
482+
- throttle_with_priority: 1000ms
435483
- lambda: |-
436484
if (id(reduce_db_reporting).state) return {};
437485
return x;
438486
still_energy:
439487
name: Radar Still Energy
440488
id: radar_still_energy
441489
filters:
490+
- throttle_with_priority: 1000ms
442491
- lambda: |-
443492
if (id(reduce_db_reporting).state) return {};
444493
return x;
445494
detection_distance:
446495
name: Radar Detection Distance
447496
id: radar_detection_distance
448497
filters:
498+
- throttle_with_priority: 1000ms
449499
- lambda: |-
450-
static float last_reported_value = 0.0;
500+
static float last_reported_value = -6.0;
451501
float current_value = x;
452502
453503
// Check if the radar_has_target sensor is off
@@ -457,12 +507,12 @@ sensor:
457507
458508
// Check if the reduce_db_reporting switch is on
459509
if (id(reduce_db_reporting).state) {
460-
// Apply delta filter: only report if the value has changed by 2 or more
510+
// Apply delta filter: only report if the value has changed by 5 or more
461511
if (abs(current_value - last_reported_value) >= 5.0) {
462512
last_reported_value = current_value; // Update the last reported value
463513
return current_value;
464514
} else {
465-
// Return the last reported value without updating if change is less than 2
515+
// Return the last reported value without updating if change is less than 5
466516
return {}; // Discard the update
467517
}
468518
} else {
@@ -536,22 +586,23 @@ sensor:
536586

537587
- platform: ltr390
538588
id: ltr_390
589+
update_interval: never
539590
light:
540591
name: "LTR390 Light"
541592
id: ltr390light
542593
filters:
543594
- lambda: |-
544-
static float last_reported_value = 0.0;
595+
static float last_reported_value = -21.0;
545596
float current_value = x;
546597
547598
// Check if the reduce_db_reporting switch is on
548599
if (id(reduce_db_reporting).state) {
549-
// Apply delta filter: only report if the value has changed by 2 or more
550-
if (abs(current_value - last_reported_value) >= 20.0) {
600+
// Apply delta filter: only report if the value has changed by 5 or more
601+
if (abs(current_value - last_reported_value) >= 5.0) {
551602
last_reported_value = current_value; // Update the last reported value
552603
return current_value;
553604
} else {
554-
// Return the last reported value without updating if change is less than 2
605+
// Return the last reported value without updating if change is less than 20
555606
return {}; // Discard the update
556607
}
557608
} else {
@@ -564,17 +615,17 @@ sensor:
564615
id: ltr390uvindex
565616
filters:
566617
- lambda: |-
567-
static float last_reported_value = 0.0;
618+
static float last_reported_value = -21.0;
568619
float current_value = x;
569620
570621
// Check if the reduce_db_reporting switch is on
571622
if (id(reduce_db_reporting).state) {
572-
// Apply delta filter: only report if the value has changed by 2 or more
573-
if (abs(current_value - last_reported_value) >= 20.0) {
623+
// Apply delta filter: only report if the value has changed by 1 or more
624+
if (abs(current_value - last_reported_value) >= 1.0) {
574625
last_reported_value = current_value; // Update the last reported value
575626
return current_value;
576627
} else {
577-
// Return the last reported value without updating if change is less than 2
628+
// Return the last reported value without updating if change is less than 20
578629
return {}; // Discard the update
579630
}
580631
} else {
@@ -590,17 +641,21 @@ sensor:
590641
id: dps310pressure
591642
filters:
592643
- lambda: |-
593-
static float last_reported_value = 0.0;
644+
static float last_reported_value = -6.0;
594645
float current_value = x;
646+
float offset = id(dps310_pressure_offset).state;
647+
if (!isnan(offset)) {
648+
current_value += offset;
649+
}
595650
596651
// Check if the reduce_db_reporting switch is on
597652
if (id(reduce_db_reporting).state) {
598-
// Apply delta filter: only report if the value has changed by 2 or more
653+
// Apply delta filter: only report if the value has changed by 5 or more
599654
if (abs(current_value - last_reported_value) >= 5.0) {
600655
last_reported_value = current_value; // Update the last reported value
601656
return current_value;
602657
} else {
603-
// Return the last reported value without updating if change is less than 2
658+
// Return the last reported value without updating if change is less than 5
604659
return {}; // Discard the update
605660
}
606661
} else {
@@ -666,6 +721,28 @@ button:
666721
id: scd40
667722

668723

724+
interval:
725+
- interval: 1s
726+
then:
727+
- lambda: |-
728+
uint32_t current_time = millis() / 1000; // Convert to seconds
729+
uint32_t last_update = id(ltr390_last_update);
730+
float configured_interval = id(ltr390_update_interval).state;
731+
uint32_t interval = (configured_interval >= 1.0f) ? (uint32_t)configured_interval : 60u;
732+
733+
// Immediate update on boot (when last_update is still 0)
734+
if (last_update == 0) {
735+
id(ltr_390).update();
736+
id(ltr390_last_update) = current_time;
737+
return;
738+
}
739+
740+
// Check if enough time has passed
741+
if (current_time - last_update >= interval) {
742+
id(ltr_390).update();
743+
id(ltr390_last_update) = current_time;
744+
}
745+
669746
switch:
670747
- platform: ld2410
671748
bluetooth:
@@ -697,6 +774,21 @@ text_sensor:
697774
version:
698775
name: "Radar Firmware Version"
699776

777+
- platform: wifi_info
778+
ip_address:
779+
name: "IP Address"
780+
id: wifi_ip
781+
entity_category: "diagnostic"
782+
- platform: version
783+
name: "ESPHome Version"
784+
hide_timestamp: true
785+
entity_category: "diagnostic"
786+
- platform: template
787+
name: "Apollo Firmware Version"
788+
id: apollo_firmware_version
789+
update_interval: never
790+
entity_category: "diagnostic"
791+
700792
select:
701793
- platform: ld2410
702794
distance_resolution:

Integrations/ESPHome/MSR-2.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ esphome:
33
friendly_name: Apollo MSR-2
44
comment: Apollo MSR-2
55
name_add_mac_suffix: true
6-
platformio_options:
7-
board_build.flash_mode: dio
8-
96
on_boot:
107
- priority: 900.0
118
then:
129
- lambda: |-
1310
id(radar_bluetooth).turn_off();
11+
- priority: 500
12+
then:
13+
- text_sensor.template.publish:
14+
id: apollo_firmware_version
15+
state: "${version}"
1416
- priority: -10
1517
then:
1618
- if:
@@ -29,6 +31,8 @@ dashboard_import:
2931
package_import_url: github://ApolloAutomation/MSR-2/Integrations/ESPHome/MSR-2.yaml
3032
import_full_config: false
3133

34+
logger:
35+
3236
ota:
3337
- platform: esphome
3438
id: ota_default

0 commit comments

Comments
 (0)