Het is me opgevallen dat de Zonneplan integratie 1 x per 5 minuten data ophaalt van een server waar de data 1 x per 5 minuten wordt ververst. De data op de server wordt elke paar seconden na de hele 5 minuten ververst. Als je toevallig net Home Assistant heb herstart om 19:09 loopt je data steeds 4 minuten achter.
Ik heb nu een automatsering gemaakt om de integratie na een herstart van HA en 2 keer per dag op een vaste tijd te herladen 40 seconden na de hele 5 minuten.
code:
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
| alias: Zonneplan herlaad integratie
description: ""
trigger:
- platform: time_pattern
minutes: "0"
seconds: "40"
- platform: time_pattern
minutes: "5"
seconds: "40"
id: "5"
- platform: time_pattern
minutes: "10"
seconds: "40"
- platform: time_pattern
minutes: "15"
seconds: "40"
- platform: time_pattern
minutes: "20"
seconds: "40"
- platform: time_pattern
minutes: "25"
seconds: "40"
- platform: time_pattern
minutes: "30"
seconds: "40"
- platform: time_pattern
minutes: "35"
seconds: "40"
- platform: time_pattern
minutes: "40"
seconds: "40"
- platform: time_pattern
minutes: "45"
seconds: "40"
- platform: time_pattern
minutes: "50"
seconds: "40"
- platform: time_pattern
minutes: "55"
seconds: "40"
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: time
after: "00:00:00"
before: "01:00:00"
- condition: trigger
id:
- "5"
- condition: and
conditions:
- condition: time
after: "12:00:00"
before: "13:00:00"
- condition: trigger
id:
- "5"
- condition: template
value_template: >-
{% set last_update = (as_timestamp(now()) -
as_timestamp(states.sensor.uptime.state)) %}
{% if last_update < 340%}True
{% else %}False
{% endif %}
enabled: true
action:
- action: homeassistant.reload_config_entry
metadata: {}
data: {}
target:
entity_id: sensor.thuisbatterij_last_measured
mode: single |
Ik hoop dat Fsaris een wijziging kan doen in de integratie waardoor deze automatisering niet meer nodig is. De automatsering is misschien een beetje omslachtig, maar weet niet hoe ik m eenvoudiger kon maken. Misschien als het verschil tussen de waarde van de sensor last_update en het moment waarop die ververst is groter is dan 5 minuten? Zoiets:
code:
1
2
3
4
| {% set last_update = (as_timestamp(states.sensor.thuisbatterij_last_measured.state)) - (as_timestamp(states.sensor.thuisbatterij_last_measured.last_changed)) %}
{% if last_update > 1 %}off
{% else %}on
{% endif %} |
[
Voor 18% gewijzigd door
Dominic-070 op 21-09-2024 21:17
]