Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New picing module for Spanish PVPC model #237

Open
wants to merge 20 commits into
base: pricing_modules
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dfa6109
Add files via upload
ngardiner Jan 21, 2021
7ac3cc2
Bump changelog and screenshot
ngardiner Jan 21, 2021
69903d5
Removed confusing statement from WebUI
ngardiner Jan 24, 2021
216754f
Merge branch 'v1.2.1' of https://github.com/ngardiner/TWCManager into…
ngardiner Jan 24, 2021
5a7c7f2
Provide the ability to override the stored API bearer/refresh tokens …
ngardiner Jan 30, 2021
d9170a3
Update Tesla API authentication to work with oAuth2 flow (no MFA supp…
ngardiner Feb 2, 2021
3ee4dfb
Remove spoofed UA headers from requests (not needed), standardise var…
ngardiner Feb 3, 2021
872cf7e
Black on TeslaAPI.py
MikeBishop Feb 3, 2021
e654722
New feature that allows to limit the max power TWC will take from the…
juanjoqg Feb 3, 2021
0825b6d
Avoid using a hardcode path for the PID file, take the path from conf…
juanjoqg Feb 4, 2021
4e781c0
Rollback to the namespace remove
juanjoqg Feb 4, 2021
5aec8ff
Bug fix in the limit amps from the grid integration with track green …
juanjoqg Feb 12, 2021
8666768
Change to ensure it just limit the amps from the grid when the right …
juanjoqg Feb 13, 2021
3514c10
New menu Graphs, it allows to represent energy graphs base on the SQL…
juanjoqg Feb 17, 2021
32f6d41
Change step on the graphs from seconds to minutes
juanjoqg Feb 18, 2021
6c7921d
New picing module for Spanish PVPC model, i adds a new schedule char…
juanjoqg Feb 20, 2021
8a4ee41
Merge remote-tracking branch 'origin/limit_amps_from_grid' into prici…
juanjoqg Feb 20, 2021
729a0bd
Merge remote-tracking branch 'origin/energy_graphs' into pricing_modules
juanjoqg Feb 20, 2021
4f78ad9
New feature related with the pricing modules that allows to schedule …
juanjoqg Feb 26, 2021
e676a37
New features related to the pricing modules, schedule charging relate…
juanjoqg Feb 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This document logs the changes per release of TWCManager.
* Expose all time properties to the policy module for evaluation (thanks @MikeBishop)
* Impovements to policy page in Web UI to show the value of policy parameters (thanks @MikeBishop)
* Move grace period functionality for vehicles connected prior to policy evaluation to the master module, which opens the door to policy evaluation based on vehicle arrival/VIN (thanks @MikeBishop)
* Split and show the values of Charger Load and Other Load in console output when the Subtract Charger Load setting is enabled (thanks @mikey4321)
* Added EMS module support for SmartMe API
* Bugfixes
* Add a sleep of 5 seconds when waking car up to avoid an infinite loop (thanks @dschuesae)
* Fix a bug with the legacy web interface which causes the Resume Track Green Energy setting of None to fail. Also added a deprecation notice to the web interface to ensure people don't inadvertently use it over the modular interface.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Screenshots
![Screenshot](docs/screenshot.png)
![Screenshot](docs/screenshot2.png)
![Screenshot](docs/screenshot3.png)

## How it works

Expand Down
7 changes: 6 additions & 1 deletion TWCManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"Status.MQTTStatus",
"Pricing.aWATTarPricing",
"Pricing.StaticPricing",
"Pricing.PVPCesPricing",
]

# Enable support for Python Visual Studio Debugger
Expand All @@ -99,6 +100,10 @@
debugLog(1, "Unable to find a configuration file.")
sys.exit()




########################################################################
# All TWCs ship with a random two-byte TWCID. We default to using 0x7777 as our
# fake TWC ID. There is a 1 in 64535 chance that this ID will match each real
# TWC on the network, in which case you should pick a different random id below.
Expand Down Expand Up @@ -242,6 +247,7 @@ def background_tasks_thread(master):
elif task["cmd"] == "saveSettings":
master.saveSettings()


