Tesla HACS uses the API call for charging.
I have the same basic model. 60 second MPC call. Pass the now PV production as the first element in pv_power_forecast payload.
But I donāt pass a load forecast payload with power_load_no_vars. The system is still using the 2 day history data.
How do you create a load forecast? Are you using the machine learning forecaster?
Must have a look at that sometime. Only keep 10 days of history in the default mysql database. I wonder if itās worth moving to mariadb.
You can extend the history for only certain entities so the current database is more than sufficient.
I am between load forecasters at the moment;
"load_power_forecast": {{
([states('sensor.power_load_no_var_loads')|int] +
states('sensor.hvac_power_forecast') | from_json | map('multiply', 1000) | list
)| tojson
}},
My HVAC was my dominant load over summer so I was just using that as the default and slipping in power_load_no_var_loads as the first element to give me the now value.
jezhall:
You use the tesla intergration? how did you create the calls? since they have changed the web browser to tesla one pro. I have had this question pop up from one of my installs.
I cant seem to find a solution to control the equipment?
I was using the Tesla Custom integration from HACS which provides you direct controls, but that is broken at the moment due to API changes.
I am having great success with the new Teslemetery integration (HACS version has leading features) to provide full control over powerwall.
Lildan
March 28, 2024, 7:01am
2006
@markpurcell I have a similar automation for my Tesla. However the Tesla Wall Charger still indicates the it is using 800w despite setting the car to 0 amps. It goes down to 4w if I stop the car charging. Does your car draw any power from the charger when you set it to 0 amps?
Lildan
March 28, 2024, 7:04am
2007
Iām running Tesla HTTP Proxy to get my Tesla Custom Integration working
# Home Assistant Add-on: Tesla HTTP Proxy
## Prerequisites
You must have a domain name (FQDN) with a valid SSL certificate to host your public key on standard port 443. The vehicle will check this key every time you send a command. The easiest way to do this is using [Nginx SSL proxy add-on](https://github.com/home-assistant/addons/tree/master/nginx_proxy). This guide will use `tesla.example.com` as an example.
Configure Nginx to use extra conf files by putting this into the **Customize** field in that addon config:
```yml
active: true
default: nginx_proxy_default*.conf
servers: nginx_proxy/*.conf
```
## How to use
Configure this addon with your domain name, then hit Start. It will initialize and then stop itself after a few seconds. Refresh the page to verify it stopped, then restart the Nginx addon so it loads the new config. Ignore the error: _Failed to restart add-on_.
> [!IMPORTANT]
> At this point your public key should be visible at `https://tesla.example.com/.well-known/appspecific/com.tesla.3p.public-key.pem`, which is required for Tesla's verification process. If this doesn't work, or if it shows any TLS certificate errors, you must fix that before proceeding further.
This file has been truncated. show original
1 Like
Johan71
March 28, 2024, 7:57am
2009
Ok thanks but now itās like Iām having a hard time knowing how to add it to my code can anyone help me?
####EMHASS######################################################################
publish_data: 'curl -i -H "Content-Type:application/json" -X POST -d ''{}'' http://localhost:5000/action/publish-data'
##
dayahead_optim: 'curl -i -H ''Content-Type: application/json'' -X POST -d ''{
"load_cost_forecast":{{((state_attr(''sensor.nordpool_kwh_se3_sek_3_10_025'', ''raw_today'') | map(attribute=''value'') | list + state_attr(''sensor.nordpool_kwh_se3_sek_3_10_025'', ''raw_tomorrow'') | map(attribute=''value'') | list))[now().hour:][:24] }},
"prod_price_forecast":{{((state_attr(''sensor.nordpool_moms'', ''raw_today'') | map(attribute=''value'') | list + state_attr(''sensor.nordpool_moms'', ''raw_tomorrow'') | map(attribute=''value'') | list))[now().hour:][:24] }},
"prediction_horizon":{{min(24, (((state_attr(''sensor.nordpool_moms'', ''raw_today'')|map(attribute=''value'')|list + state_attr(''sensor.nordpool_moms'', ''raw_tomorrow'') | map(attribute=''value'')| list)[now().hour:][:48]|list|length)))}},
"pv_power_forecast":{{([states(''sensor.solcast_pv_forecast_power_now'')|int(0)] + state_attr(''sensor.solcast_pv_forecast_forecast_today'', ''detailedHourly'')|selectattr(''period_start'',''gt'',utcnow()) | map(attribute=''pv_estimate'')|map(''multiply'',1000)|map(''int'')|list + state_attr(''sensor.solcast_pv_forecast_forecast_tomorrow'', ''detailedHourly'')|selectattr(''period_start'',''gt'',utcnow()) | map(attribute=''pv_estimate'')|map(''multiply'',1000)|map(''int'')|list)| tojson}},
"delta_forecast":2
}'' http://localhost:5000/action/dayahead-optim'
##
mpc: 'curl -i -H ''Content-Type: application/json'' -X POST -d ''{
"load_cost_forecast":{{((state_attr(''sensor.nordpool_kwh_se3_sek_3_10_025'', ''raw_today'') | map(attribute=''value'') | list + state_attr(''sensor.nordpool_kwh_se3_sek_3_10_025'', ''raw_tomorrow'') | map(attribute=''value'') | list))[now().hour:][:24] }},
"prod_price_forecast":{{((state_attr(''sensor.nordpool_moms'', ''raw_today'') | map(attribute=''value'') | list + state_attr(''sensor.nordpool_moms'', ''raw_tomorrow'') | map(attribute=''value'') | list))[now().hour:][:24] }},
"prediction_horizon":{{min(24, (((state_attr(''sensor.nordpool_moms'', ''raw_today'')|map(attribute=''value'')|list + state_attr(''sensor.nordpool_moms'', ''raw_tomorrow'') | map(attribute=''value'')| list)[now().hour:][:48]|list|length)))}},
"pv_power_forecast":{{([states(''sensor.solcast_pv_forecast_power_now'')|int(0)] + state_attr(''sensor.solcast_pv_forecast_forecast_today'', ''detailedHourly'')|selectattr(''period_start'',''gt'',utcnow()) | map(attribute=''pv_estimate'')|map(''multiply'',1000)|map(''int'')|list + state_attr(''sensor.solcast_pv_forecast_forecast_tomorrow'', ''detailedHourly'')|selectattr(''period_start'',''gt'',utcnow()) | map(attribute=''pv_estimate'')|map(''multiply'',1000)|map(''int'')|list)| tojson}},
"delta_forecast":2
}'' http://localhost:5000/action/naive-mpc-optim'
##
forecast_model_fit: curl -i -H "Content-Type:application/json" -X POST -d '{}' http://localhost:5000/action/forecast-model-fit
####END#########################################################################
rcruikshank
(Robert Cruikshank)
March 28, 2024, 8:02am
2010
Ok Tesla HACS
Interesting using HVAC to represent consumption history. If it can be that approximate I might make something up. Perhaps an average of a weeks load no var.
Thanks
Another strategy I have been using is a FIFO buffer of 48 elements that moves one to the left every 30 minutes.
Yes I still see ~ 400 W with the Tesla Wall connector Even if I set 0A, Iām on three phase.
Interestingly with the Universal Wall Connector when I set 0 A it stops drawing power.
It is a challenge as I donāt want to switch the master control on and off continuously.
The Charge on Solar option from Tesla does also stop the power draw, but those endpoints arenāt (yet) controlled by the API. CoS seems to be good for this at the end and start of the day as well as overnight as it prevents the phantom draw.
Johan71:
"delta_forecast":2
You can add it to MPC before delta_forecast
"soc_init": {{ max(0,states('sensor.energy_site_percentage_charged')|int(0))/100 }},
"soc_final": {{ max(100,states('sensor.gateway_battery')|int(0))/100 }},
Replace the sensor entities with your values.
@GeoDerp
Iām not sure if this issue is really fixed. Sometimes I have this error again. Today again:
raise ValueError(
ValueError: Length mismatch: Expected axis has 0 elements, new values have 23 elements
I only have this part in my log. Where can I access the full log?
Johan71
March 28, 2024, 2:37pm
2016
Can someone explain if I have understood this setting correctly? did it mean how fast per in my case a 60 minute session the battery is charged?
battery_target_state_of_charge: 0.2
Lildan
March 29, 2024, 6:06am
2017
Thanks Mark.
Iāve updated my EV charging deferrable automation to turn off charging when its 0w and to turn it back on when its >0w (in addition to setting the charging amps)
1 Like
I understand the line with the value for soc_init, but what does soc_final contain for you, or what is in the entity āsensor.gateway_batteryāā?
bvm
(bvm)
March 29, 2024, 9:51pm
2019
Hello,
I am recently having issues while running the rest command automation.
I am having this configuration regarding rest_command for day ahead optimization:
dayahead_optim_rest:
url: http://localhost:5000/action/dayahead-optim
method: POST
content_type: "application/json"
payload: >-
{
"prediction_horizon": {{
min(48, state_attr('sensor.entsoe_prices_forecast_30', 'prices')|length |int) | tojson
}},
"pv_power_forecast": {{
(state_attr('sensor.solcast_pv_forecast_forecast_today', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list +
state_attr('sensor.solcast_pv_forecast_forecast_tomorrow', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list
)| tojson
}},
"load_cost_forecast": {{
state_attr('sensor.entsoe_prices_forecast_30', 'prices') |tojson
}},
"num_def_loads": 1,
"def_total_hours": [4],
"P_deferrable_nom": [2500],
"treat_def_as_semi_cont": [0],
"set_def_constant": [1]
}
Running the curl command manually in terminal works fine.
But running in automation mode , I see following entry in log file:
2024-03-29 22:44:10.342 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: Timeout when calling resource 'http://localhost:5000/action/dayahead-optim'
Any pointers anyone?
Thank you!
That is the value you want the battery at the end of the optimisation, ie the end of the 24 hours.
Do some experimentation, I have played around with setting it to zero, so the battery is planned on being fully discharged, or the same as the init value. Currently Iām using 100 % so the plan is always to have a full battery in 24 hours.
Copy the rest command into the developer tools template to see what it is being expanded to.
110hs
(110hs)
March 30, 2024, 8:34am
2022
Hello, just a heads-up to the community there may still be a bug with the time change; check your log.
Iāve already reported it on github.
Johan71
March 30, 2024, 11:46am
2023
Can someone explain if I have understood this setting correctly? did it mean how fast per in my case a 60 minute session the battery is charged?
battery_target_state_of_charge: 0.2
Donāt know if itās allowed in the forum but I bump my question
110hs
(110hs)
March 30, 2024, 12:40pm
2024
This is the desired status of charge of your battery at the end of the horizon (typically 24 h) you are optimizing.