DIY smart grid: EV (Tesla) charging on excess solar power production

@dikkertjedap does your charger run 3 phases or 1 phase. I am just surprised that in you calculation you don’t multiply with 3 eg. V * A * 3. Also i guess if it should be totally right we need to do Power = Voltage (V) x Current (I) x Power Factor (PF) x square root of three if you meter provides the PF.

I use a 1 phase charger. I’m not familiar with the amp settings in a 3-phase situation. As I’m measuring the power surplus/deficit on the grid (so from outside the charger) and the charger power is set according to the actual grid situation, the power factor of the charger (the amount of power that can be transferred for useful work) doesn’t seem too important to me.

1 Like

Thank you, that makes sense.

Could you explain a bit this logic :

{% set charger_power_draw = (states('number.charging_amps') |
int) * grid_voltage %} {% set charging_amps = ((grid_usage +
charger_power_draw) / grid_voltage) | round(0, 'floor') | int %}
{{ [max_charging_amps, charging_amps] | min }}

At this time you already turned the charger on now you need to set the correct charging rate that is not buying from grid but uses excess solar. Maybe you could explain above in some steps what you do.

Allright, let me try to break this down for you:

  1. First step is to determine the power that is drawn by the charger, which is determined by multiplying the number of charging amps by the grid voltage, and set that as the variable charger_power_draw.

  2. Second step is to calculate the new charging amps to set by adding the (positive or negative) grid usage to the charger_power_draw and devide that total by the grid voltage.

The assumption here is that the variable grid_usage only has a positive value when there is solar power production surplus, in any other situation it shows a negative number (power drawn from supplier) or 0.

And why do you need this ? Why not just wait with starting the charger, calculate what you can charge with then start the charger with that ?

That is exactly what this does inside the script (but you’ve taken out this part as an excerpt). And the beauty of it is that this part runs as a loop, where re-calculation is triggered each time the power_grid_usage state changes.

ok something i am missing here, i do understand that the automation get’s triggered on every state change of power_grid_usage but if we take this part here :

- conditions:
          - condition: template
            value_template: "{{ grid_usage > 0 }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.charger
            data: {}
          - service: number.set_value
            target:
              entity_id: number.charging_amps
            data:
              value: >
                {% set charger_power_draw = (states('number.charging_amps') |
                int) * grid_voltage %} {% set charging_amps = ((grid_usage +
                charger_power_draw) / grid_voltage) | round(0, 'floor') | int %}
                {{ [max_charging_amps, charging_amps] | min }}

First time you get here is when there is solar surplus, it starts the charger without any data meaning it starts with whatever amperage it was set before we came here, it could be 16A or it could be 2A. Now the next step is setting the amperage so you calculate how much we consume NOW before we set the new amperage and here is the question i asked earlier. Why not start the charger after you have calculated how much you can charge with so you don’t need to do this extra calculation ?

That is correct and I don’t see any problem with this elegantly simple (and proven to work absolutely flawless) solution. :slight_smile: I wouldn’t want to go through the hassle of all extra calculations when the charge is started (as it recalibrates at every grid state change, about 10 seconds in between) and 99 out of a 100 times the smart charging boolean is set to on, there is already a ‘regular’ charge running when the smart charging is initiated so the charger_power_draw is indeed correct.

@dikkertjedap so i replicated 1:1 what you did as much as i could :

Two things which are different from yours :

  • The only change i have is that my Power Grid Usage sensor is a bit different because i also have a bttery so when SOC is more than 15% i have 2400W that is available that should show as “sollar surplus”.
  • min_charging_amps is changed to be 3 since i have by experience found out that charging with lower than 3 is really bad in terms of efficiency.
