-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: rewrite to add support for energy sites (#250)
Added support for Tesla energy sites and updates to cars. - Move car specific code out of `TeslaBaseEntity` to a newly created `TeslaCarEntity`. - New `TeslaEnergyEntity` class which also inherits from `TeslaBaseEntity`. - New `TeslaEnergyPowerSensor` class used for creating power sensors (solar, grid, load and battery). - New `TeslaEnergyBattery` class for Powerwall battery percentage sensor. - New `TeslaEnergyBatteryRemaining` class for Powerewall battery Watt hour remaining sensor. - New `TeslaEnergyBackupReserve` class for Powerwall backup reserve percentage setting sensor. - New `TeslaEnergyBatteryCharging` class for Powerwall battery charging binary sensor. - New `TeslaEnergyGridStatus` class for Powerwall grid status binary sensor. - New `TeslaEnergyGridCharging` class for Powerwall grid charging select. - New `TeslaEnergyExportRule` class for Powerwall export rule select. - New `TeslaEnergyOperationMode` class for Powerwall operation mode select. - New `TeslaCarChargerPower` class for car charger power (kW). - Updated properties and method calls to teslajsonpy to reflect the changes made to teslajsonpy. - Added additional checks to only add entities for what a car actually has (seat heaters, heated steering wheel, HomeLink, etc.) - Updated naming to align with [current](https://developers.home-assistant.io/docs/core/entity#entity-naming) Home Assistant convention. - Changed unique IDs to use VIN + entity type for vehicles. - Update class naming to `TeslaCar*` and `TeslaEnergy*` for all vehicle and energy site related classes respectively. - Renamed `TeslaCarMileage` to `TeslaCarOdometer`. - `TeslaCarParkingBrake` will indicate "On" when the car is on and in "Park" but also when the car is off (parking brake still engaged). - Updated icons to better reflect entities purpose. - Added a check to the car energy added sensor to report 0 unless the car is charging, then report the actual charge energy added. This is due to the Tesla API reporting a decreasing value over time when not charging causing issues with the HA sensor state class "TOTAL_INCREASING". - Removed extra state attributes that are already a separate entity (charge energy added, charge current request). - Moved charger actual current, charger voltage and charger power extra state attributes from the charging rate to energy added entity. - Updated `TeslaCarChargerConnection` device class to `PLUG`. - Removed unused `helpers.py`. - Cast vehicle ID and ID to a string in `TeslaCarOnline` extra state attributes to prevent HA from automatically formatting with commas. - Check users HA unit system locale settings for determining to return miles vs kilometers. - Vehicles will be forced to wake up the first time the integration is set up. For subsequent integration or HA restarts, vehicles will not be forced to wake up unless enabled in the configuration options (defaults to off). - Added two new options, "Include Vehicles" and "Include Energy Sites" to the setup config flow. These will allow a user to include/exclude vehicles or energy sites. Defaults selected. - Updated doc strings. - Updated and added tests to cover changes. - closes #79 - closes #93 - closes #101 - closes #173 - closes #204 - closes #222 - closes #226 - closes #271 BREAKING CHANGE: This is a rewrite. Multiple entitiy_ids were changed. It is recommended you remove and reinstall. Changed trunk, frunk and charger door from lock to cover entities. Created separate sensor (`TeslaCarChargerPower` class) for charger power. Moved charger amps, charger volts and charger phases extra state attributes to the new charger power sensor. Moved added range extra state attributes to the charger energy added sensor.
- Loading branch information
Showing
52 changed files
with
4,601 additions
and
2,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
source /opt/container/helpers/common/paths.sh | ||
mkdir -p /config | ||
|
||
# Required to get automations to work | ||
echo "Creating automations.yaml" | ||
touch /config/automations.yaml | ||
|
||
# source: /opt/container/helpers/commons/homeassistant/start.sh | ||
if test -d "custom_components"; then | ||
echo "Symlink the custom component directory" | ||
|
||
if test -d "custom_components"; then | ||
rm -R /config/custom_components | ||
fi | ||
|
||
ln -sf "$(workspacePath)custom_components/" /config/custom_components || echo "Could not copy the custom_component" exit 1 | ||
elif test -f "__init__.py"; then | ||
echo "Having the component in the root is currently not supported" | ||
fi | ||
|
||
# Install | ||
echo "Install home assistant" | ||
container install | ||
|
||
# Setup the Dev Stuff | ||
|
||
pip install poetry | ||
# We're in Docker, so we don't need a VENV | ||
poetry config virtualenvs.create false | ||
poetry install --no-interaction | ||
|
||
# Keep this inline with any requirements that are in manifest.json | ||
pip install git+https://github.com/zabuldon/teslajsonpy.git@dev#teslajsonpy==2.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
// Example of attaching to local debug server | ||
"name": "Python: Attach Local", | ||
"type": "python", | ||
"request": "attach", | ||
"port": 5678, | ||
"justMyCode": false, | ||
"host": "localhost", | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}", | ||
"remoteRoot": "." | ||
} | ||
] | ||
}, | ||
{ | ||
// Example of attaching to my production server | ||
"name": "Python: Attach Remote", | ||
"type": "python", | ||
"request": "attach", | ||
"port": 5678, | ||
"host": "homeassistant.local", | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}", | ||
"remoteRoot": "/usr/src/homeassistant" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"tests" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"files.associations": { | ||
"*.yaml": "home-assistant" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run Home Assistant on port 9123", | ||
"type": "shell", | ||
"command": "container start", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Run Home Assistant configuration against /config", | ||
"type": "shell", | ||
"command": "container check", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Upgrade Home Assistant to latest dev", | ||
"type": "shell", | ||
"command": "container install", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Install a specific version of Home Assistant", | ||
"type": "shell", | ||
"command": "container set-version", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Serve Documentation on port 8000", | ||
"type": "shell", | ||
"command": "mkdocs -v serve", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6a1f9c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic effort!
I have just loaded natively from dev though the UI and all appears good.