Thanks for sharing @matfroh .
I’ll do mine - I’m sure it’s useful for the not-so-advanced HA-user. Although, like you, I’m not fully there yet.
I’m using the (cloud based and thus 15 min delayed) Solar Edge values to calculate my Tesla charging amps (can’t do the modbus thing, according to SolarEdge documentation).
Start charging based on P1 value, stop charging based on (almost) no more sun. Still a work in progress, but it’s working quite well already (for my requirements and skills).
All this is based on what’s been said in this thread, so many thanks for that, everyone!
Next up: using the P1 value for calculation, but I’m having a bit of trouble combining the code with the math (plus time to look for it a bit more).
To be clear; I keep KISS high & mighty (I don’t want to copy paste large chunks of python code I don’t understand fully). These are all automations and 1 simple script (mentioned above).
Start Charging based on P1 excess
alias: Tesla - Start laden bij zon over en onder 90
description: ''
trigger:
- platform: numeric_state
below: '-300'
for:
hours: 0
minutes: 3
seconds: 0
entity_id: sensor.p1_meter_3c39e724c5a2_active_power
condition:
- condition: state
entity_id: device_tracker.dikke_baby_location_tracker
state: home
- condition: state
entity_id: binary_sensor.dikke_baby_charger_sensor
state: 'on'
- condition: state
entity_id: switch.dikke_baby_charger_switch
state: 'off'
- condition: numeric_state
entity_id: sensor.dikke_baby_battery_sensor
below: '90'
action:
- service: notify.notify
data:
message: Tesla begint te laden (veel zon over)
title: Tesla automatisch laden!
- service: switch.turn_on
target:
entity_id: switch.dikke_baby_charger_switch
data: {}
- service: script.tesla_laadsnelheid_test
data: {}
mode: single
Calculate input_number based on SolardEdge generated power, every 15 minutes
alias: Tesla - Update Tesla Charge Amperage (input number)
description: ''
trigger:
- platform: time_pattern
minutes: /15
condition:
- type: is_on
condition: device
device_id: d8b42c4c8cf5d20b8f9571f7dd28cbe1
entity_id: binary_sensor.dikke_baby_charger_sensor
domain: binary_sensor
- condition: state
state: home
entity_id: device_tracker.dikke_baby_location_tracker
- condition: state
entity_id: switch.dikke_baby_charger_switch
state: 'on'
- condition: state
entity_id: input_boolean.tesladynamiccharging
state: 'on'
action:
- service: input_number.set_value
data:
value: >
{{ (states('sensor.solaredge_current_power') | float / 600) | round(0)
}}
target:
entity_id: input_number.tesla_current
- service: notify.notify
data:
message: Input number update "{{ states('input_number.tesla_current') }}"
title: Tesla
- service: script.tesla_laadsnelheid_test
data: {}
mode: single
Stop Charging based on “no more sun”
alias: Tesla - Stop laden bij geen zon meer
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.solaredge_current_power
below: '500'
for:
hours: 0
minutes: 5
seconds: 0
condition:
- condition: state
entity_id: binary_sensor.dikke_baby_charger_sensor
state: 'on'
- condition: state
entity_id: device_tracker.dikke_baby_location_tracker
state: home
- condition: state
entity_id: switch.dikke_baby_charger_switch
state: 'on'
- condition: state
entity_id: input_boolean.teslaoverruleautostop
state: 'off'
- condition: numeric_state
entity_id: sensor.dikke_baby_battery_sensor
above: input_number.tesla_min_charge
action:
- service: notify.notify
data:
message: Tesla gestopt met laden (zon weg)!
title: Tesla
- service: switch.turn_off
data: {}
target:
device_id: d8b42c4c8cf5d20b8f9571f7dd28cbe1
- type: turn_off
device_id: d8b42c4c8cf5d20b8f9571f7dd28cbe1
entity_id: switch.dikke_baby_charger_switch
domain: switch
mode: single
Script
alias: Tesla Adust Charging Amps
sequence:
- service: tesla_custom.api
data:
command: CHARGING_AMPS
parameters:
path_vars:
vehicle_id: '{{ state_attr(''binary_sensor.dikke_baby_online_sensor'', ''id'') }}'
charging_amps: '{{ states(''input_number.tesla_current'')|int }}'
mode: single
icon: mdi:battery-charging-20
What I’m working on to replace the solaredge calculated Amp value, but renders minus values, for now
alias: Tesla - TEST - Update Tesla Min Charge (P1 calc)
description: ''
trigger:
- platform: time_pattern
hours: /1
condition:
- type: is_on
condition: device
device_id: d8b42c4c8cf5d20b8f9571f7dd28cbe1
entity_id: binary_sensor.dikke_baby_charger_sensor
domain: binary_sensor
- condition: state
state: home
entity_id: device_tracker.dikke_baby_location_tracker
- condition: state
entity_id: switch.dikke_baby_charger_switch
state: 'on'
- condition: state
entity_id: input_boolean.tesladynamiccharging
state: 'on'
action:
- service: input_number.set_value
data:
value: >-
{{ (states('input_number.tesla_current_test') | float) -
((states('sensor.p1_meter_3c39e724c5a2_active_power') | float / 500) |
round(0))}}
target:
entity_id: input_number.tesla_current_test
- service: notify.notify
data:
message: >-
Tesla - TEST P1-calculated "{{ states('input_number.tesla_current_test')
}}"
title: Tesla
mode: single
I’m pretty sure surrounding the code above by an “IF” ( calculation < 0, then GO, ELSE Charging Amps = 0) is a dirty solution, and that’s what I’m going for, for now.
I’m using a few helpers
And I also have a few other automations which I won’t share because of the fact they’re not relevant here (stop charging when plugged in, stop charging when no sun and < minimum charge,…)