except:
master.debugLog(
1,
Expand Down Expand Up @@ -288,7 +294,6 @@ def check_green_energy():
master.setGeneration(module["name"], module["ref"].getGeneration())
master.setMaxAmpsToDivideAmongSlaves(master.getMaxAmpsToDivideGreenEnergy())


def update_statuses():

# Print a status update if we are on track green energy showing the
Expand Down
12 changes: 12 additions & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ The Do not Charge action states that outside of scheduled or Track Green Energy
* Track Green Energy

This is an option that currently does not operate (and will only set Non-Scheduled Charging rate to 0). In future, this will allow continuing of Track Green Energy behaviour outside of the hard-coded daylight hours (6am - 8pm).

### Manual Tesla API key override

In some instances, you may prefer to obtain the Tesla API keys yourself. The main benefit of this approach is that you do not need to provide your Tesla username or password to TWCManager.

Another reason to use this feature might be as a temporary workaround if the Tesla authentication flow is changed or the TWCManager authentication function is faulty.

Note: Providing your Tesla username and password to TWCManager to automatically fetch your Tesla API access and refresh tokens does not put your credentials at significant risk as they are only used once to fetch the token before being destroyed, however there may nonetheless be a preference not to provide these credentials at all.

To obtain the key, you will need some knowledge of the Tesla API authentication flow. To assist with this, a <a href="http://registration.teslatasks.com/generateTokens">link</a> to a service which can assist you with this process is provided, however this does therefore require you to provide your credentials to that service. Otherwise, you may want to research the Tesla authentication flow and obtain the tokens yourself, or to obtain them from another application that you have previously authenticated to.

Providing any value for the Access or Refresh tokens will result in the current stored tokens being overridden with the value you supply. We don't perform any validation of the tokens and the previous values are lost. Back up your settings.json file prior to entering your token manually if you need to revert your settings.
Binary file added docs/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions etc/twcmanager/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@
# wiringMaxAmpsPerTWC = 50 * 0.8 = 40 and wiringMaxAmpsAllTWCs = 40 + 40 = 80.
"wiringMaxAmpsPerTWC": 6,


# If you what to limit the power drawn from the Grid you need to set this
# maxAmpsAllowedFromGrid and extend the policy you what it to apply, i.e.:
# { "name": "Charge Now with Grid power limit",
# "match": [
# "settings.chargeNowAmps",
# "settings.chargeNowTimeEnd",
# "settings.chargeNowTimeEnd",
# ],
# "condition": ["gt", "gt", "gt"],
# "value": [0, 0, "now"],
# "background_task": "checkMaxPowerFromGrid",
# "charge_amps": "settings.chargeNowAmps",
# "charge_limit": "config.chargeNowLimit"},

# { "name": "Scheduled Charging with Grid power limit",
# "match": [ "checkScheduledCharging()" ],
# "condition": [ "eq" ],
# "value": [ 1 ],
# "background_task": "checkMaxPowerFromGrid",
# "charge_amps": "settings.scheduledAmpsMax",
# "charge_limit": "config.scheduledLimit"},

"maxAmpsAllowedFromGrid": 15,


# https://teslamotorsclub.com/tmc/threads/model-s-gen2-charger-efficiency-testing.78740/#post-1844789
# says you're using 10.85% more power (91.75/82.77=1.1085) charging at 5A vs 40A,
# 2.48% more power at 10A vs 40A, and 1.9% more power at 20A vs 40A. This is
Expand Down Expand Up @@ -258,6 +284,25 @@
#
# They should primarily be used to abort charging when necessary.
"emergency":[
{ "name": "Charge Now with Grid power limit",
"match": [
"settings.chargeNowAmps",
"settings.chargeNowTimeEnd",
"settings.chargeNowTimeEnd",
],
"condition": ["gt", "gt", "gt"],
"value": [0, 0, "now"],
"background_task": "checkMaxPowerFromGrid",
"charge_amps": "settings.chargeNowAmps",
"charge_limit": "config.chargeNowLimit"},

{ "name": "Scheduled Charging with Grid power limit",
"match": [ "checkScheduledCharging()" ],
"condition": [ "eq" ],
"value": [ 1 ],
"background_task": "checkMaxPowerFromGrid",
"charge_amps": "settings.scheduledAmpsMax",
"charge_limit": "config.scheduledLimit"},
],
# Rules in the before section here are evaluated after the Charge Now rule
"before":[
Expand Down Expand Up @@ -423,7 +468,14 @@
"import": 0.20,
"export": 0.09
}
},
"PVPCes": {
# Enable this module if you are a customer under PVPC in Spain
# You need to get a personal token from https://api.esios.ree.es/
"enabled": false,
"token": "xxx"
}

},
"sources":{
# This section is where we configure the various sources that we retrieve our generation and consumption
Expand Down
4 changes: 0 additions & 4 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
// 1 is just the most useful info.
// 10 is all info.
$debugLevel = 0;

// Point $twcScriptDir to the directory containing the TWCManager.py script.
// Interprocess Communication with TWCManager.py will not work if this
// parameter is incorrect.
$twcScriptDir = "/etc/twcmanager";

// End configuration parameters
Expand Down
Loading