@
Fremske misschien heb je ook wat aan mijn variant, al is het wel een brei aan code
Toevallig heb ik afgelopen weekend mijn
Node-RED-flow voor vraaggestuurde ventilatie met pensioen gestuurd en iets soortgelijks in HA gebouwd. YAML en HA snap ik best goed, maar van templates heb ik weinig kaas gegeten. Daarom heb ik onderstaande met chat-gpt gemaakt, waardoor het er waarschij
nlijk veel minder mooi is dan als het vanaf 0 gemaakt zou zijn door iemand die precies weet wat hij doet. Maar het werkt wel:
YAML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| alias: Ventilatie auto en manual
triggers:
- entity_id:
- input_boolean.ventilatie_automatisch
- sensor.badkamer_humidity
- sensor.particulate_matter_2_5mm_concentration
- sensor.co2_huiskamer_2
- sensor.co2_kantoor32_co2_kantoor
- sensor.mh_z19_co2_value_3
- input_number.ventilatie_handmatig_percentage
trigger: state
conditions:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.badkamer_humidity
above: 80
- condition: numeric_state
entity_id: sensor.particulate_matter_2_5mm_concentration
above: 10
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.co2_huiskamer_2
above: 400
- condition: numeric_state
entity_id: sensor.co2_kantoor32_co2_kantoor
above: 400
- condition: numeric_state
entity_id: sensor.mh_z19_co2_value_3
above: 400
actions:
- data:
topic: ESP_mechanischeventilatie/cmd
qos: 0
retain: false
payload: |-
{% if is_state('input_boolean.ventilatie_automatisch', 'off') %}
PWM,14,{{ (states('input_number.ventilatie_handmatig_percentage') | int * 1023 / 100) | int }},0,1500
{% else %}
{% set co2_values = [ states('sensor.co2_huiskamer_2'),
states('sensor.co2_kantoor32_co2_kantoor'),
states('sensor.mh_z19_co2_value_3') ] %}
{% set valid_co2_values = co2_values | select('is_number') | map('int') | list %}
{% set max_co2 = valid_co2_values | max if valid_co2_values | length > 0 else 0 %}
{% set humidity = states('sensor.badkamer_humidity') | int %}
{% set particulate = states('sensor.particulate_matter_2_5mm_concentration') | float %}
{% if humidity > 80 or particulate > 10 or max_co2 > 400 %}
{% set pwm_value = ((max_co2 - 450) / (1300 - 450) * 1023) | int %}
{% if pwm_value > 1023 %}
PWM,14,1023,0,1500
{% elif pwm_value < 0 %}
PWM,14,0,0,1500
{% else %}
PWM,14,{{ pwm_value }},0,1500
{% endif %}
{% else %}
PWM,14,0,0,1500
{% endif %}
{% endif %}
action: mqtt.publish
- data:
entity_id: input_number.ventilatie_handmatig_percentage
value: |-
{% if is_state('input_boolean.ventilatie_automatisch', 'on') %}
{% set co2_values = [ states('sensor.co2_huiskamer_2'),
states('sensor.co2_kantoor32_co2_kantoor'),
states('sensor.mh_z19_co2_value_3') ] %}
{% set valid_co2_values = co2_values | select('is_number') | map('int') | list %}
{% set max_co2 = valid_co2_values | max if valid_co2_values | length > 0 else 0 %}
{% set humidity = states('sensor.badkamer_humidity') | int %}
{% set particulate = states('sensor.particulate_matter_2_5mm_concentration') | float %}
{% if humidity > 80 or particulate > 10 or max_co2 > 400 %}
{% set pwm_value = ((max_co2 - 450) / (1300 - 450) * 1023) | int %}
{% if pwm_value > 1023 %}
100
{% elif pwm_value < 0 %}
0
{% else %}
{{ (pwm_value / 1023 * 100) | int }}
{% endif %}
{% else %}
0
{% endif %}
{% else %}
{{ ((states('input_number.ventilatie_handmatig_percentage') | int * 1023 / 100) / 1023 * 100) | int }}
{% endif %}
action: input_number.set_value
mode: single |
Toelichting: ik heb 3 CO
2-sensoren, 1 fijnstofsensor (keuken) en 1 luchtvochtigheidssensor.
De mechanische ventilatie stuur ik traploos (nouja, in 1024 stappen

) aan met een PWM->0-10V module.
Dat is dit stukje dat je ziet:
YAML:
1
| PWM,14,{{ pwm_value }},0,1500 |
Hierbij krijgt een esp-bordje het commando om op pin 14 een PWM-signaal uit te sturen. Dit signaal heeft een waarde van 0 (0V) tot 1023 (10V).
Als de luchtvochtigheid in de badkamer >80% is of fijnstof in de keuken >10ppm, dan gaat de mechanische ventilatie op 100%.
Is bovenstaande niet het geval, dan wordt gekeken naar de hoogste CO
2-waarde: bij 1300ppm gaat de mechanische ventilatie op 100%, bij 400ppm op 0% (al draait de mv dan nog steeds wel door de ingebouwde stand 1) en alle waardes ertussen worden traploos bepaald. Bij 850ppm draait de MV bijvoorbeeld op 50%.
Daarnaast heb ik nog een schakelaar waarmee ik kan bepalen of de MV automatisch aangestuurd wordt of handmatig. In de automatische stand laat de schuif zien op welke snelheid de MV nu wordt aangestuurd. Op de handmatige stand kan ik met de schuif juist bepalen hoe hard ik de MV wil laten draaien:
Canon EOS 5Dm3 + 5D + 7D + 300D + 1000FN + EF 17-40 4L + EF 35 1.4L + EF 50 1.8 + EF 80-200 2.8L + 550EX