mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-01-09 04:06:19 +00:00
chore: improve Home Assistant adapter
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Add documentation for home assistant adapter. Make adapter correctly set the measurement keys for PV production. Add adapter configuration for grid import and export measurements. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
2
.env
2
.env
@@ -11,7 +11,7 @@ DOCKER_COMPOSE_DATA_DIR=${HOME}/.local/share/net.akkudoktor.eos
|
||||
# -----------------------------------------------------------------------------
|
||||
# Image / build
|
||||
# -----------------------------------------------------------------------------
|
||||
VERSION=0.2.0.dev81236039
|
||||
VERSION=0.2.0.dev44099868
|
||||
PYTHON_VERSION=3.13.9
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# the root directory (no add-on folder as usual).
|
||||
|
||||
name: "Akkudoktor-EOS"
|
||||
version: "0.2.0.dev81236039"
|
||||
version: "0.2.0.dev44099868"
|
||||
slug: "eos"
|
||||
description: "Akkudoktor-EOS add-on"
|
||||
url: "https://github.com/Akkudoktor-EOS/EOS"
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
"homeassistant": {
|
||||
"config_entity_ids": null,
|
||||
"load_emr_entity_ids": null,
|
||||
"grid_export_emr_entity_ids": null,
|
||||
"grid_import_emr_entity_ids": null,
|
||||
"pv_production_emr_entity_ids": null,
|
||||
"device_measurement_entity_ids": null,
|
||||
"device_instruction_entity_ids": null,
|
||||
@@ -59,6 +61,8 @@
|
||||
"homeassistant": {
|
||||
"config_entity_ids": null,
|
||||
"load_emr_entity_ids": null,
|
||||
"grid_export_emr_entity_ids": null,
|
||||
"grid_import_emr_entity_ids": null,
|
||||
"pv_production_emr_entity_ids": null,
|
||||
"device_measurement_entity_ids": null,
|
||||
"device_instruction_entity_ids": null,
|
||||
@@ -142,9 +146,11 @@ E.g. The instruction for device id 'battery1' becomes the entity_id 'sensor.eos_
|
||||
| device_measurement_entity_ids | `Optional[dict[str, str]]` | `rw` | `None` | Mapping of EOS measurement keys used by device (resource) simulations to Home Assistant entity IDs. |
|
||||
| eos_device_instruction_entity_ids | `list[str]` | `ro` | `N/A` | Entity IDs for energy management instructions available at EOS. |
|
||||
| eos_solution_entity_ids | `list[str]` | `ro` | `N/A` | Entity IDs for optimization solution available at EOS. |
|
||||
| grid_export_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of export to grid energy meter readings [kWh] |
|
||||
| grid_import_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of import from grid energy meter readings [kWh] |
|
||||
| homeassistant_entity_ids | `list[str]` | `ro` | `N/A` | Entity IDs available at Home Assistant. |
|
||||
| load_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of load energy meter reading [kWh] |
|
||||
| pv_production_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of PV production energy meter reading [kWh] |
|
||||
| load_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of load energy meter readings [kWh] |
|
||||
| pv_production_emr_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity ID(s) of PV production energy meter readings [kWh] |
|
||||
| solution_entity_ids | `Optional[list[str]]` | `rw` | `None` | Entity IDs for optimization solution keys to be updated by EOS.
|
||||
The solution keys have to be prepended by 'sensor.eos_' to build the entity_id.
|
||||
E.g. solution key 'battery1_idle_op_mode' becomes the entity_id 'sensor.eos_battery1_idle_op_mode'. |
|
||||
@@ -166,6 +172,12 @@ E.g. solution key 'battery1_idle_op_mode' becomes the entity_id 'sensor.eos_batt
|
||||
"load_emr_entity_ids": [
|
||||
"sensor.load_energy_total_kwh"
|
||||
],
|
||||
"grid_export_emr_entity_ids": [
|
||||
"sensor.grid_export_energy_total_kwh"
|
||||
],
|
||||
"grid_import_emr_entity_ids": [
|
||||
"sensor.grid_import_energy_total_kwh"
|
||||
],
|
||||
"pv_production_emr_entity_ids": [
|
||||
"sensor.pv_energy_total_kwh"
|
||||
],
|
||||
@@ -200,6 +212,12 @@ E.g. solution key 'battery1_idle_op_mode' becomes the entity_id 'sensor.eos_batt
|
||||
"load_emr_entity_ids": [
|
||||
"sensor.load_energy_total_kwh"
|
||||
],
|
||||
"grid_export_emr_entity_ids": [
|
||||
"sensor.grid_export_energy_total_kwh"
|
||||
],
|
||||
"grid_import_emr_entity_ids": [
|
||||
"sensor.grid_import_energy_total_kwh"
|
||||
],
|
||||
"pv_production_emr_entity_ids": [
|
||||
"sensor.pv_energy_total_kwh"
|
||||
],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
"homeassistant": {
|
||||
"config_entity_ids": null,
|
||||
"load_emr_entity_ids": null,
|
||||
"grid_export_emr_entity_ids": null,
|
||||
"grid_import_emr_entity_ids": null,
|
||||
"pv_production_emr_entity_ids": null,
|
||||
"device_measurement_entity_ids": null,
|
||||
"device_instruction_entity_ids": null,
|
||||
@@ -136,7 +138,7 @@
|
||||
}
|
||||
},
|
||||
"general": {
|
||||
"version": "0.2.0.dev81236039",
|
||||
"version": "0.2.0.dev44099868",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
| latitude | `EOS_GENERAL__LATITUDE` | `Optional[float]` | `rw` | `52.52` | Latitude in decimal degrees between -90 and 90. North is positive (ISO 19115) (°) |
|
||||
| longitude | `EOS_GENERAL__LONGITUDE` | `Optional[float]` | `rw` | `13.405` | Longitude in decimal degrees within -180 to 180 (°) |
|
||||
| timezone | | `Optional[str]` | `ro` | `N/A` | Computed timezone based on latitude and longitude. |
|
||||
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev81236039` | Configuration file version. Used to check compatibility. |
|
||||
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev44099868` | Configuration file version. Used to check compatibility. |
|
||||
:::
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
```json
|
||||
{
|
||||
"general": {
|
||||
"version": "0.2.0.dev81236039",
|
||||
"version": "0.2.0.dev44099868",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
@@ -46,7 +46,7 @@
|
||||
```json
|
||||
{
|
||||
"general": {
|
||||
"version": "0.2.0.dev81236039",
|
||||
"version": "0.2.0.dev44099868",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Akkudoktor-EOS
|
||||
|
||||
**Version**: `v0.2.0.dev81236039`
|
||||
**Version**: `v0.2.0.dev44099868`
|
||||
|
||||
<!-- pyml disable line-length -->
|
||||
**Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.
|
||||
|
||||
@@ -3,109 +3,194 @@
|
||||
|
||||
# Home Assistant Adapter
|
||||
|
||||
The Home Assistant adapter provides a bidirectional interface between
|
||||
The Home Assistant adapter provides a **bidirectional interface** between
|
||||
**Home Assistant (HA)** and the **Akkudoktor-EOS (EOS)** energy optimisation system.
|
||||
|
||||
It allows EOS to:
|
||||
|
||||
- **Read** entity states and attributes from Home Assistant
|
||||
- **Write** optimisation results and control instructions back to Home Assistant
|
||||
* **Read** entity states and attributes from Home Assistant
|
||||
* **Write** optimisation results and control instructions back to Home Assistant
|
||||
|
||||
This enables EOS to integrate seamlessly with Home Assistant–managed devices,
|
||||
sensors, and energy meters, while keeping EOS device simulations and optimisation
|
||||
logic decoupled from HA-specific implementations.
|
||||
sensors, and energy meters, while keeping EOS **device simulations and optimisation
|
||||
logic decoupled from HA-specific implementations**.
|
||||
|
||||
## Configuration entity IDs
|
||||
## 1. Exchanging data between EOS and Home Assistant
|
||||
|
||||
EOS can synchronise parts of its configuration from Home Assistant entity states.
|
||||
This is particularly useful for **device (resource) parameters** that are already
|
||||
provided by Home Assistant integrations, such as:
|
||||
### Basic concept
|
||||
|
||||
- Battery capacity
|
||||
- Maximum charge or discharge power
|
||||
- Nominal device ratings
|
||||
EOS **reads** configuration data and measurements from **Home Assistant entity states**
|
||||
before each energy management run.
|
||||
|
||||
These configuration values are typically consumed by EOS **device simulations**
|
||||
during optimisation.
|
||||
EOS **publishes results** by writing states and attributes to Home Assistant entities.
|
||||
After each optimisation run, these values are available as standard Home Assistant entities
|
||||
and can be used like any other sensor or state.
|
||||
|
||||
### Entity state conversion rules
|
||||
Typical use cases in Home Assistant:
|
||||
|
||||
When reading configuration values from entity states, the adapter applies the
|
||||
following heuristics to convert the HA state into a suitable EOS value:
|
||||
* Dashboards and visualisation
|
||||
* Automations and scripts
|
||||
* Device or manufacturer integrations
|
||||
* Debugging and validation
|
||||
|
||||
- **Boolean `True`**: `["y", "yes", "on", "true", "home", "open"]`
|
||||
- **Boolean `False`**: `["n", "no", "off", "false", "closed"]`
|
||||
- **`None`**: `["unavailable", "none"]`
|
||||
- **`float`**: if the value can be converted to a floating-point number
|
||||
- **`str`**: if none of the above apply
|
||||
### Configuration steps in EOS
|
||||
|
||||
## Device instruction entity IDs
|
||||
#### 1. Enable and configure the Home Assistant adapter
|
||||
|
||||
EOS must be configured with access to the Home Assistant API. It must be run
|
||||
as a Home Assistant add-on.
|
||||
|
||||
#### 2. Define source entity IDs
|
||||
|
||||
Configure EOS to read configuration and measurement entities from Home Assistant.
|
||||
Typical sources include:
|
||||
|
||||
* Configuration entities
|
||||
* Measurement entities
|
||||
|
||||
#### 3. Define target entity IDs
|
||||
|
||||
Configure EOS to write the results back to Home Assistant.
|
||||
Typical targets include:
|
||||
|
||||
* Device instruction entities
|
||||
* Solution / optimisation result entities
|
||||
|
||||
#### 4. Run energy optimisation
|
||||
|
||||
* EOS reads the source entities before optimisation.
|
||||
* After the run, EOS writes the device instruction and solution entities back to Home Assistant.
|
||||
|
||||
### Configuration steps in Home Assistant
|
||||
|
||||
#### 1. Accept entities created by EOS
|
||||
|
||||
Entities written by EOS automatically appear in Home Assistant’s state machine.
|
||||
|
||||
#### 2. Make entities usable in the UI
|
||||
|
||||
* Entities created by EOS have **no unique ID**.
|
||||
* To use them properly in dashboards, history, or automations, wrap them in **template sensors**.
|
||||
|
||||
#### 3. Use EOS data
|
||||
|
||||
EOS entities can be referenced in:
|
||||
|
||||
* Automations
|
||||
* Scripts
|
||||
* Dashboards
|
||||
* Device control logic
|
||||
|
||||
:::{admonition} Warning
|
||||
:class: warning
|
||||
Entities created by EOS have **no unique ID**. The unique ID cannot be set by an add-on.
|
||||
To use the entity information in the Home Assistant UI, a template sensor should be used.
|
||||
:::
|
||||
|
||||
##### Example: UI-usable template sensor for an EOS entity
|
||||
|
||||
<!-- pyml disable line-length -->
|
||||
```yaml
|
||||
template:
|
||||
- sensor:
|
||||
- name: "Battery1 Operation Mode"
|
||||
unique_id: "battery1_op_mode"
|
||||
state: >
|
||||
{% set battery1_op_mode = states('sensor.eos_battery1') -%}
|
||||
{{ battery1_op_mode }}
|
||||
state_class: measurement
|
||||
````
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
## 2. Data obtained *from EOS*
|
||||
|
||||
### 2.1 Device instruction entity IDs
|
||||
|
||||
After each energy optimisation run, EOS produces **device instructions** for the
|
||||
controlled resources. These instructions are written back to Home Assistant via
|
||||
dedicated entities.
|
||||
|
||||
- The **entity state** represents the selected **operation mode** of the device.
|
||||
- **Entity attributes** provide additional parameters for the operation mode, such as:
|
||||
* The **entity state** represents the device's selected **operation mode**.
|
||||
* **Entity attributes** provide additional parameters for the operation mode, such as:
|
||||
|
||||
- `operation_mode_factor`
|
||||
- Power or rate limits
|
||||
- Mode-specific control parameters
|
||||
* `operation_mode_factor`
|
||||
* Power or rate limits
|
||||
* Mode-specific control parameters
|
||||
|
||||
Home Assistant automations or device integrations can then react to these entity
|
||||
updates to perform the actual control actions.
|
||||
> **Note:** Home Assistant automations or device integrations can react to these updates to execute control actions.
|
||||
|
||||
## Device measurement entity IDs
|
||||
|
||||
Before starting an energy optimisation run, EOS retrieves **measurement values**
|
||||
from Home Assistant that describe the *current state* of devices.
|
||||
|
||||
Typical examples include:
|
||||
|
||||
- Battery state of charge (SoC)
|
||||
- Current power or energy levels
|
||||
- Device availability or readiness indicators
|
||||
|
||||
These measurements are used as input for EOS **device simulations** and strongly
|
||||
influence optimisation results.
|
||||
|
||||
## Load EMR entity IDs
|
||||
|
||||
Load **Energy Meter Readings (EMR)** are used to adapt and refine the **load
|
||||
prediction**.
|
||||
|
||||
EOS retrieves these readings from Home Assistant **before** each energy management
|
||||
run to align forecasts with actual consumption.
|
||||
|
||||
## PV production EMR entity IDs
|
||||
|
||||
PV production **Energy Meter Readings (EMR)** are used to adapt and refine the
|
||||
**photovoltaic generation forecast**.
|
||||
|
||||
EOS retrieves these readings from Home Assistant **before** each optimisation run
|
||||
to improve forecast accuracy based on real production data.
|
||||
|
||||
## Solution entity IDs
|
||||
### 2.2 Solution entity IDs
|
||||
|
||||
Each energy management run produces an **optimisation solution**.
|
||||
|
||||
In addition to device-level instructions, EOS can publish solution-level details to
|
||||
dedicated Home Assistant entities. These entities are useful for:
|
||||
EOS can publish solution-level details to dedicated Home Assistant entities for:
|
||||
|
||||
- Debugging and validation
|
||||
- Visualisation and dashboards
|
||||
- Gaining deeper insight into optimisation decisions
|
||||
* Debugging and validation
|
||||
* Visualisation and dashboards
|
||||
* Gaining deeper insight into optimisation decisions
|
||||
|
||||
EOS updates these entities **after** each energy management run.
|
||||
EOS updates these entities **after each energy management run**.
|
||||
|
||||
## Entity state and value conversion
|
||||
## 3. Data read by EOS from Home Assistant
|
||||
|
||||
Before starting an energy optimisation run, EOS retrieves several categories of
|
||||
data from Home Assistant, including:
|
||||
|
||||
### 3.1 Configuration entity IDs
|
||||
|
||||
EOS can synchronise parts of its configuration from Home Assistant entity states.
|
||||
This is particularly useful for **device (resource) parameters** already provided
|
||||
by Home Assistant integrations, such as:
|
||||
|
||||
* Battery capacity
|
||||
* Maximum charge or discharge power
|
||||
* Nominal device ratings
|
||||
|
||||
These values are typically consumed by EOS **device simulations** during optimisation.
|
||||
|
||||
### 3.2 Device measurement entity IDs
|
||||
|
||||
EOS retrieves **measurement values** that describe the *current state* of devices, such as:
|
||||
|
||||
* Battery state of charge (SoC)
|
||||
* Current power or energy levels
|
||||
* Device availability or readiness indicators
|
||||
|
||||
These measurements are used as input for EOS simulations and strongly influence
|
||||
optimisation results.
|
||||
|
||||
### 3.3 Energy meter entity IDs
|
||||
|
||||
**Energy Meter Readings (EMR)** are used to adapt and refine **predictions**.
|
||||
|
||||
* **Load** energy meter readings
|
||||
* **Grid export** energy meter readings
|
||||
* **Grid import** energy meter readings
|
||||
* **PV production** energy meter readings
|
||||
|
||||
EOS retrieves these readings from Home Assistant **before each energy management run**
|
||||
to align forecasts with actual consumption.
|
||||
|
||||
## 4. Entity state and value conversion
|
||||
|
||||
When reading configuration values and measurements from entity states, the adapter
|
||||
applies the following heuristics to convert the Home Assistant state into a suitable
|
||||
EOS value:
|
||||
|
||||
* **Boolean `True`**: `["y", "yes", "on", "true", "home", "open"]`
|
||||
* **Boolean `False`**: `["n", "no", "off", "false", "closed"]`
|
||||
* **`None`**: `["unavailable", "none"]`
|
||||
* **`float`**: if the value can be converted to a floating-point number
|
||||
* **`str`**: if none of the above apply
|
||||
|
||||
### Recommendation: value conversion in Home Assistant
|
||||
|
||||
To adapt, scale, or transform Home Assistant entity values to match EOS
|
||||
expectations, it is recommended to use
|
||||
[template sensors](https://www.home-assistant.io/integrations/template/#sensor).
|
||||
|
||||
This allows value conversion to remain fully within Home Assistant, keeping the EOS
|
||||
configuration clean and consistent.
|
||||
This keeps value conversion fully within Home Assistant, ensuring a clean and
|
||||
consistent EOS configuration.
|
||||
|
||||
### Example: Battery SoC conversion
|
||||
|
||||
@@ -124,3 +209,38 @@ template:
|
||||
state_class: measurement
|
||||
```
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
## 5. Further processing of EOS data in Home Assistant
|
||||
|
||||
Once published, EOS data behaves like any other Home Assistant entity and can be:
|
||||
|
||||
* Used as triggers or conditions in automations
|
||||
* Mapped to device-specific services or integrations
|
||||
* Visualised in dashboards
|
||||
* Compared with measured values for monitoring and validation
|
||||
|
||||
EOS does **not** directly control devices.
|
||||
It provides **structured optimisation results**, while Home Assistant remains
|
||||
responsible for executing the actual control actions.
|
||||
|
||||
## 6. Data sent *to EOS* and how
|
||||
|
||||
All data sent to EOS is provided via **Home Assistant entity states and attributes**.
|
||||
|
||||
| Data type | HA entity type | Purpose in EOS |
|
||||
| --------------------- | --------------- | -------------------- |
|
||||
| Configuration values | Sensor / Number | Device modelling |
|
||||
| Measurements | Sensor | Initial device state |
|
||||
| Energy meter readings | Sensor | Forecast correction |
|
||||
| Availability flags | Binary sensor | Device availability |
|
||||
|
||||
> EOS always **reads** this data; Home Assistant remains the authoritative source for measurements and configuration.
|
||||
|
||||
### Summary
|
||||
|
||||
* **EOS** focuses on **forecasting, simulation, and optimisation**
|
||||
* **Home Assistant** focuses on **measurement, integration, and execution**
|
||||
|
||||
The Home Assistant adapter provides a clear, structured interface between both
|
||||
systems, allowing flexible integration without coupling EOS to Home Assistant
|
||||
device specifics.
|
||||
|
||||
@@ -31,6 +31,8 @@ develop/install.md
|
||||
akkudoktoreos/configuration.md
|
||||
develop/update.md
|
||||
develop/revert.md
|
||||
akkudoktoreos/adapter/adapterhomeassistant.md
|
||||
akkudoktoreos/adapter/adapternodered.md
|
||||
|
||||
```
|
||||
|
||||
@@ -48,6 +50,7 @@ akkudoktoreos/prediction.md
|
||||
akkudoktoreos/measurement.md
|
||||
akkudoktoreos/integration.md
|
||||
akkudoktoreos/logging.md
|
||||
akkudoktoreos/adapter.md
|
||||
akkudoktoreos/serverapi.md
|
||||
akkudoktoreos/api.rst
|
||||
|
||||
|
||||
96
openapi.json
96
openapi.json
@@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "Akkudoktor-EOS",
|
||||
"description": "This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.",
|
||||
"version": "v0.2.0.dev81236039"
|
||||
"version": "v0.2.0.dev44099868"
|
||||
},
|
||||
"paths": {
|
||||
"/v1/admin/cache/clear": {
|
||||
@@ -2525,7 +2525,7 @@
|
||||
"general": {
|
||||
"$ref": "#/components/schemas/GeneralSettings-Output",
|
||||
"default": {
|
||||
"version": "0.2.0.dev81236039",
|
||||
"version": "0.2.0.dev44099868",
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
"longitude": 13.405,
|
||||
@@ -4272,7 +4272,7 @@
|
||||
"type": "string",
|
||||
"title": "Version",
|
||||
"description": "Configuration file version. Used to check compatibility.",
|
||||
"default": "0.2.0.dev81236039"
|
||||
"default": "0.2.0.dev44099868"
|
||||
},
|
||||
"data_folder_path": {
|
||||
"anyOf": [
|
||||
@@ -4346,7 +4346,7 @@
|
||||
"type": "string",
|
||||
"title": "Version",
|
||||
"description": "Configuration file version. Used to check compatibility.",
|
||||
"default": "0.2.0.dev81236039"
|
||||
"default": "0.2.0.dev44099868"
|
||||
},
|
||||
"data_folder_path": {
|
||||
"anyOf": [
|
||||
@@ -5240,7 +5240,7 @@
|
||||
}
|
||||
],
|
||||
"title": "Load Emr Entity Ids",
|
||||
"description": "Entity ID(s) of load energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of load energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.load_energy_total_kwh"
|
||||
@@ -5251,6 +5251,46 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"grid_export_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Grid Export Emr Entity Ids",
|
||||
"description": "Entity ID(s) of export to grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.grid_export_energy_total_kwh"
|
||||
]
|
||||
]
|
||||
},
|
||||
"grid_import_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Grid Import Emr Entity Ids",
|
||||
"description": "Entity ID(s) of import from grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.grid_import_energy_total_kwh"
|
||||
]
|
||||
]
|
||||
},
|
||||
"pv_production_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -5264,7 +5304,7 @@
|
||||
}
|
||||
],
|
||||
"title": "Pv Production Emr Entity Ids",
|
||||
"description": "Entity ID(s) of PV production energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of PV production energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.pv_energy_total_kwh"
|
||||
@@ -5376,7 +5416,7 @@
|
||||
}
|
||||
],
|
||||
"title": "Load Emr Entity Ids",
|
||||
"description": "Entity ID(s) of load energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of load energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.load_energy_total_kwh"
|
||||
@@ -5387,6 +5427,46 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"grid_export_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Grid Export Emr Entity Ids",
|
||||
"description": "Entity ID(s) of export to grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.grid_export_energy_total_kwh"
|
||||
]
|
||||
]
|
||||
},
|
||||
"grid_import_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Grid Import Emr Entity Ids",
|
||||
"description": "Entity ID(s) of import from grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.grid_import_energy_total_kwh"
|
||||
]
|
||||
]
|
||||
},
|
||||
"pv_production_emr_entity_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -5400,7 +5480,7 @@
|
||||
}
|
||||
],
|
||||
"title": "Pv Production Emr Entity Ids",
|
||||
"description": "Entity ID(s) of PV production energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of PV production energy meter readings [kWh]",
|
||||
"examples": [
|
||||
[
|
||||
"sensor.pv_energy_total_kwh"
|
||||
|
||||
@@ -54,7 +54,7 @@ class HomeAssistantAdapterCommonSettings(SettingsBaseModel):
|
||||
load_emr_entity_ids: Optional[list[str]] = Field(
|
||||
default=None,
|
||||
json_schema_extra={
|
||||
"description": "Entity ID(s) of load energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of load energy meter readings [kWh]",
|
||||
"examples": [
|
||||
["sensor.load_energy_total_kwh"],
|
||||
["sensor.load_emr1_kwh", "sensor.load_emr2_kwh"],
|
||||
@@ -62,10 +62,30 @@ class HomeAssistantAdapterCommonSettings(SettingsBaseModel):
|
||||
},
|
||||
)
|
||||
|
||||
grid_export_emr_entity_ids: Optional[list[str]] = Field(
|
||||
default=None,
|
||||
json_schema_extra={
|
||||
"description": "Entity ID(s) of export to grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
["sensor.grid_export_energy_total_kwh"],
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
grid_import_emr_entity_ids: Optional[list[str]] = Field(
|
||||
default=None,
|
||||
json_schema_extra={
|
||||
"description": "Entity ID(s) of import from grid energy meter readings [kWh]",
|
||||
"examples": [
|
||||
["sensor.grid_import_energy_total_kwh"],
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
pv_production_emr_entity_ids: Optional[list[str]] = Field(
|
||||
default=None,
|
||||
json_schema_extra={
|
||||
"description": "Entity ID(s) of PV production energy meter reading [kWh]",
|
||||
"description": "Entity ID(s) of PV production energy meter readings [kWh]",
|
||||
"examples": [
|
||||
["sensor.pv_energy_total_kwh"],
|
||||
["sensor.pv_emr1_kwh", "sensor.pv_emr2_kwh"],
|
||||
@@ -467,6 +487,50 @@ class HomeAssistantAdapter(AdapterProvider):
|
||||
except Exception as e:
|
||||
logger.error(f"{e}")
|
||||
|
||||
# Retrieve export to grid measurements
|
||||
entity_ids = self.config.adapter.homeassistant.grid_export_emr_entity_ids
|
||||
if entity_ids:
|
||||
measurement_keys = self.config.measurement.grid_export_emr_keys
|
||||
if measurement_keys is None:
|
||||
measurement_keys = []
|
||||
for entity_id in entity_ids:
|
||||
measurement_key = entity_id
|
||||
if measurement_key not in measurement_keys:
|
||||
measurement_keys.append(measurement_key)
|
||||
self.config.measurement.grid_export_emr_keys = measurement_keys
|
||||
try:
|
||||
state = self.get_entity_state(entity_id)
|
||||
logger.debug(f"Entity {entity_id}: {state}")
|
||||
if state:
|
||||
measurement_value = float(state)
|
||||
self.measurement.update_value(
|
||||
self.ems_start_datetime, measurement_key, measurement_value
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"{e}")
|
||||
|
||||
# Retrieve import from grid measurements
|
||||
entity_ids = self.config.adapter.homeassistant.grid_import_emr_entity_ids
|
||||
if entity_ids:
|
||||
measurement_keys = self.config.measurement.grid_import_emr_keys
|
||||
if measurement_keys is None:
|
||||
measurement_keys = []
|
||||
for entity_id in entity_ids:
|
||||
measurement_key = entity_id
|
||||
if measurement_key not in measurement_keys:
|
||||
measurement_keys.append(measurement_key)
|
||||
self.config.measurement.grid_import_emr_keys = measurement_keys
|
||||
try:
|
||||
state = self.get_entity_state(entity_id)
|
||||
logger.debug(f"Entity {entity_id}: {state}")
|
||||
if state:
|
||||
measurement_value = float(state)
|
||||
self.measurement.update_value(
|
||||
self.ems_start_datetime, measurement_key, measurement_value
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"{e}")
|
||||
|
||||
# Retrieve measurements for PV prediction
|
||||
entity_ids = self.config.adapter.homeassistant.pv_production_emr_entity_ids
|
||||
if entity_ids:
|
||||
@@ -477,7 +541,7 @@ class HomeAssistantAdapter(AdapterProvider):
|
||||
measurement_key = entity_id
|
||||
if measurement_key not in measurement_keys:
|
||||
measurement_keys.append(measurement_key)
|
||||
self.comfig.measurement.pv_production_emr_keys = measurement_keys
|
||||
self.config.measurement.pv_production_emr_keys = measurement_keys
|
||||
try:
|
||||
state = self.get_entity_state(entity_id)
|
||||
logger.debug(f"Entity {entity_id}: {state}")
|
||||
|
||||
@@ -703,6 +703,12 @@ def Configuration(
|
||||
elif config["name"].startswith("adapter.homeassistant.load_emr_entity_ids"):
|
||||
# Home Assistant adapter load energy meter readings entities
|
||||
update_form_factory = make_config_update_list_form(homeassistant_entity_ids)
|
||||
elif config["name"].startswith("adapter.homeassistant.grid_export_emr_entity_ids"):
|
||||
# Home Assistant adapter grid export energy meter readings entities
|
||||
update_form_factory = make_config_update_list_form(homeassistant_entity_ids)
|
||||
elif config["name"].startswith("adapter.homeassistant.grid_import_emr_entity_ids"):
|
||||
# Home Assistant adapter grid import energy meter readings entities
|
||||
update_form_factory = make_config_update_list_form(homeassistant_entity_ids)
|
||||
elif config["name"].startswith("adapter.homeassistant.pv_production_emr_entity_ids"):
|
||||
# Home Assistant adapter pv energy meter readings entities
|
||||
update_form_factory = make_config_update_list_form(homeassistant_entity_ids)
|
||||
|
||||
Reference in New Issue
Block a user