Power Grid Usage Template Sensor
power_grid_usage:
      friendly_name: "Power Grid Usage"
      unit_of_measurement: "W"
      value_template: >
        {% set power_consumption_w = states('sensor.total_ac_load')|float %}
        {% set battery_soc = states('sensor.battery_soc') | int%}
        
        {# If battery SOC is above 15% we have extra 2400W we can pull #}
        {% if battery_soc > 15%}
          {% set power_production_w = states('sensor.pv_ac_power_fronius')|float + 2400 %}
        {% else %}
          {% set power_production_w = states('sensor.pv_ac_power_fronius')|float + states('sensor.pv_dc_power')|float %}
        {% endif %}
        
        {% if power_production_w >= 0 and power_consumption_w >= 0 %}
          {{ (power_production_w - power_consumption_w) }}
        {% elif power_production_w >= 0 %}
          {{ power_production_w }}
        {% else %}
          {{ -1 * power_consumption_w }}
        {% endif %}
Tesla Charge on solar power
############# Charge Tesla ########### 
- alias: "Tesla Charge on solar power"
  id: 'charge_tesla'
  description: ""
  trigger:
    - platform: state
      entity_id: sensor.power_grid_usage
  condition:
    - condition: state
      entity_id: binary_sensor.mihai_s_tesla_charger
      state: "on"
    - condition: state
      entity_id: device_tracker.mihai_s_tesla_location_tracker
      state: home
    - condition: state
      entity_id: input_boolean.smart_charge
      state: "on"
  action:
    - variables:
        grid_usage: "{{ states('sensor.power_grid_usage') | float }}"
        max_charging_amps: "{{ state_attr('number.mihai_s_tesla_charging_amps', 'max') | int }}"
        min_charging_amps: 3
        grid_voltage: "{{ states('sensor.grid_voltage_l1') | float }}"
    - choose:
        - conditions:
            - condition: template
              value_template: "{{ grid_usage > 0 }}"
          sequence:        
            - service: number.set_value
              target:
                entity_id: number.mihai_s_tesla_charging_amps
              data:
                value: >
                  {% set charger_power_draw = (states('number.mihai_s_tesla_charging_amps') | int) * grid_voltage * 3 %} 
                  {% set charging_amps = ((grid_usage + charger_power_draw) / grid_voltage / 3) | round(0, 'floor') | int %}
                  {{ [max_charging_amps, charging_amps] | min }}
            - service: switch.turn_on  
              target:
                entity_id: switch.mihai_s_tesla_charger            
        - conditions:
            - condition: template
              value_template: "{{ grid_usage <= 0 }}"
          sequence:
            - service: number.set_value
              target:
                entity_id: number.mihai_s_tesla_charging_amps
              data:
                value: >
                  {% set deficit_watts = -1 * grid_usage %} {% set current_charging_amps = states('number.mihai_s_tesla_charging_amps') | int %}
                  {% set required_charging_amps = ((deficit_watts / grid_voltage) | round(0, 'ceil')) | int %} 
                  {% set updated_charging_amps = current_charging_amps - required_charging_amps %} 
                  {% if updated_charging_amps < min_charging_amps %}
                    0
                  {% else %}
                    {{ [max_charging_amps, updated_charging_amps] | min }}
                  {% endif %}
  mode: single

Now i see few problems in my case and i don’t understand why :

  1. I see that 0A does not stop the charger but the car continues to pull something so maybe this doesn’t work on all Tesla models ? I have a TMY LR from 2022. What do you have ?
  2. Even though i specified minimum 3 for min_charging_amps i still see the amperage is set to 1A or 2A, any ideas what is causing this ? From what i can see your code looks correct. If the amperage calculated is lower than minimum it should set the amperage to 0A.

Define “something”. I have a Tesla MYP 2023.

A bit of a guess since I can’t reproduce, but since every amp goes over three phases, every amp counts for 3 times the amount of voltage in watts. So try multiplying your grid voltage by three in the calculation of required charging amps: (deficit_watts / (grid_voltage * 3))

Something = around 800W and the charger switch does not turn off, does yours turn off when the amperage is set to 0A ?

Spot on! Yes that was a miss from my side, thank you. That would probably solve that problem.

@dikkertjedap how often does your power_grid_usage update in your case ? Mine updates each 1-3sec which i think messes things up so the amperage jumps up and down and really never settles.

Mine updates every 15 seconds. You could add a condition to run the automation only once the previous run is x seconds ago (say 30 seconds) like so:

condition:
  - condition: template
    value_template: >
      {% if state_attr('automation.tesla_charge_on_solar_power', 'last_triggered') %}
        {{ as_timestamp(now()) - as_timestamp(state_attr('automation.tesla_charge_on_solar_power', 'last_triggered')) > 30 }}
      {% else %}
        True
      {% endif %}

Change the interval as you deem most comfortable.

1 Like

Good suggestion, i will try it out to see if it calms things down.

So i have made few changes and added your suggestion so now things are much better. I have added to turn off the charger when the amperage is 0A since it was pulling about 500W which i pressume was just to keep the car electronics running. One more thing which i may also need to is to NOT update the carging amps if the car is not actively charging since this may keep the car awake and not going to sleep and waisting energy for nothing.

Here how it looks now, have not tested it extensively so today i will do that and see if i see issues.

############# Charge Tesla ########### 
- alias: "Tesla Charge on solar power"
  id: 'charge_tesla'
  description: ""
  trigger:
    - platform: state
      entity_id: sensor.power_grid_usage
  condition:
    - condition: state
      entity_id: binary_sensor.mihai_s_tesla_charger
      state: "on"
    - condition: state
      entity_id: device_tracker.mihai_s_tesla_location_tracker
      state: home
    - condition: state
      entity_id: input_boolean.smart_charge
      state: "on"
    - condition: template
      value_template: >
        {% if state_attr('automation.tesla_charge_on_solar_power', 'last_triggered') %}
          {{ as_timestamp(now()) - as_timestamp(state_attr('automation.tesla_charge_on_solar_power', 'last_triggered')) > 15 }}
        {% else %}
          True
        {% endif %}
  action:
    - variables:
        grid_usage: "{{ states('sensor.power_grid_usage') | float }}"
        max_charging_amps: "{{ state_attr('number.mihai_s_tesla_charging_amps', 'max') | int }}"
        min_charging_amps: 3
        grid_voltage: "{{ states('sensor.grid_voltage_l1') | float }}"
    - choose:
        - conditions:
            - condition: template
              value_template: "{{ grid_usage > 0 }}"
          sequence:        
            - service: number.set_value
              target:
                entity_id: number.mihai_s_tesla_charging_amps
              data:
                value: >
                  {% set charger_power_draw = (states('number.mihai_s_tesla_charging_amps') | int) * grid_voltage * 3 %} 
                  {% set charging_amps = ((grid_usage + charger_power_draw) / grid_voltage / 3) | round(0, 'floor') | int %}
                  {{ [max_charging_amps, charging_amps] | min }}
            - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ states('number.mihai_s_tesla_charging_amps') | int == 0 }}"
                sequence:
                  - service: switch.turn_off
                    target:
                      entity_id: switch.mihai_s_tesla_charger 
                    data: {}
              - conditions:
                  - condition: template
                    value_template: "{{ states('number.mihai_s_tesla_charging_amps') | int >= min_charging_amps }}"
                sequence:
                  - service: switch.turn_on
                    target:
                      entity_id: switch.mihai_s_tesla_charger 
                    data: {}            
        - conditions:
            - condition: template
              value_template: "{{ grid_usage <= 0 }}"
          sequence:
            - service: number.set_value
              target:
                entity_id: number.mihai_s_tesla_charging_amps
              data:
                value: >
                  {% set deficit_watts = -1 * grid_usage %} {% set current_charging_amps = states('number.mihai_s_tesla_charging_amps') | int %}
                  {% set required_charging_amps = ((deficit_watts / (grid_voltage * 3)) | round(0, 'ceil')) | int %} 
                  {% set updated_charging_amps = current_charging_amps - required_charging_amps %} 
                  {% if updated_charging_amps < min_charging_amps %}
                    0
                  {% else %}
                    {{ [max_charging_amps, updated_charging_amps] | min }}
                  {% endif %}
            - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ states('number.charging_amps') | int == 0 }}"
                sequence:
                  - service: switch.turn_off
                    target:
                      entity_id: switch.mihai_s_tesla_charger 
                    data: {}
                  
  mode: single

