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

Add support for energy sites to re-write #250

Merged
merged 110 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
18bb0b1
Update Dev Container
Megabytemb Apr 26, 2022
cc7be78
Initial rewrite WIP
Megabytemb Apr 26, 2022
a98f0fb
More typing and comments.
Megabytemb Apr 27, 2022
5542f5c
Start Working on Sensors.
Megabytemb May 2, 2022
c166bfc
Climate Entity
Megabytemb May 2, 2022
130ebf7
More Sensor Updates.
Megabytemb May 3, 2022
7aaa55a
Add new controls.
Megabytemb May 4, 2022
6b9faf2
Add support for Sensors, Switches and Buttons.
Megabytemb May 6, 2022
fb8c97e
ran isort
Megabytemb May 6, 2022
954d4da
Add Locks
Megabytemb May 6, 2022
aad4789
fix initial data loading lag.
Megabytemb May 6, 2022
cc2e58b
Small Cleanup
Megabytemb May 9, 2022
dbfd4c9
add Binary Sensors
Megabytemb May 9, 2022
9c7c63d
Add Device_tracker
Megabytemb May 9, 2022
9da15ff
run isort
Megabytemb May 9, 2022
69a0eb4
enable device_tracker
Megabytemb May 9, 2022
80b45c8
Fix Up testing Env.
Megabytemb May 20, 2022
27d0d78
Fix Up testing Env.
Megabytemb May 20, 2022
4fb87c4
Merge branch 'tesla-rewrite' of https://github.com/Megabytemb/tesla i…
Megabytemb May 20, 2022
c83bb61
First Round of Tests.
Megabytemb May 20, 2022
eae15a4
Initial commit for energy site support
shred86 Aug 18, 2022
3890495
Fix update_controller and small updates
shred86 Aug 18, 2022
bb3fee5
Refactor and fix NumberEntity
shred86 Aug 18, 2022
aa9c3c2
Update const
shred86 Aug 18, 2022
2a08210
More updates to fix NumberEntity
shred86 Aug 18, 2022
f08a349
Fix naming issue
shred86 Aug 18, 2022
7a095bc
Naming updates and fixes
shred86 Aug 18, 2022
4a9d316
Temporary requirements change for testing
shred86 Aug 18, 2022
70b991a
Minor clean up
shred86 Aug 19, 2022
07a6921
Add battery data for battery sites
shred86 Aug 19, 2022
b00023f
Add power_data property to TeslaEnergyDevice class
shred86 Aug 19, 2022
7e9bc46
Update for teslajsonpy changes
shred86 Aug 20, 2022
ddec892
Fix typos with charging
shred86 Aug 20, 2022
ba648bb
Initial commit for changes to teslajsonpy
shred86 Aug 21, 2022
bc0d767
More updates for teslajsonpy changes
shred86 Aug 21, 2022
b3a7e1d
Clean up unused methods
shred86 Aug 21, 2022
4933af5
Remove temporary argument
shred86 Aug 21, 2022
68636e5
Add checks for steering wheel and rear seat heater
shred86 Aug 21, 2022
bdb19c8
Fix & add tests and add generate objects
shred86 Aug 29, 2022
b5f8c15
Minor clean up
shred86 Aug 29, 2022
9cb9f66
Add sentry mode check and fix range display
shred86 Aug 29, 2022
4aad5ea
Minor update to solar attribute naming
shred86 Aug 29, 2022
6c23163
Add battery site entities and fix battery sensor
shred86 Aug 30, 2022
96f8088
Change battery remaining to Watt hour
shred86 Aug 30, 2022
e7c2277
Add set operation mode and backup reserve
shred86 Aug 31, 2022
fed10fc
Update icons
shred86 Aug 31, 2022
cfcaacb
Add energy export rule
shred86 Sep 1, 2022
b845f3a
Change name to match app
shred86 Sep 1, 2022
afd54e6
Fix property name
shred86 Sep 2, 2022
b9d81e7
Add grid charging switch
shred86 Sep 2, 2022
84b78c0
Check for solar
shred86 Sep 2, 2022
1efd319
Change grid charging to select entity and fixes
shred86 Sep 2, 2022
e973141
Icon updates
shred86 Sep 2, 2022
3fbf07a
Update tests and unique ID format for energy sites
shred86 Sep 2, 2022
5c1430c
Naming clean up and add more tests
shred86 Sep 2, 2022
bd3c413
Clean up and icon changes
shred86 Sep 2, 2022
3d74e28
Fix power sensors and clean up
shred86 Sep 2, 2022
e0e1556
Icon updates
shred86 Sep 2, 2022
e11114f
Charger icons updated
shred86 Sep 2, 2022
e2337be
Doc string updates and remove unused code
shred86 Sep 2, 2022
d25265d
Update HA state after sending post request
shred86 Sep 4, 2022
845073f
Update class naming convention
shred86 Sep 4, 2022
93073ac
Update README to reflect changes and updates
shred86 Sep 4, 2022
dfca569
Update README format
shred86 Sep 4, 2022
9a8a4f8
Add update entity to README
shred86 Sep 4, 2022
1128c9e
Icon changes, clean up and change min amps
shred86 Sep 5, 2022
b92d5ca
Add sw version for Powerwall sites
shred86 Sep 5, 2022
13a6f54
Add and update tests
shred86 Sep 5, 2022
2524982
Fix for showing state change
shred86 Sep 5, 2022
5622973
Update to match docs
shred86 Sep 5, 2022
7f90b75
Update test_button.py
shred86 Sep 6, 2022
a808d17
Fix for energy added error
shred86 Sep 6, 2022
c6eafda
Add 100W buffer to battery charging
shred86 Sep 6, 2022
0fe034a
HomeLink check and fixes
shred86 Sep 7, 2022
ed93a4b
Fix for reseting energy added to 0
shred86 Sep 8, 2022
6d7ecc3
Unique ID change and fixes
shred86 Sep 10, 2022
9b1bdfb
Update tests
shred86 Sep 10, 2022
7cd69fd
Changes for better climate control
shred86 Sep 10, 2022
648d65e
Fix for energy added
shred86 Sep 10, 2022
e743bcc
Move some attributes and fix parking brake
shred86 Sep 10, 2022
7901e74
Update charging device class
shred86 Sep 10, 2022
ca17f16
Minor clean up
shred86 Sep 11, 2022
56bf27c
Add charger power sensor and move attributes
shred86 Sep 18, 2022
926c653
Update to support teslajsonpy changes
shred86 Sep 18, 2022
234a234
Rename Mileage sensor to Odometer
shred86 Sep 18, 2022
910e32d
Use user unit settings
shred86 Sep 19, 2022
a891fe1
Catch httpx.ConnectError
shred86 Sep 19, 2022
b1431e1
Use try for generate_car_objects method
shred86 Sep 19, 2022
08540c4
Change to cover entity
shred86 Sep 20, 2022
5c5d476
Fix charger cover state
shred86 Sep 22, 2022
ae210af
Fix attribute typo
shred86 Sep 22, 2022
e8b9eb5
Fix for charge port door open state
shred86 Sep 24, 2022
d592e16
Check for powered lift gate
shred86 Sep 24, 2022
88ed5d0
Default True for wake on start
shred86 Sep 24, 2022
628e1d8
Add note about wake on start defaulted on
shred86 Sep 24, 2022
afcb640
Wake if asleep only on initial setup
shred86 Sep 25, 2022
2918750
Fixes for vehicle asleep state
shred86 Sep 25, 2022
d3f734d
Update homelink and strings
shred86 Sep 26, 2022
b7c918f
Use DistanceConverter
shred86 Oct 8, 2022
c585c60
Remove unused import
shred86 Oct 10, 2022
1ce9cb4
Merge 'dev' of alandtse/tesla into tesla-rewrite
shred86 Oct 10, 2022
c6650aa
Poetry update
shred86 Oct 10, 2022
dada861
Add gcj02 to wgs84 conversion
shred86 Oct 11, 2022
75f465d
Bump teslajsonpy
shred86 Oct 14, 2022
84368c1
Update poetry and pyprojects
shred86 Oct 14, 2022
c64d087
Update tests
shred86 Oct 16, 2022
dac813d
Update min HA version
shred86 Oct 16, 2022
6835b77
build: update dependencies
alandtse Oct 16, 2022
9b75b66
ci: update python to 3.10
alandtse Oct 16, 2022
6f901db
ci: pass python version as string
alandtse Oct 16, 2022
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: 1 addition & 1 deletion .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ logger:
authcaptureproxy: debug
teslajsonpy: debug
# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
# debugpy:
11 changes: 6 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"image": "ludeeus/container:integration-debian",
"name": "Tesla Custom Component development",
"context": "..",
"appPort": ["9123:8123"],
"postCreateCommand": "container install && pip install poetry && poetry config virtualenvs.create false && poetry install",
"image": "ghcr.io/ludeeus/devcontainer/integration:stable",
"appPort": [
"9123:8123"
],
"postCreateCommand": "bash .devcontainer/post-create.sh",
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
Expand All @@ -29,4 +30,4 @@
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
}
35 changes: 35 additions & 0 deletions .devcontainer/post-create.sh
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ hs_err_pid*
*.jl.mem
deps/deps.jl

