Skip to content
Open
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
53 changes: 50 additions & 3 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.3.2.1"
version: "26.6.10.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
Expand Down Expand Up @@ -409,7 +409,7 @@ sensor:
co2:
name: "CO2"
id: "co2"
automatic_self_calibration: false
automatic_self_calibration: true
update_interval: 60s
measurement_mode: "periodic"
i2c_id: bus_a
Expand Down Expand Up @@ -767,6 +767,23 @@ switch:
restore_mode: RESTORE_DEFAULT_OFF
optimistic: true
entity_category: "config"
- platform: template
name: "CO2 Auto Calibration"
id: co2_auto_calibration
icon: mdi:molecule-co2
restore_mode: RESTORE_DEFAULT_ON
optimistic: true
entity_category: "config"
on_turn_on:
then:
- script.execute:
id: setCo2AutoCalibration
enable: true
on_turn_off:
then:
- script.execute:
id: setCo2AutoCalibration
enable: false


text_sensor:
Expand Down Expand Up @@ -798,7 +815,37 @@ select:


script:
- id: testScript
- id: setCo2AutoCalibration
mode: restart
parameters:
enable: bool
then:
#The SCD40 forgets this setting on power loss and the scd4x component
#re-applies the YAML default during setup (~1.5s after boot), so when this
#runs at boot (via the restored switch state) wait for setup to finish first.
- if:
condition:
lambda: "return millis() < 20000;"
then:
- delay: 20s
#The sensor only accepts the ASC command while idle, so stop periodic
#measurement first, then restart it. Same sequence the component uses
#for forced calibration.
- lambda: |-
id(scd40).write_command((uint16_t) 0x3F86); //stop periodic measurement
- delay: 500ms
- lambda: |-
id(scd40).set_automatic_self_calibration(enable);
if (!id(scd40).write_command((uint16_t) 0x2416, (uint16_t) (enable ? 1 : 0))) {
ESP_LOGE("Apollo", "Failed to set CO2 auto calibration");
} else {
ESP_LOGI("Apollo", "CO2 auto calibration %s", enable ? "enabled" : "disabled");
}
- delay: 10ms
- lambda: |-
id(scd40).write_command((uint16_t) 0x21B1); //start periodic measurement

- id: testScript
then:
if:
condition:
Expand Down
Loading