Good, hope this works out for you!

One of the issues discussed in this thread is that continuous switching on and off the charger (which happens especially around the moments there is just about (not) enough solar power) causes the charger to be switched on and off a lot, which might shorten the charger relays’ lifetime. Therefore I’ve created a script solution (see also in this thread) which guards it from switching on and off too soon and too often. Take a look and see if it suits your situation!

I writed this nodered flow (I’ve bought a Model 3 last week) maybe it need a debug :slight_smile: because I’m a newbie :smiley: :

  1. when I start charging My Tesla M3, Nodered Ask me by Telegram if I want to charge Tesla by maximize self PV consumption or a manual charge
  2. if answer is “yes” then a function node calculates unused PV power (Inverter output power + PV power to grid)
  3. So if residual PV power is between a range interval es. 230W-460W a node set 2A tesla sensor “number.charging_amps”
  4. nodered wait until unused PW power is over than 230W or under 230W to repeat cycle and set a smaller or greater Ampere value in sensor “number.charging_amps”
  5. on sunset Nodered turn off the flow, same as Tesla’s Battery is 100% charged
  6. a check on Tesla’s charge = on avoid nodered loop to set Ampere uselessly

[{"id":"cda4cbac66948c9c","type":"tab","label":"Tesla","disabled":false,"info":"","env":[]},{"id":"d4fa434ed53dfa64","type":"telegrambot-switch","z":"cda4cbac66948c9c","name":"Scelta DLM","bot":"7ac1b2eced8b20a3","chatId":"57748018","question":"Vuoi gestire la ricarica dell'auto per massimizzare l'autoconsumo del fotovoltaico?","answers":["si","no"],"outputs":3,"autoAnswerCallback":true,"verticalAnswers":true,"timeoutValue":"1","timeoutUnits":"min","parseMode":"","x":290,"y":120,"wires":[["8a947ab0f9c6cc1b"],["8e2baf6ba25acb32"],["8a947ab0f9c6cc1b"]]},{"id":"7725f19802142a07","type":"trigger-state","z":"cda4cbac66948c9c","name":"Tesla Charge ON","server":"1c37c350.3f926d","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.charger","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":80,"y":80,"wires":[["d4fa434ed53dfa64"],["3fbe5fb8508b6f43"]]},{"id":"22dc7b1664a7da58","type":"api-call-service","z":"cda4cbac66948c9c","name":"Auto","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"telegram_bot","service":"send_message","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"ok avvio la gestione automatica!\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":40,"wires":[["1f84fcfc79acc87e"]]},{"id":"8e2baf6ba25acb32","type":"api-call-service","z":"cda4cbac66948c9c","name":"Manual","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"telegram_bot","service":"send_message","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"La gestione della ricarica proseguirà in modo manuale\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":380,"y":220,"wires":[["3fbe5fb8508b6f43"]]},{"id":"1f84fcfc79acc87e","type":"function","z":"cda4cbac66948c9c","name":"","func":"var power1 = global.get('homeassistant.homeAssistant.states[\"sensor.input_power\"].state');\nvar power2 = global.get('homeassistant.homeAssistant.states[\"sensor.charger_power\"].state');\nvar power3 = global.get('homeassistant.homeAssistant.states[\"sensor.active_power\"].state');\nvar power4 = global.get('homeassistant.homeAssistant.states[\"sensor.pv_to_grid_kwp\"].state');\n\nlet w1 = parseFloat(power1);\nlet w2 = parseFloat(power2);\nlet w3 = parseFloat(power3);\nlet w4 = parseFloat(power4);\n\nmsg.payload = w1 - w3 + w4 + (w2 * 1000) - 300;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":220,"wires":[["1dfa78e36e48e542","410ab08425cbf79b"]]},{"id":"1dfa78e36e48e542","type":"switch","z":"cda4cbac66948c9c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"230","vt":"str"},{"t":"btwn","v":"230","vt":"num","v2":"460","v2t":"num"},{"t":"btwn","v":"461","vt":"num","v2":"691","v2t":"num"},{"t":"btwn","v":"692","vt":"num","v2":"922","v2t":"num"},{"t":"btwn","v":"923","vt":"num","v2":"1153","v2t":"num"},{"t":"btwn","v":"1154","vt":"num","v2":"1384","v2t":"num"},{"t":"btwn","v":"1385","vt":"num","v2":"1615","v2t":"num"},{"t":"btwn","v":"1616","vt":"num","v2":"1846","v2t":"num"},{"t":"btwn","v":"1847","vt":"num","v2":"2077","v2t":"num"},{"t":"btwn","v":"2078","vt":"num","v2":"2308","v2t":"num"},{"t":"btwn","v":"2309","vt":"num","v2":"2539","v2t":"num"},{"t":"btwn","v":"2540","vt":"num","v2":"2770","v2t":"num"},{"t":"btwn","v":"2771","vt":"num","v2":"3001","v2t":"num"},{"t":"btwn","v":"3002","vt":"num","v2":"3232","v2t":"num"},{"t":"btwn","v":"3233","vt":"num","v2":"3463","v2t":"num"},{"t":"btwn","v":"3464","vt":"num","v2":"3694","v2t":"num"},{"t":"btwn","v":"3695","vt":"num","v2":"3925","v2t":"num"},{"t":"btwn","v":"3926","vt":"num","v2":"4156","v2t":"num"},{"t":"btwn","v":"4157","vt":"num","v2":"4387","v2t":"num"},{"t":"btwn","v":"4388","vt":"num","v2":"4618","v2t":"num"},{"t":"btwn","v":"4619","vt":"num","v2":"4849","v2t":"num"},{"t":"gte","v":"4850","vt":"num"}],"checkall":"false","repair":false,"outputs":22,"x":890,"y":260,"wires":[["b2c231128d26b2e1"],["7cec61285af7710c"],["a2022d91a8c24697"],["1ef1e04dba22a52b"],["25111e7925ed9ecc"],["b3f8c5d56d5d6b1c"],["e3fcf7f32ec8cb77"],["6e85ac0f1223a91f"],["5603f6d63da3317c"],["7c23d0da8b04505e"],["778a6599898376f1"],["fea9b4b36d73a950"],["77fbc0857669572d"],["7a5fc827c4cbdfcd"],["43c10d26bb957df3"],["1f90d56ebcd06f3c"],["9545f5a05c5554bb"],["122bd183a1b3b6b8"],["f518695425da67e4"],["9f3adf1edfa017dd"],["f76787dc7f3e551f"],["16927fc2ad18f84d"]]},{"id":"b2c231128d26b2e1","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":1}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":120,"wires":[["09d0a58c1fa54ce0"]]},{"id":"7cec61285af7710c","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":2}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":160,"wires":[["09d0a58c1fa54ce0"]]},{"id":"a2022d91a8c24697","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":3}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":200,"wires":[["09d0a58c1fa54ce0"]]},{"id":"25111e7925ed9ecc","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":5}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":280,"wires":[["09d0a58c1fa54ce0"]]},{"id":"1ef1e04dba22a52b","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":4}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":240,"wires":[["09d0a58c1fa54ce0"]]},{"id":"b3f8c5d56d5d6b1c","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":6}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":320,"wires":[["09d0a58c1fa54ce0"]]},{"id":"e3fcf7f32ec8cb77","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":7}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":360,"wires":[["09d0a58c1fa54ce0"]]},{"id":"6e85ac0f1223a91f","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":8}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":400,"wires":[["09d0a58c1fa54ce0"]]},{"id":"fea9b4b36d73a950","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":12}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":560,"wires":[["09d0a58c1fa54ce0"]]},{"id":"77fbc0857669572d","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":13}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":600,"wires":[["09d0a58c1fa54ce0"]]},{"id":"778a6599898376f1","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":11}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":520,"wires":[["09d0a58c1fa54ce0"]]},{"id":"7c23d0da8b04505e","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":10}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":480,"wires":[["09d0a58c1fa54ce0"]]},{"id":"5603f6d63da3317c","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":9}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":440,"wires":[["09d0a58c1fa54ce0"]]},{"id":"7a5fc827c4cbdfcd","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":14}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":640,"wires":[["09d0a58c1fa54ce0"]]},{"id":"43c10d26bb957df3","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":15}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":680,"wires":[["09d0a58c1fa54ce0"]]},{"id":"9545f5a05c5554bb","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":17}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":760,"wires":[["09d0a58c1fa54ce0"]]},{"id":"1f90d56ebcd06f3c","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":16}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":720,"wires":[["09d0a58c1fa54ce0"]]},{"id":"122bd183a1b3b6b8","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":18}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":800,"wires":[["09d0a58c1fa54ce0"]]},{"id":"f76787dc7f3e551f","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":21}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":920,"wires":[["09d0a58c1fa54ce0"]]},{"id":"9f3adf1edfa017dd","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":20}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":880,"wires":[["09d0a58c1fa54ce0"]]},{"id":"f518695425da67e4","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":19}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":840,"wires":[["09d0a58c1fa54ce0"]]},{"id":"16927fc2ad18f84d","type":"api-call-service","z":"cda4cbac66948c9c","name":"Set Amp Value","server":"1c37c350.3f926d","version":5,"debugenabled":true,"domain":"number","service":"set_value","areaId":[],"deviceId":[],"entityId":["number.charging_amps"],"data":"{\"value\":22}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":960,"wires":[["09d0a58c1fa54ce0"]]},{"id":"b007dee0136dbed1","type":"inject","z":"cda4cbac66948c9c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["1f84fcfc79acc87e"]]},{"id":"410ab08425cbf79b","type":"ha-sensor","z":"cda4cbac66948c9c","name":"PV avaible for Tesla","entityConfig":"ede6040ad88b4bc3","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":690,"y":340,"wires":[[]]},{"id":"09d0a58c1fa54ce0","type":"ha-wait-until","z":"cda4cbac66948c9c","name":"waith power is 1","server":"1c37c350.3f926d","version":2,"outputs":2,"entityId":"sensor.pwleft_for_tesla","entityIdFilterType":"exact","property":"state","comparator":"is","value":"1","valueType":"num","timeout":"150","timeoutType":"num","timeoutUnits":"seconds","checkCurrentState":false,"blockInputOverrides":false,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":1460,"y":480,"wires":[["77a18864989d7823"],["77a18864989d7823"]]},{"id":"77a18864989d7823","type":"api-current-state","z":"cda4cbac66948c9c","name":"check 1 again","server":"1c37c350.3f926d","version":3,"outputs":2,"halt_if":"1","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.pwleft_for_tesla","state_type":"str","blockInputOverrides":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"60","forType":"num","forUnits":"seconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1500,"y":360,"wires":[["a385dcc1806a30a3"],["53c346490c537f93"]]},{"id":"53c346490c537f93","type":"delay","z":"cda4cbac66948c9c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1800,"y":500,"wires":[["77a18864989d7823"]]},{"id":"04a35f51460f31f9","type":"time-range-switch","z":"cda4cbac66948c9c","name":"Set Sun","lat":"38.953554","lon":"16.285832","startTime":"sunrise","endTime":"sunset","startOffset":"0","endOffset":"-30","x":1360,"y":80,"wires":[["1f84fcfc79acc87e"],["8cfa908163bb902b"]]},{"id":"8cfa908163bb902b","type":"api-call-service","z":"cda4cbac66948c9c","name":"Off on Sunset!","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.charger"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1600,"y":80,"wires":[["bca3780193b5c1b3"]]},{"id":"96e908d56d2d7f6a","type":"api-current-state","z":"cda4cbac66948c9c","name":"if on Charger","server":"1c37c350.3f926d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.charger","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1450,"y":180,"wires":[["04a35f51460f31f9"],[]]},{"id":"3fbe5fb8508b6f43","type":"api-call-service","z":"cda4cbac66948c9c","name":"Off DLM Switch","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.pv_dlm_button"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":300,"wires":[[]]},{"id":"8a947ab0f9c6cc1b","type":"api-call-service","z":"cda4cbac66948c9c","name":"On DLM Switch","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.pv_dlm_button"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":540,"y":60,"wires":[["22dc7b1664a7da58"]]},{"id":"1662c9f1eb796f6d","type":"api-current-state","z":"cda4cbac66948c9c","name":"if on DLM Switch","server":"1c37c350.3f926d","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.pv_dlm_button","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1490,"y":260,"wires":[["96e908d56d2d7f6a"],[]]},{"id":"bca3780193b5c1b3","type":"api-call-service","z":"cda4cbac66948c9c","name":"Off DLM Switch","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.pv_dlm_button"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1820,"y":80,"wires":[[]]},{"id":"48c5dd0d1da99315","type":"cronplus","z":"cda4cbac66948c9c","name":"Pool on Sunrise","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"default","payload":"","expressionType":"solar","expression":"0 30 20 * * *","location":"38.95349692898102 16.28588925115764","offset":"15","solarType":"selected","solarEvents":"sunrise"}],"x":120,"y":340,"wires":[["8e764f86a3b8e328"]]},{"id":"8e764f86a3b8e328","type":"api-call-service","z":"cda4cbac66948c9c","name":"Pooling on","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.polling"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":330,"y":400,"wires":[[]]},{"id":"c89cbdf9186dbe41","type":"cronplus","z":"cda4cbac66948c9c","name":"Pool off Sunset","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"default","payload":"","expressionType":"solar","expression":"0 30 20 * * *","location":"38.95349692898102 16.28588925115764","offset":"15","solarType":"selected","solarEvents":"sunset"}],"x":120,"y":440,"wires":[["dca700937fda58dd"]]},{"id":"dca700937fda58dd","type":"api-call-service","z":"cda4cbac66948c9c","name":"Pooling off","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.polling"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":330,"y":500,"wires":[[]]},{"id":"a385dcc1806a30a3","type":"api-current-state","z":"cda4cbac66948c9c","name":"if batt lev < 100%","server":"1c37c350.3f926d","version":3,"outputs":2,"halt_if":"100","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.battery","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1770,"y":360,"wires":[["1662c9f1eb796f6d"],["601c54e86a00ccfc"]]},{"id":"601c54e86a00ccfc","type":"api-call-service","z":"cda4cbac66948c9c","name":"Off DLM Switch","server":"1c37c350.3f926d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.charger"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1860,"y":420,"wires":[[]]},{"id":"7ac1b2eced8b20a3","type":"telegrambot-config","botname":"Casa Lamezia - Home Assistant","usernames":"","chatIds":"57748018","pollInterval":"300"},{"id":"1c37c350.3f926d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"id","deviceSelector":"id","entitySelector":"id","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"ede6040ad88b4bc3","type":"ha-entity-config","server":"1c37c350.3f926d","deviceConfig":"a08c40dd19ee2726","name":"pv 4 tesla","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"pv 4 tesla"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":"power"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"a08c40dd19ee2726","type":"ha-device-config","name":"pv 4 tesla","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}]
1 Like

Hello,

Could you share a screenshot of the charging power historical graph ?

Is the regulation allowing a good follow up of the production curve or in your case good adjustment when you plug or remove the second Tesla?

Gr

Thank you for sharing your great project. I have already adapted it to my home, and it has been working for a few days. However, I am curious about its potential impact on the lifespan of the Tesla battery. I tried consulting both ChatGPT and Bard to seek their input. They both indicated that frequently changing the charging amps could indeed pose a problem for my Tesla. The Tesla charging system is specifically designed to function within a particular range of amps, and constant variations in the amps could place undue stress (or strain) on the system, potentially leading to damage. Considering this information, what are your thoughts on the matter?

Great to hear this works for you!

Considering that home charging max current is about 5% of the fast charging max current, which steps through amps differences far greater than my home charging setup, and even amp difference when the car is in use (amps drawn when discharging) are far greater, I wouldn’t even give it a thought. If you do stumble upon any facts (other than nudging a chatbot into erring on the cautious side), let me know!

2 Likes