-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
magnuselden
authored and
magnuselden
committed
Aug 13, 2023
1 parent
686d898
commit 04f5160
Showing
1 changed file
with
27 additions
and
27 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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
from __future__ import annotations | ||
# from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
# from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from custom_components.peaqev.peaqservice.hub.hub import HomeAssistantHub | ||
from homeassistant.core import HomeAssistant # pylint: disable=import-error | ||
# if TYPE_CHECKING: | ||
# from custom_components.peaqev.peaqservice.hub.hub import HomeAssistantHub | ||
# from homeassistant.core import HomeAssistant # pylint: disable=import-error | ||
|
||
import logging | ||
from enum import Enum | ||
# import logging | ||
# from enum import Enum | ||
|
||
from .const import DOMAIN | ||
# from .const import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
# _LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class ServiceCalls(Enum): | ||
OVERRIDE_SENSOR_DATA = "override_sensor_data" | ||
# class ServiceCalls(Enum): | ||
# OVERRIDE_SENSOR_DATA = "override_sensor_data" | ||
|
||
async def async_servicehandler_override_sensor_data(call): | ||
_sensor = call.data.get("sensor_entity", None) | ||
_duration = call.data.get("cycle_duration_in_minutes", None) | ||
_energy = call.data.get("cycle_energy_in_kwh", None) | ||
# async def async_servicehandler_override_sensor_data(call): | ||
# _sensor = call.data.get("sensor_entity", None) | ||
# _duration = call.data.get("cycle_duration_in_minutes", None) | ||
# _energy = call.data.get("cycle_energy_in_kwh", None) | ||
|
||
_LOGGER.debug("Calling {} service".format(ServiceCalls.OVERRIDE_CHARGE_AMOUNT.value)) | ||
# if _amount and _amount > 0: | ||
# await hub.max_min_controller.async_servicecall_override_charge_amount(_amount) | ||
|
||
# Register services | ||
SERVICES = { | ||
ServiceCalls.OVERRIDE_SENSOR_DATA: async_servicehandler_override_sensor_data | ||
} | ||
|
||
for service, handler in SERVICES.items(): | ||
hass.services.async_register(DOMAIN, service.value, handler) | ||
_LOGGER.debug("Registered services: {}".format(SERVICES.keys())) | ||
# _LOGGER.debug("Calling {} service".format(ServiceCalls.OVERRIDE_CHARGE_AMOUNT.value)) | ||
# # if _amount and _amount > 0: | ||
# # await hub.max_min_controller.async_servicecall_override_charge_amount(_amount) | ||
|
||
# # Register services | ||
# SERVICES = { | ||
# ServiceCalls.OVERRIDE_SENSOR_DATA: async_servicehandler_override_sensor_data | ||
# } | ||
|
||
# for service, handler in SERVICES.items(): | ||
# hass.services.async_register(DOMAIN, service.value, handler) | ||
# _LOGGER.debug("Registered services: {}".format(SERVICES.keys())) |