-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from tijsverkoyen/169-charging-station
169 charging station
- Loading branch information
Showing
13 changed files
with
317 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
custom_components/nhc2/entities/easee_chargingstation_charging_mode.py
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,28 @@ | ||
from homeassistant.components.select import SelectEntity | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationChargingModeEntity(NHCBaseEntity, SelectEntity): | ||
_attr_has_entity_name = True | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a select entity.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = device_instance.uuid + '_charging_mode' | ||
|
||
self._attr_options = self._device.possible_charging_modes | ||
|
||
@property | ||
def name(self) -> str: | ||
return 'Charging Mode' | ||
|
||
@property | ||
def current_option(self) -> str: | ||
return self._device.charging_mode | ||
|
||
async def async_select_option(self, option: str) -> None: | ||
self._device.set_charging_mode(self._gateway, option) | ||
self.schedule_update_ha_state() |
26 changes: 26 additions & 0 deletions
26
custom_components/nhc2/entities/easee_chargingstation_charging_status.py
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,26 @@ | ||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationChargingStatusEntity(NHCBaseEntity, SensorEntity): | ||
_attr_has_entity_name = True | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a sensor.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = device_instance.uuid + '_charging_status' | ||
|
||
self._attr_device_class = SensorDeviceClass.ENUM | ||
self._attr_options = self._device.possible_charging_status | ||
self._attr_native_value = self._device.charging_status | ||
|
||
@property | ||
def name(self) -> str: | ||
return 'Charging Status' | ||
|
||
@property | ||
def state(self) -> str: | ||
return self._device.charging_status |
28 changes: 28 additions & 0 deletions
28
custom_components/nhc2/entities/easee_chargingstation_coupling_status.py
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,28 @@ | ||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass | ||
from homeassistant.helpers.entity import EntityCategory | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationCouplingStatusEntity(NHCBaseEntity, SensorEntity): | ||
_attr_has_entity_name = True | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a sensor.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = device_instance.uuid + '_coupling_status' | ||
|
||
self._attr_device_class = SensorDeviceClass.ENUM | ||
self._attr_options = self._device.possible_coupling_status | ||
self._attr_native_value = self._device.coupling_status | ||
self._attr_entity_category = EntityCategory.DIAGNOSTIC | ||
|
||
@property | ||
def name(self) -> str: | ||
return 'Coupling Status' | ||
|
||
@property | ||
def state(self) -> str: | ||
return self._device.coupling_status |
30 changes: 30 additions & 0 deletions
30
custom_components/nhc2/entities/easee_chargingstation_electrical_power.py
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,30 @@ | ||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass | ||
from homeassistant.const import UnitOfPower | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationElectricalPowerEntity(NHCBaseEntity, SensorEntity): | ||
_attr_has_entity_name = True | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a sensor.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = device_instance.uuid + '_electrical_power' | ||
|
||
self._attr_device_class = SensorDeviceClass.POWER | ||
self._attr_native_value = self._device.electrical_power | ||
self._attr_native_unit_of_measurement = UnitOfPower.WATT | ||
self._attr_state_class = SensorStateClass.MEASUREMENT | ||
self._attr_suggested_display_precision = 2 | ||
self._attr_native_precision = 2 | ||
|
||
@property | ||
def name(self) -> str: | ||
return 'Electrical Power' | ||
|
||
@property | ||
def native_value(self) -> float: | ||
return self._device.electrical_power |
26 changes: 26 additions & 0 deletions
26
custom_components/nhc2/entities/easee_chargingstation_ev_status.py
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,26 @@ | ||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationEvStatusEntity(NHCBaseEntity, SensorEntity): | ||
_attr_has_entity_name = True | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a sensor.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = device_instance.uuid + '_ev_status' | ||
|
||
self._attr_device_class = SensorDeviceClass.ENUM | ||
self._attr_options = self._device.possible_ev_status | ||
self._attr_native_value = self._device.ev_status | ||
|
||
@property | ||
def name(self) -> str: | ||
return 'EV Status' | ||
|
||
@property | ||
def state(self) -> str: | ||
return self._device.ev_status |
31 changes: 31 additions & 0 deletions
31
custom_components/nhc2/entities/easee_chargingstation_status.py
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,31 @@ | ||
from homeassistant.components.switch import SwitchEntity, SwitchDeviceClass | ||
|
||
from ..nhccoco.devices.easee_chargingstation import CocoEaseeChargingstation | ||
from .nhc_entity import NHCBaseEntity | ||
|
||
|
||
class Nhc2EaseeChargingstationStatusEntity(NHCBaseEntity, SwitchEntity): | ||
_attr_has_entity_name = True | ||
_attr_name = None | ||
|
||
def __init__(self, device_instance: CocoEaseeChargingstation, hub, gateway): | ||
"""Initialize a switch.""" | ||
super().__init__(device_instance, hub, gateway) | ||
|
||
self._attr_unique_id = self._device.uuid | ||
|
||
@property | ||
def device_class(self) -> str: | ||
return SwitchDeviceClass.SWITCH | ||
|
||
@property | ||
def is_on(self) -> bool: | ||
return self._device.is_status_on | ||
|
||
async def async_turn_on(self): | ||
self._device.turn_on(self._gateway) | ||
self.schedule_update_ha_state() | ||
|
||
async def async_turn_off(self): | ||
self._device.turn_off(self._gateway) | ||
self.schedule_update_ha_state() |
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
83 changes: 83 additions & 0 deletions
83
custom_components/nhc2/nhccoco/devices/easee_chargingstation.py
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,83 @@ | ||
from ..const import PROPERTY_CHARGING_MODE, PROPERTY_CHARGING_STATUS, PROPERTY_COUPLING_STATUS, \ | ||
PROPERTY_ELECTRICAL_POWER, PROPERTY_EV_STATUS, PROPERTY_STATUS, PROPERTY_STATUS_VALUE_OFF, PROPERTY_STATUS_VALUE_ON | ||
from ..helpers import to_float_or_none | ||
from .device import CoCoDevice | ||
|
||
|
||
class CocoEaseeChargingstation(CoCoDevice): | ||
@property | ||
def supports_status(self) -> bool: | ||
return self.has_property(PROPERTY_STATUS) | ||
|
||
@property | ||
def status(self) -> str: | ||
return self.extract_property_value(PROPERTY_STATUS) | ||
|
||
@property | ||
def is_status_on(self) -> bool: | ||
return self.status == PROPERTY_STATUS_VALUE_ON | ||
|
||
@property | ||
def charging_mode(self) -> str: | ||
return self.extract_property_value(PROPERTY_CHARGING_MODE) | ||
|
||
@property | ||
def possible_charging_modes(self) -> list[str]: | ||
return self.extract_property_definition_description_choices(PROPERTY_CHARGING_MODE) | ||
|
||
@property | ||
def supports_charging_mode(self) -> bool: | ||
return self.has_property(PROPERTY_CHARGING_MODE) | ||
|
||
@property | ||
def charging_status(self) -> str: | ||
return self.extract_property_value(PROPERTY_CHARGING_STATUS) | ||
|
||
@property | ||
def possible_charging_status(self) -> list: | ||
return self.extract_property_definition_description_choices(PROPERTY_CHARGING_STATUS) | ||
|
||
@property | ||
def supports_charging_status(self) -> bool: | ||
return self.has_property(PROPERTY_CHARGING_STATUS) | ||
|
||
@property | ||
def coupling_status(self) -> str: | ||
return self.extract_property_value(PROPERTY_COUPLING_STATUS) | ||
|
||
@property | ||
def possible_coupling_status(self) -> list: | ||
return self.extract_property_definition_description_choices(PROPERTY_COUPLING_STATUS) | ||
|
||
@property | ||
def supports_coupling_status(self) -> bool: | ||
return self.has_property(PROPERTY_COUPLING_STATUS) | ||
|
||
@property | ||
def ev_status(self) -> str: | ||
return self.extract_property_value(PROPERTY_EV_STATUS) | ||
|
||
@property | ||
def possible_ev_status(self) -> list: | ||
return self.extract_property_definition_description_choices(PROPERTY_EV_STATUS) | ||
|
||
@property | ||
def supports_ev_status(self) -> bool: | ||
return self.has_property(PROPERTY_EV_STATUS) | ||
|
||
@property | ||
def electrical_power(self) -> float: | ||
return to_float_or_none(self.extract_property_value(PROPERTY_ELECTRICAL_POWER)) | ||
|
||
@property | ||
def supports_electrical_power(self) -> bool: | ||
return self.has_property(PROPERTY_ELECTRICAL_POWER) | ||
|
||
def turn_on(self, gateway): | ||
gateway.add_device_control(self.uuid, PROPERTY_STATUS, PROPERTY_STATUS_VALUE_ON) | ||
|
||
def turn_off(self, gateway): | ||
gateway.add_device_control(self.uuid, PROPERTY_STATUS, PROPERTY_STATUS_VALUE_OFF) | ||
|
||
def set_charging_mode(self, gateway, charging_mode: str): | ||
gateway.add_device_control(self.uuid, PROPERTY_CHARGING_MODE, charging_mode) |
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
Oops, something went wrong.