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

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

And what switch.pv.dlm_button does in your case ?

1 Like

Hi Dick, I hope that I may pick your brain on your routines to charge Your/My Tesla with access PV power. I understand the logic behind your code, but as a newbee I am unsure if I took the right steps and how to "see"what is going on. Could you let me know if I am ontrack or not?

I took each of your code blocks seperately and copy and pasted them via File Editor into a new Yaml file. I changed all variables to reflect my environment. But now I struggle…do I have to start them or do they launch automatically with HA boot sequence? You refer to ON of OFF status pop ups and iOS messages. When would I see those? Do I need to create an overview TAB and link that to your code? Any help would be greatly appreciated. As a background I am with Tibber for the energy and have the Tibber integration up- and running in HA. I use the Tibber sensor.power_production which is the net of production minus usage.

Thanks for this automation. Nicely done. I’m trying it on my Tesla named Noir.
When I plug the Tesla, I get the demand to enable or not Smart Charging. I answer and I see the action automation being received. But for some reason the charging doesn’t start. It seems like my HA doesn’t want to talk to my Tesla. I’m using the Tessie integration and the Tesla one too. (I’m transitioning from the Tesla one to the Tessie one right now). When I do a switch.on service call, I get an error.


This should work right?

By the way, it also doesn’t work when using the Tesla variable switch.noir_charge
(without the r)

Semantically speaking, this should work. This error seems unrelated to the automation. Check your core logging.

Hi Axel, it’s been a while since you posted your question. Did you progress? Your questions seem to be quite basic ones in regard to how automations and iOS callbacks work. I don’t think this kind of automation is for the faint of heart, but I do encourage you to dig deep and get this to work!

As soon as you add or edit an automation, all you have to do is restart the automation through the developer tools menu and they are up and running. The iOS notification callback function is not for beginners, so I’lld encourage you to experiment with this a bit more at first with a simpler automation (for instance with a button and a light, where the button triggers the iOS question “Do you want to turn on the light?” and a yes/no reaction triggers the action. You could start your research here: Introduction | Home Assistant Companion Docs (home-assistant.io)

Good luck, days are getting longer over here so now is as good a time as ever to get this up and running! :wink: Let me know how you’re progressing.

There is indeed errors in the log. I’m quite useless in reading these, I have to admit.
Thanks

Could this be because I’m running both he Tesla and the Tessie integration?

And also this one, longer

Both errors show that the integration isn’t connecting tot the Tesla API. Dit you manage to authenticate correctly? I would strongly advise you to use only one, preferably the (HACS) Tesla Custom Integration. You connect to the Tessie platform using it’s own API, which in turn is connected to the Tesla API. This introduces not only a new ‘point of failure’ but it’s also abstracting/obscuring what’s really happening and hard to debug. First get the Tesla integration working, then make the switch to the Tessie platform.

1 Like

Yeah I figured it out. It was indeed Tessie who needed a second authentication for access to my virtual key apparently. Somehow I missed it. I didn’t try it yet but I’m guessing it’ll work now. Can’t wait til tomorrow morning. :joy::joy:.

As for using the Tesla integration, that’s what I’ve had for a while but it’s not been responding well with a lot of unknown values on my entities.

Apparently Tesla is about to close it up and I read that Tessie is a more sure way to go from now on. That why I’m still using both. I didn’t get to turn the other off and change all my entities names

Thanks for guiding me in the right direction. :pray:t2:

Hi,

I have change the code to suit my sensor. I am using tessie to communicate with my tesla. But I can’t find what to write instead of :
max_charging_amps: “{{ state_attr(‘number.charging_amps’, ‘max’) | int }}”

since I have no number.charging_amps, I presume it’s created from the old tesla integration. But don’t find the equivalent with tessie.

EDIT :
I think that I found it :

max_charging_amps: "{{ state_attr('number.mycarname_courant_de_recharge', 'max') | int }}"

yep, it’s in french :wink:
But now, the Tesla UMC can set 13A max but my power socket can’t handle that much, 8A is the max it can do. So How can I set it up to get only 8A max ? changing like the first post ? Like :

max_charging_amps: 8

I don’t understand why you would speak of the ‘old Tesla integration’, as it is just the direct implementation of Tesla’s API. In sharp contrast to Tessie’s API, which is an API which in turn addresses that exact same Tesla API. Enfin, there’s that. :wink:

Indeed.

Tessie is working fine for me, the other tesla integration return the stat of the car but I can’t interract with the car. As tesla shutdown on january something regarding the wzy to communicate with the car, I was thinking that’s why I can’t use the “old” integration of tesla in Home Assistant.
Perhaps it’s finally just a setting that I miss :sweat_smile:

@dikkertjedap, hi is this nice automation available in blueprint?