Hi all,
A bit of a newbie here, although I’ve been playing around with stuff for a few months now. I’m trying to create an automation that switches the socket of the car charger to on when we’re getting cheap power (either due to time based tariffs or due to our solar panels sending most of the energy back onto the grid). The code I have is the following:
alias: Charge car
description: "Charge the car only when it is cheap for us"
trigger:
- platform: time_pattern
minutes: /15
condition: []
action:
- if:
- condition: or
conditions:
- type: is_power
condition: device
device_id: de55a9e4519fcabc29348768ebb78143
entity_id: 64320c8b65628662bbd5b0e5a66e0da2
domain: sensor
above: 1500
- condition: state
entity_id: sensor.p1_meter_3c39e7252b62_active_tariff
state: "1"
- condition: and
conditions:
- type: is_power
condition: device
device_id: b5a91b0169b98067880cf0335555df9e
entity_id: 35ca72049528c6c9e5bc5bd6e1551dfe
domain: sensor
above: 2000
- type: is_power
condition: device
device_id: de55a9e4519fcabc29348768ebb78143
entity_id: 64320c8b65628662bbd5b0e5a66e0da2
domain: sensor
below: 500
then:
- type: turn_on
device_id: b5a91b0169b98067880cf0335555df9e
entity_id: 593bca0270120e853e9290bdb5a00782
domain: switch
else:
- type: turn_off
device_id: b5a91b0169b98067880cf0335555df9e
entity_id: 593bca0270120e853e9290bdb5a00782
domain: switch
mode: single
I’d like to make two improvements, but having trouble to make it work, hopefully someone can help me:
-
I added an Input button that would be pressed when we want to charge the car no matter of the costs. Basically, I’d like to check if the button was pressed within the last 12 hours, but I have no idea where to start that condition.
-
Currently, I’m checking the actual latest power usage ever 15 minutes, but it would probably make sense to check the average usage over the last 15 minutes. I’m guessing I should make a Helper for that? Should I create a Helper for each of the measurements I’m using (P1 Power, Charger Socket Power) or is there some generic thing I should be using instead?
Thanks for any guidance you can provide! Also, is there some sort of tutorial that does some useful stuff from the get-go with HA scripting/automating that guides a newbie through some of the basics?