From 65a13fe13eb4f682d8a2c0b95df04916882b42c5 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan@faked.org>
Date: Fri, 11 Nov 2022 09:49:06 +0100
Subject: [PATCH] SCD40: add calibration/reset button Fan: use PWM Triac

---
 packages/fan.yaml   | 15 ++++++++++++++-
 packages/scd40.yaml | 17 ++++++++++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/packages/fan.yaml b/packages/fan.yaml
index dbbef7d..a8195b2 100644
--- a/packages/fan.yaml
+++ b/packages/fan.yaml
@@ -1,3 +1,17 @@
+output:
+  - platform: ledc
+    pin: GPIO13
+    id: fan_dimmer
+    frequency: 223Hz
+    min_power: 0.36
+    max_power: 0.78
+    zero_means_zero: true
+
+fan:
+  - platform: speed
+    output: fan_dimmer
+    name: "Extraction Fan"
+
 prometheus:
   relabel:
     propbox_fan:
@@ -89,7 +103,6 @@ interval:
     then:
       - script.execute: fan_state
 
-
 script:
   - id: fan_control
     then:
diff --git a/packages/scd40.yaml b/packages/scd40.yaml
index f8959ee..56e5baa 100644
--- a/packages/scd40.yaml
+++ b/packages/scd40.yaml
@@ -1,7 +1,8 @@
 sensor:
 - platform: scd4x
+  id: scd40
   update_interval: 5s
-  temperature_offset: 5.35
+  temperature_offset: 5.8
   ambient_pressure_compensation_source: bme280_pressure
   co2:
     id: scd40_co2
@@ -24,3 +25,17 @@ prometheus:
     scd40_humidity:
       id: humidity_co2
       name: "Humidity (CO2)"
+
+button:
+  - platform: template
+    name: "CO2: Calibration to 419 ppm"
+    on_press:
+      then:
+        - scd4x.perform_forced_calibration:
+            value: 419  # outside average April 2022
+            id: scd40
+  - platform: template
+    name: "CO2: Factory Reset"
+    on_press:
+      then:
+        - scd4x.factory_reset: scd40
-- 
GitLab