Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
36fa65c
chore: custom endpoints
davidccdtsp Jul 2, 2024
8ebf10b
wip: login
davidccdtsp Jul 4, 2024
0b3c3d5
chore: deps update and refactor
davidccdtsp Jul 4, 2024
b27bf7e
wip: address
davidccdtsp Jul 4, 2024
9873e31
chore: add address to lambda_args
davidccdtsp Jul 4, 2024
869496b
chore: add location into optispark backend
davidccdtsp Jul 5, 2024
5bd0b2e
wip: add device
davidccdtsp Jul 5, 2024
f1ad5bc
chore: delete prints
davidccdtsp Jul 5, 2024
7933499
wip: add device
davidccdtsp Jul 5, 2024
a7d3c2e
chore: cleaning
davidccdtsp Jul 5, 2024
e425463
chore: get location id from backend if necessary
davidccdtsp Jul 5, 2024
9b56b56
fix: LocationResponse from_json
davidccdtsp Jul 5, 2024
a43c364
fix: user_hash and json key in DeviceResponse
davidccdtsp Jul 8, 2024
a2862eb
wip: mock lambda response
davidccdtsp Jul 8, 2024
a414cf2
chore: get backend url from config
davidccdtsp Jul 10, 2024
11b377d
wip
davidccdtsp Jul 10, 2024
3113f38
wip
davidccdtsp Jul 10, 2024
33ff39f
wip: thermostat service
davidccdtsp Jul 10, 2024
47fb18e
wip
davidccdtsp Jul 10, 2024
c5188a2
wip
davidccdtsp Jul 10, 2024
ba48619
wip
davidccdtsp Jul 10, 2024
d92ca13
chore: thermostat service
davidccdtsp Jul 10, 2024
e72848e
wip: create manual control
davidccdtsp Jul 11, 2024
e994a2f
wip: thermostat create manual added heat pump info (temp and mode)
davidccdtsp Jul 11, 2024
72dd0b9
wip: refactor
davidccdtsp Jul 11, 2024
920ae78
chore: cleaning comments
davidccdtsp Jul 11, 2024
c80b41d
wip: get graph info
davidccdtsp Jul 11, 2024
c3804ea
wip
davidccdtsp Jul 11, 2024
1bb8f76
fix
davidccdtsp Jul 11, 2024
3f4e2b7
chore: get profile from graph data
davidccdtsp Jul 11, 2024
b6bd4d6
chore: added cache to ConfigurationService
davidccdtsp Jul 12, 2024
e529a4a
chore: default value option in get from ConfigurationService
davidccdtsp Jul 12, 2024
127e326
chore: disable ssl verification option
davidccdtsp Jul 12, 2024
70244e4
fix: dictionary key
davidccdtsp Jul 12, 2024
b309e5a
wip
davidccdtsp Jul 12, 2024
b537228
wip
davidccdtsp Jul 12, 2024
e13fe4f
fix: homeassistant.const.TEMP_CELSIUS
davidccdtsp Jul 15, 2024
619d735
chore: update set_point on startup
davidccdtsp Jul 16, 2024
5e2c03c
chore: climate fetches target temp on startup
davidccdtsp Jul 16, 2024
39ca6ed
chore: fetch climate data from backend
davidccdtsp Jul 16, 2024
c758a6a
chore: cleaning
davidccdtsp Jul 16, 2024
ea51de3
wip
davidccdtsp Jul 16, 2024
911e348
chore: automatic login when token expires & big refactor
davidccdtsp Jul 16, 2024
dc7264f
chore: send data to backend
davidccdtsp Jul 17, 2024
a334468
fix: circular import
davidccdtsp Jul 17, 2024
bb6dc02
chore: send device data
davidccdtsp Jul 18, 2024
6b76080
update device data log
davidccdtsp Jul 18, 2024
a8281c4
chore: clean and rename dir
davidccdtsp Jul 27, 2024
12bca82
fix: location None check
davidccdtsp Jul 28, 2024
55a990f
chore: remote config
davidccdtsp Jul 29, 2024
0af7f8c
fix: endpoints
davidccdtsp Jul 30, 2024
edcb555
chore: thermostat_service cache
davidccdtsp Jul 30, 2024
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ config/*

homeassistant
Session.vim

# IntelliJ

.idea
Empty file added custom_components/__init__.py
Empty file.
52 changes: 36 additions & 16 deletions custom_components/optispark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
For more details about this integration, please refer to
https://github.com/Big-Tree/HomeAssistant-OptiSpark
"""

from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
Expand All @@ -11,30 +12,47 @@
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .api import OptisparkApiClient
from .const import DOMAIN, LOGGER
from custom_components.optispark.domain.address.address import Address

PLATFORMS: list[Platform] = [
Platform.SENSOR,
Platform.SWITCH,
Platform.NUMBER,
Platform.CLIMATE
Platform.CLIMATE,
]


# https://developers.home-assistant.io/docs/config_entries_index/#setting-up-an-entry
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up this integration using UI."""
from .coordinator import OptisparkDataUpdateCoordinator # Prevent circular import
from .backend_update_handler import BackendUpdateHandler # Prevent circular import
from .coordinator import OptisparkDataUpdateCoordinator
from .climate import OptisparkClimate

address = Address(
address=entry.data["address"],
postcode=entry.data["postcode"],
city=entry.data["city"],
country=entry.data["country"]
)

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = coordinator = OptisparkDataUpdateCoordinator(
hass=hass,
client=OptisparkApiClient(
session=async_get_clientsession(hass)),
climate_entity_id=entry.data['climate_entity_id'],
heat_pump_power_entity_id=entry.data['heat_pump_power_entity_id'],
external_temp_entity_id=entry.data['external_temp_entity_id'],
user_hash=entry.data['user_hash'],
postcode=entry.data['postcode'],
tariff=entry.data['tariff']
session=async_get_clientsession(hass),
user_hash=entry.data["user_hash"],
address=address
),
climate_entity_id=entry.data["climate_entity_id"],
heat_pump_power_entity_id=entry.data["heat_pump_power_entity_id"],
external_temp_entity_id=entry.data["external_temp_entity_id"],
user_hash=entry.data["user_hash"],
postcode=entry.data["postcode"],
tariff=entry.data["tariff"],
address=entry.data["address"],
city=entry.data["city"],
country=entry.data["country"],
)
# https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities
await coordinator.async_config_entry_first_refresh()
Expand Down Expand Up @@ -77,17 +95,19 @@ def get_entity(hass, entity_id):
entities_found = []
successful_domains = []
for domain in hass.data:
if hasattr(hass.data[domain], 'get_entity'):
if hasattr(hass.data[domain], "get_entity"):
entity = hass.data[domain].get_entity(entity_id)
if entity is not None:
entities_found.append(entity)
successful_domains.append(domain)
if len(entities_found) != 1:
LOGGER.error(f'({len(entities_found)}) entities found instead of 1')
LOGGER.error(f'successful_domains:\n {successful_domains}')
LOGGER.error(f'entities_found:\n {entities_found}')
LOGGER.error(f'hass.data.keys():\n {hass.data.keys()}')
raise OptisparkGetEntityError(f'({len(entities_found)}) entities found instead of 1')
LOGGER.error(f"({len(entities_found)}) entities found instead of 1")
LOGGER.error(f"successful_domains:\n {successful_domains}")
LOGGER.error(f"entities_found:\n {entities_found}")
LOGGER.error(f"hass.data.keys():\n {hass.data.keys()}")
raise OptisparkGetEntityError(
f"({len(entities_found)}) entities found instead of 1"
)
return entities_found[0]


Expand All @@ -97,6 +117,6 @@ def get_username(hass):
Surely there is a better way than this.
"""
try:
return list(hass.data['person'][1].data.keys())[0]
return list(hass.data["person"][1].data.keys())[0]
except Exception:
return None
Loading