-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
176 additions
and
532 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,6 @@ jobs: | |
run: | | ||
make lint | ||
make test | ||
make black | ||
make ruff | ||
make mypy |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# autodoc | ||
homeassistant | ||
bluecurrent-api | ||
|
||
# readthedocs dependencies | ||
alabaster==0.7.12 | ||
attrs==21.2.0 | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
2 changes: 1 addition & 1 deletion
2
docs/source/documentation/api-package-documentation/exceptions.md
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
2 changes: 1 addition & 1 deletion
2
docs/source/documentation/api-package-documentation/websocket.md
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,103 +1,9 @@ | ||
# Integration | ||
|
||
### async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool | ||
|
||
- Retrieves the api token from the config_entry. | ||
- Tries to connect to the API. | ||
- Starts the loop. | ||
- Waits until `CHARGE_POINTS` is received. | ||
- Stores the connector, so it can be retrieved in other classes. | ||
- Tells Ha to start the platform setup. | ||
- Sets disconnect to be called when the integration is unloaded. | ||
- Defines all service methods. | ||
- Registers services. | ||
|
||
### async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool | ||
|
||
- Unloads the config entry. | ||
|
||
### set_entities_unavailable(hass: HomeAssistant, config_id: str) | ||
|
||
- Sets all BlueCurrent entities to unavailable. | ||
|
||
## Connector | ||
|
||
charge_points: dict[str, dict] | ||
grid: dict[str, Any] | ||
|
||
### \_\_init\_\_(hass: HomeAssistant, config: ConfigEntry, client: Client) | ||
|
||
- Stores the given parameters. | ||
|
||
### connect(token: str) | ||
|
||
- Sets `on_data` as the receiver. | ||
- Connects to the API. | ||
|
||
### on_data(message: dict) | ||
|
||
[](../flow/on-data.md) | ||
|
||
Routes the received message to the correct function based on the object. | ||
|
||
#### handle_charge_points(data: list) | ||
|
||
- Adds all evse_ids to `charge_points` and sends status requests for each. Also sends grid status request. | ||
|
||
### get_charge_point_data(self, evse_id: str) | ||
|
||
- Requests the status and settings of the charge point with the given evse_id. | ||
|
||
### add_charge_point(self, evse_id: str, model: str, name: str) | ||
|
||
- Adds the charge point to `charge_points` | ||
|
||
### update_charge_point(self, evse_id: str, data: dict) | ||
|
||
- Updates the key, value pairs of charge point with the given evse_id and dispatches a signal. | ||
|
||
#### handle_activity(data: dict) | ||
|
||
- The state of the block / operative switch is not returned with `CH_STATUS`, But the state is related to the state of the `activity` sensor. So this function sets the state of `block` switch based on the state of `activity`. | ||
|
||
### dispatch_value_update_signal(self, evse_id: str) | ||
- Dispatches a `value_update` | ||
|
||
### dispatch_grid_update_signal(self) -> None: | ||
- Dispatches a `grid_update` | ||
|
||
### start_loop() | ||
|
||
- Tries to start the loop for listening to the API. | ||
- If an error happens, a warning is logged and the reconnect method is called after 1 second. | ||
|
||
```{note} | ||
The reason for the one second delay is that the connection closes quite frequently so with this it 'immediately' reconnects. | ||
```{toctree} | ||
--- | ||
maxdepth: 1 | ||
glob: | ||
--- | ||
integration-documentation/* | ||
``` | ||
|
||
### reconnect(self, event_time: datetime | None = None) | ||
|
||
- Tries to reconnect the API, starts the loop again and requests the charge points. | ||
- If the reconnection fails the entities will be set unavailable and the reconnect method will be called again in 20 seconds. | ||
- If the error was `request limit reached`, the reconnect method is called after the next limit reset. | ||
|
||
### disconnect() | ||
|
||
- Disconnects with the API, if the connection was already closed and a `WebsocketError` is thrown, ignore it. | ||
|
||
## BlueCurrentEntity(Entity) | ||
|
||
### \_\_init\_\_(connector: Connector, evse_id: str | None = None) | ||
|
||
- Stores connector | ||
- If evse_id is given, device info is added to entity. | ||
|
||
### async_added_to_hass() | ||
|
||
- Connects the dispatcher to a signal to call `update` when triggered. | ||
|
||
Update method calls `update_from_latest_data()` and writes the state to HA. | ||
|
||
### update_from_latest_data() | ||
|
||
- Method that is implemented in the platform classes. |
23 changes: 23 additions & 0 deletions
23
docs/source/documentation/integration-documentation/config_flow.md
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,23 @@ | ||
# ConfigFlow | ||
|
||
```{eval-rst} | ||
.. automodule:: homeassistant.components.blue_current.config_flow | ||
:members: | ||
:private-members: | ||
:special-members: | ||
:exclude-members: __weakref__ | ||
``` | ||
|
||
### async_step_user | ||
- This method is called when a user adds the integration to Home Assistant. If the user_input is None it returns the form with `async_show_form`. | ||
- If there is user input it will validate the given token and get the customer id and email. The customer id is used as the unique id of the config entry and the email as title. | ||
- If an exception happens it will add an error to the `errors` dict and this will be given to `async_show_form` and shown to the user. | ||
- If there are no errors it sets the unique id and stores the current entry if there is one. | ||
- If there is a current entry 'update_entry' is called and the flow will be aborted because the reauth is successful. | ||
- Otherwise, the entry is created normally. | ||
|
||
|
||
### async_step_reauth | ||
|
||
- Is called when a config is reconfigured. This button is shown when the `ConfigEntryAuthFailed` exception is raised in `async_setup_entry` in `__init__.py`. | ||
- Calls `async_step_user` in which the entry is updated instead of creating a new one. |
9 changes: 9 additions & 0 deletions
9
docs/source/documentation/integration-documentation/entity.md
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,9 @@ | ||
# Entity | ||
|
||
```{eval-rst} | ||
.. automodule:: homeassistant.components.blue_current.entity | ||
:members: | ||
:private-members: | ||
:special-members: | ||
:exclude-members: __weakref__ | ||
``` |
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,9 @@ | ||
# Init | ||
|
||
```{eval-rst} | ||
.. automodule:: homeassistant.components.blue_current.__init__ | ||
:members: | ||
:private-members: | ||
:special-members: | ||
:exclude-members: __weakref__ | ||
``` |
9 changes: 9 additions & 0 deletions
9
docs/source/documentation/integration-documentation/sensor.md
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,9 @@ | ||
# Sensor | ||
|
||
```{eval-rst} | ||
.. automodule:: homeassistant.components.blue_current.sensor | ||
:members: | ||
:private-members: | ||
:special-members: | ||
:exclude-members: __weakref__ | ||
``` |
Oops, something went wrong.