Skip to content

Commit

Permalink
Version 2.0.0 (#43)
Browse files Browse the repository at this point in the history
* Version 2.0.0

* Update README.md

* Update hacs.json

* Update labels.yml

* Update manifest.json

* Create config_flow.py

* Update hacs.json

* Update release.yml

* Update labels.yml

* Update README.md

* Create logo_new@2x.png

* Update README.md

* Update .gitignore

* Update README.md

* Delete entity.py

* Update __init__.py

* Update manifest.json

* Create entitys.py

* Update __init__.py

* Update const.py

* Update manifest.json

* Create const_schema.py

* Update config_flow.py

* Update sensor.py

* Create en.json

* Create de.json

* Update sensor.py

* Create strings.json

* Update sensor.py

* Update release.yml

* Update config_flow.py

* Update const.py

* Update config_flow.py

* Create coordinator.py

* Update manifest.json

* Update const_schema.py

* Create account_de_url.json

* Create demo_de_url.json

* Update config_flow.py

* Update hacs.json
  • Loading branch information
Ludy87 authored Jun 18, 2023
1 parent 68ec2a7 commit 577250d
Show file tree
Hide file tree
Showing 20 changed files with 1,221 additions and 554 deletions.
8 changes: 6 additions & 2 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
description: This issue or pull request already exists
color: cfd3d7
- name: feature request
description: Request a new ecotrend-ista feature
description: Request a new ista EcoTrend feature
color: a2eeef
- name: help wanted
description: Extra attention is needed
Expand Down Expand Up @@ -54,4 +54,8 @@
color: d73a4a
- name: NEWS
description: Integration News
color: "016175"
color: "016175"
- name: "Version 1"
color: "ff0000"
- name: "Version 2"
color: "5319e7"
30 changes: 11 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,16 @@ jobs:
run: |
version="$(python3 ./.github/actions/get_version.py)"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Is Tag exists
uses: mukunku/tag-exists-action@v1.2.0
id: checkTag
with:
tag: ${{ steps.version.outputs.version }}
- if: steps.checkTag.outputs.exists == 'false'
name: Check Tagname
id: check-tag
- uses: actions/checkout@v3.5.0
- name: ZIP Component Dir
run: |
if [[ "${{ steps.version.outputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Build
if: steps.check-tag.outputs.match == 'true'
uses: softprops/action-gh-release@v1
cd ${{ github.workspace }}/custom_components/ecotrend_ista
zip -r ecotrend_ista.zip ./
- name: Upload zip to release
uses: svenstaro/upload-release-action@2.5.0
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
draft: false
prerelease: false
token: "${{ secrets.TOKEN }}"
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/custom_components/ecotrend_ista/ecotrend_ista.zip
asset_name: ecotrend_ista.zip
tag: ${{ steps.version.outputs.version }}
overwrite: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ dmypy.json

# Home Assistant Core
/homeassistant

# Dev Files
codiga.*
115 changes: 24 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# ecotrend-ista

[ecotrend-ista](https://ecotrend.ista.de/) Home Assistant Integration

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge&logo=appveyor)](https://github.com/hacs/integration)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Ludy87/ecotrend-ista?style=for-the-badge&logo=appveyor)](https://github.com/Ludy87/ecotrend-ista/releases)
![GitHub Release Date](https://img.shields.io/github/release-date/Ludy87/ecotrend-ista?style=for-the-badge&logo=appveyor)
[![GitHub](https://img.shields.io/github/license/Ludy87/ecotrend-ista?style=for-the-badge&logo=appveyor)](LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/Ludy87/ecotrend-ista?style=for-the-badge&logo=appveyor)](https://github.com/Ludy87/ecotrend-ista/issues)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/Ludy87/ecotrend-ista.svg?logo=lgtm&logoWidth=18&style=for-the-badge)](https://lgtm.com/projects/g/Ludy87/ecotrend-ista/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Ludy87/ecotrend-ista.svg?logo=lgtm&logoWidth=18&style=for-the-badge)](https://lgtm.com/projects/g/Ludy87/ecotrend-ista/context:python)
[![Validate with hassfest and HACS](https://github.com/Ludy87/ecotrend-ista/actions/workflows/hassfest.yaml/badge.svg)](https://github.com/Ludy87/ecotrend-ista/actions/workflows/hassfest.yaml)

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ludy87)

[✨ Wishlist from Amazon ✨](https://smile.amazon.de/registry/wishlist/2MX8QK8VE9MV1)
# ista EcoTrend Version 2

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://img.shields.io/badge/My-HACS:%20REPOSITORY-000000.svg?&style=for-the-badge&logo=home-assistant&logoColor=white&color=049cdb)](https://my.home-assistant.io/redirect/hacs_repository/?owner=Ludy87&repository=ecotrend-ista&category=integration)
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge&logo=home-assistant&logoColor=white)](https://github.com/hacs/integration)
![Validate with hassfest and HACS](https://img.shields.io/github/actions/workflow/status/Ludy87/ecotrend-ista/hassfest.yaml?label=Validate%20with%20hassfest%20and%20hacs&style=for-the-badge&logo=home-assistant&logoColor=white)\
[![GitHub license](https://img.shields.io/github/license/Ludy87/ecotrend-ista?label=📜%20License&style=for-the-badge&logo=informational&logoColor=white)](LICENSE)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Ludy87/ecotrend-ista?style=for-the-badge&logo=GitHub&logoColor=white)](https://github.com/Ludy87/ecotrend-ista/releases)
![GitHub Release Date](https://img.shields.io/github/release-date/Ludy87/ecotrend-ista?style=for-the-badge&logo=GitHub&logoColor=white)
[![GitHub stars](https://img.shields.io/github/stars/Ludy87/ecotrend-ista?style=for-the-badge&logo=GitHub&logoColor=white)](https://github.com/Ludy87/ecotrend-ista/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/Ludy87/ecotrend-ista?style=for-the-badge&logo=GitHub&logoColor=white)](https://github.com/Ludy87/ecotrend-ista/issues)
![Github All Releases](https://img.shields.io/github/downloads/Ludy87/ecotrend-ista/total.svg?style=for-the-badge&logo=GitHub&logoColor=white)\
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge&logoColor=white)\
[![✨ Wishlist from Amazon ✨](https://img.shields.io/static/v1.svg?label=✨%20Wishlist%20from%20Amazon%20✨&message=📖&color=green&logo=amazon&style=for-the-badge&logoColor=white)](https://smile.amazon.de/registry/wishlist/2MX8QK8VE9MV1)
[![Buy me a coffee](https://img.shields.io/static/v1.svg?label=Buy%20me%20a%20coffee&message=donate&style=for-the-badge&color=black&logo=buy%20me%20a%20coffee&logoColor=white&labelColor=orange)](https://www.buymeacoffee.com/ludy87)

---
![ecotrend-ista](https://github.com/Ludy87/ecotrend-ista/blob/main/image/logo@2x.png?raw=true)
![ista EcoTrend V2](https://github.com/Ludy87/ecotrend-ista/blob/main/image/logo@2x_new.png?raw=true)

## Installation

Expand All @@ -27,90 +25,25 @@ Copy the ecotrend_ista [last Releae](https://github.com/Ludy87/ecotrend-ista/rel
### INSTALLATION mit HACS

1. Ensure that [HACS](https://hacs.xyz/) is installed.
2. Search for and install the "**ecotrend ista Integration**" integration. [![GitHub release (latest by date)](https://img.shields.io/github/v/release/Ludy87/ecotrend-ista?style=for-the-badge&logo=appveyor)](https://github.com/Ludy87/ecotrend-ista/releases)
3. [Add a `ecotrend_ista` entry to your `configuration.yaml`.](https://github.com/Ludy87/ecotrend-ista#basis-configuration)
2. Search for and install the "__ecotrend ista Integration__" integration. [![GitHub release (latest by date)](https://img.shields.io/github/v/release/Ludy87/ecotrend-ista?style=for-the-badge&logo=GitHub)](https://github.com/Ludy87/ecotrend-ista/releases)
3. [Configuration for the `ista EcoTrend` integration is now performed via a config flow as opposed to yaml configuration file.](https://github.com/Ludy87/ecotrend-ista#basis-configuration)
4. Restart Home Assistant.

---

## Basis Configuration

Add entry to your `configuration.yaml`

```yaml
ecotrend_ista:
email: "email@local"
password: "password"
```
![list_all](https://github.com/Ludy87/ecotrend-ista/blob/main/image/list_all.png?raw=true)
### optional
```yaml
unit_heating: "Einheiten" # default kwh
unit_warmwater: "" # default kwh
```
```yaml
year:
- 2022
yearmonth:
- "2022.4"
```
1. Go to HACS -> Integrations -> Click "+"
2. Search for "ista EcoTrend" repository and add to HACS
3. Restart Home Assistant when it says to.
4. In Home Assistant, go to Configuration -> Integrations -> Click "+ Add Integration"
5. Search for "ista EcoTrend" and follow the instructions to setup.

```yaml
scan_interval: 39600
```
---
### deprecated v1.0.7-beta-3
ista EcoTrend should now appear as a card under the HA Integrations page with "Configure" selection available at the bottom of the card.

```yaml
unit: "kwh"
```
---

## Template
```yaml
- template:
- sensor:
- name: ECO Heizung Einheiten
unit_of_measurement: "Einheiten"
state: "{{ state_attr('sensor.heating_XXXXXXXXX', 'value') }}"
state_class: total
- name: ECO Heizung kwh
unit_of_measurement: "kwh"
state: "{{ state_attr('sensor.heating_XXXXXXXXX', 'valuekwh') }}"
state_class: total
- name: ECO Wasserverbrauch m³
unit_of_measurement: ""
state: "{{ state_attr('sensor.warmwater_XXXXXXXXX', 'value') }}"
state_class: total
- name: ECO Wasserverbrauch kwh
unit_of_measurement: "kwh"
state: "{{ state_attr('sensor.warmwater_XXXXXXXXX', 'valuekwh') }}"
state_class: total
- name: ECO Heizung Einheiten 03/2022
unit_of_measurement: "Einheiten"
state: "{{ state_attr('sensor.heating_2022_3_XXXXXXXXX', 'value') }}"
state_class: total
- name: ECO Heizung kwh 03/2022
unit_of_measurement: "kwh"
state: "{{ state_attr('sensor.heating_2022_3_XXXXXXXXX', 'valuekwh') }}"
state_class: total
- name: ECO Wasserverbrauch m³ 03/2022
unit_of_measurement: ""
state: "{{ state_attr('sensor.warmwater_2022_3_XXXXXXXXX', 'value') }}"
state_class: total
- name: ECO Wasserverbrauch kwh 03/2022
unit_of_measurement: "kwh"
state: "{{ state_attr('sensor.warmwater_2022_3_XXXXXXXXX', 'valuekwh') }}"
state_class: total
```
![](./image/template.png)
# Debug
## Debug

```yaml
logger:
Expand Down
145 changes: 55 additions & 90 deletions custom_components/ecotrend_ista/__init__.py
Original file line number Diff line number Diff line change
@@ -1,113 +1,78 @@
""" ecotrend-ista """
""" ista EcoTrend Version 2 """
from __future__ import annotations

import logging
import voluptuous as vol

from datetime import timedelta
import voluptuous as vol

from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType

from .const import (
CONF_CONTROLLER,
CONF_EMAIL,
CONF_PASSWORD,
CONF_UNIT,
CONF_UNIT_HEATING,
CONF_UNIT_WARMWATER,
CONF_UPDATE_FREQUENCY,
CONF_YEAR,
CONF_YEARMONTH,
DEFAULT_SCAN_INTERVAL_TIME,
DOMAIN,
UNIT_SUPPORT_HEATING,
UNIT_SUPPORT_WARMWATER,
)
from .const import DATA_HASS_CONFIG, DOMAIN
from .const_schema import DEFAULT_DATA_SCHEMA
from .coordinator import IstaDataUpdateCoordinator

from pyecotrend_ista import pyecotrend_ista as ista
PLATFORMS = [Platform.SENSOR]

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [SENSOR_DOMAIN]
DEFAULT_SCAN_INTERVAL = timedelta(seconds=DEFAULT_SCAN_INTERVAL_TIME)

CONTROLLER_SCHEMA = vol.Schema(
{
vol.Required(CONF_EMAIL): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
##############################################
########## deprecated configuration ##########
##############################################
########## options v1.0.7-beta-3 #############
vol.Remove(CONF_UNIT): cv.string, ###########
##############################################
vol.Optional(CONF_UNIT_HEATING, default="kwh"): cv.string,
vol.Optional(CONF_UNIT_WARMWATER, default="kwh"): cv.string,
vol.Optional(CONF_YEAR, default=[]): cv.ensure_list,
vol.Optional(CONF_YEARMONTH, default=[]): cv.ensure_list,
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL): cv.time_period,
}
)

CONFIG_SCHEMA = vol.Schema(
{DOMAIN: vol.Schema(vol.All(cv.ensure_list, [CONTROLLER_SCHEMA]))},
{DOMAIN: vol.Schema(DEFAULT_DATA_SCHEMA)},
extra=vol.ALLOW_EXTRA,
)


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.data[CONF_EMAIL] = []
hass.data[CONF_PASSWORD] = []
hass.data[CONF_UNIT_HEATING] = []
hass.data[CONF_UNIT_WARMWATER] = []
hass.data[CONF_UPDATE_FREQUENCY] = []
hass.data[CONF_YEAR] = []
hass.data[CONF_YEARMONTH] = []
hass.data[DOMAIN] = []
success = False
for controller_config in config[DOMAIN]:
success = success or await _setup_controller(hass, controller_config, config)
return success


async def _setup_controller(hass: HomeAssistant, controller_config, config: ConfigType) -> bool:
email: str = controller_config[CONF_EMAIL]
password: str = controller_config[CONF_PASSWORD]
unitheating = controller_config[CONF_UNIT_HEATING]
unitwarmwater = controller_config[CONF_UNIT_WARMWATER]

if unitheating != "" and unitheating not in UNIT_SUPPORT_HEATING:
raise Exception(f'unit "{unitheating}" don\'t supported. Only: {UNIT_SUPPORT_HEATING} or remove unit: "{unitheating}"')
if unitwarmwater != "" and unitwarmwater not in UNIT_SUPPORT_WARMWATER:
raise Exception(
f'unit "{unitwarmwater}" don\'t supported. Only: {UNIT_SUPPORT_WARMWATER} or remove unit: "{unitwarmwater}"'
)

eco = ista.PyEcotrendIsta(email=email, password=password)
await eco.login()
position = len(hass.data[DOMAIN])
hass.data[CONF_EMAIL].append(email)
hass.data[CONF_PASSWORD].append(password)
hass.data[CONF_UNIT_HEATING].append(unitheating)
hass.data[CONF_UNIT_WARMWATER].append(unitwarmwater)
hass.data[CONF_UPDATE_FREQUENCY].append(controller_config[CONF_SCAN_INTERVAL])
hass.data[CONF_YEAR].append(controller_config[CONF_YEAR])
hass.data[CONF_YEARMONTH].append(controller_config[CONF_YEARMONTH])
hass.data[DOMAIN].append(eco)

for platform in PLATFORMS:
async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
"""Set up the ista EcoTrend Version 2 component."""
_LOGGER.debug("Set up the ista EcoTrend Version 2 component")
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][DATA_HASS_CONFIG] = hass_config
if DOMAIN in hass_config:
hass.async_create_task(
discovery.async_load_platform(
hass,
platform,
hass.config_entries.flow.async_init(
DOMAIN,
{CONF_CONTROLLER: position, **controller_config},
config,
context={"source": config_entries.SOURCE_IMPORT},
data={
CONF_EMAIL: hass_config[DOMAIN][CONF_EMAIL],
CONF_PASSWORD: hass_config[DOMAIN][CONF_PASSWORD],
},
)
)
return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Configure based on config entry."""
_LOGGER.debug("Configure based on config entry %s", entry.entry_id)
coordinator = IstaDataUpdateCoordinator(hass, entry)
await coordinator.init()
await coordinator.async_config_entry_first_refresh()

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

entry.async_on_unload(entry.add_update_listener(options_update_listener))

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
_LOGGER.debug("Unload a config entry")
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok


async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Handle options update."""
_LOGGER.debug("Configuration options updated, reloading ista EcoTrend 2 integration")
await hass.config_entries.async_reload(config_entry.entry_id)
Loading

0 comments on commit 577250d

Please sign in to comment.