# User settings
/.vscode/settings.json


# Keep these config files
!/.gitignore
!/.travis.yml
Expand All @@ -72,3 +76,4 @@ deps/deps.jl
!/.scrutinizer.yml
!/.prospector.yml
!/.devcontainer
!/.vscode
35 changes: 35 additions & 0 deletions .vscode/launch.json
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"
}
]
}
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.default.json
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"
}
}
35 changes: 35 additions & 0 deletions .vscode/tasks.json
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": []
}
]
}
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
[![Discord][discord-shield]][discord]
[![Community Forum][forum-shield]][forum]

A fork of the [official Tesla integration](https://www.home-assistant.io/integrations/tesla/) in Home Assistant.

This is the successor to the core app which was removed due to Tesla login issues. Do not report issues to Home Assistant.
A fork of the previous official Tesla integration in Home Assistant which has been removed due to Tesla login issues. Do not report issues to Home Assistant.

To use the component, you will need an application to generate a Tesla refresh token:

Expand All @@ -36,32 +34,36 @@ To use the component, you will need an application to generate a Tesla refresh t
7. Restart Home Assistant.
8. [![Add Integration][add-integration-badge]][add-integration] or in the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Tesla Custom Integration".

Note: This integration will wake up your vehicle(s) during installation.

<!---->

## Usage

The `Tesla` integration offers integration with the [Tesla](https://auth.tesla.com/login) cloud service and provides presence detection as well as sensors such as charger state and temperature.

This integration provides the following platforms:
This integration provides the following entities for vehicles:

- Binary sensors - charger connection, charging status, car online and parking brake.
- Buttons - horn, flash lights, wake up<sup>1</sup>, force data update<sup>1</sup> and trigger HomeLink. **Note:** The HomeLink button is disabled by default as some vehicles don't have this option. Enable via configuration/entities if desired.
- Climate - turn HVAC on/off, set target temperature, set preset modes (defrost, keep on, dog mode and camp mode).
- Device tracker - car location<sup>1</sup>.
- Locks - door lock, rear trunk lock, front trunk (frunk) lock and charger door lock.
**Note:** Set `state` to `heat_cool` or `off` to enable/disable your Tesla's climate system via a scene.
- Selects - seat heaters and cabin overheat protection<sup>2</sup>.
- Sensors - battery level, charge rate, energy added, inside/outside temperature, odometer and estimated range.
- Switches - heated steering wheel, charger, sentry mode and polling<sup>1</sup>.
- Update - software update<sup>2</sup>

- Binary sensors - such as update available, parking, and charger connection.
- Sensors - such as Battery level, Inside/Outside temperature, odometer, estimated range, charging rate, and vehicle data
- Device tracker - to track location of your car
- Locks - Door lock, rear trunk lock, front trunk (frunk) lock and charger door lock. Enables you to control Tesla's door, trunks and charger door lock.
- Climate - HVAC control. Allow you to control (turn on/off, set target temperature) your Tesla's HVAC system. Also enables preset modes to enable or disable max defrost mode `defrost` or `normal` operation mode. **NOTE:** Set `state` to `heat_cool` or `off` to enable/disable your Tesla's climate system via a scene.
- Switches - Charger and max range switch allow you to start/stop charging and set max range charging. Polling switch allows you to disable polling of vehicles to conserve battery. Sentry mode switch enables or disable Sentry mode.
- Buttons - Horn, Flash lights, and Trigger homelink. **Note:** The homelink button is disabled by default as many vehicles don't have the homelink option. Enable via configuration/entities if desired.
<sup>1</sup> *Diagnostics entities.*<br/>
<sup>2</sup> *Configuration entities.*

The following sensors provide all available vehicle data as attributes. These sensors are disabled by default and need to be enabled in HASS first. It is also recommended to exclude these sensors from [recorder](https://www.home-assistant.io/integrations/recorder/).

- Climate data sensor
- Charge data sensor
- Vehicle state data sensor
- Software update data sensor
- Speed Limit data sensor
- Vehicle Config data sensor
- Drive State data sensor
- GUI Settings data sensor
This integration provides the following entities for energy sites:

- Binary sensors - Powerwall charging and grid status.
- Selects - grid charging, export rule and operation mode.
- Sensors - solar power, grid power, load power, battery level, battery Wh remaining and backup reserve.

This integration provies the following platforms for solar systems:

Expand All @@ -72,9 +74,7 @@ This integration provies the following platforms for solar systems:
Tesla options are set via **Configuration** -> **Integrations** -> **Tesla** -> **Options**.

- Seconds between polling - referred to below as the `polling_interval`.

- Wake cars on start - Whether to wake sleeping cars on Home Assistant startup. This allows a user to choose whether cars should continue to sleep (and not update information) or to wake up the cars potentially interrupting long term hibernation and increasing vampire drain.

- Polling policy - When do we actively poll the car to get updates, and when do we try to allow the car to sleep. See [the Wiki](https://github.com/alandtse/tesla/wiki/Polling-policy) for more information.

## Potential Battery impacts
Expand Down
Loading