Thank you all. You guys help me to starting up with it. I don’t get it worked so you describe it but It works.
For te people who’ve intrested.
automation on:
alias: Regenschakelaar aan
description: ''
trigger:
- platform: time_pattern
seconds: /5
condition:
- condition: template
value_template: >-
{{ (((states('sensor.rain_sensor') | float -
states('sensor.regen_history') | float) / -2)) > 0 }}
action:
- scene: scene.regenschakelaar_aan
mode: single
Automation off
alias: Regenschakelaar uit
description: ''
trigger:
- platform: time_pattern
seconds: /5
condition:
- condition: state
entity_id: input_boolean.regen
state: 'on'
- condition: template
value_template: >-
{{ (((states('sensor.rain_sensor') | float -
states('sensor.regen_history') | float) / 5)) > 0 }}
action:
- scene: scene.regenschakelaar_uit
mode: single
extra configuration setting:
#sensor om de huidige waarde mee te vergelijken
- platform: sql
queries:
- name: regen history
query: "SELECT * FROM states WHERE entity_id = 'sensor.rain_sensor' ORDER BY state_id DESC LIMIT 1;"
column: "state"