generated from ludeeus/integration_blueprint
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #18 from zackslash/master
New 'vehicle connected' binary sensor, bug fix & deprecation resolution
- Loading branch information
Showing
13 changed files
with
102 additions
and
21 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
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
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,52 @@ | ||
"""Binary Sensor platform for EO Mini.""" | ||
|
||
from homeassistant.components.binary_sensor import ( | ||
BinarySensorEntity, | ||
BinarySensorEntityDescription, | ||
BinarySensorDeviceClass, | ||
) | ||
from homeassistant.core import callback | ||
|
||
from custom_components.eo_mini import EODataUpdateCoordinator | ||
from .const import DOMAIN | ||
from .entity import EOMiniChargerEntity | ||
|
||
|
||
async def async_setup_entry(hass, entry, async_add_devices): | ||
"""Setup binary sensor platform.""" | ||
coordinator: EODataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] | ||
async_add_devices( | ||
[ | ||
EOMiniChargerVehicleConnectedSensor(coordinator), | ||
] | ||
) | ||
|
||
|
||
class EOMiniChargerVehicleConnectedSensor(EOMiniChargerEntity, BinarySensorEntity): | ||
"""EO Mini Charger vehicle connected binary sensor class.""" | ||
|
||
coordinator: EODataUpdateCoordinator | ||
|
||
_attr_icon = "mdi:car-electric" | ||
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY | ||
_previous_state = None | ||
|
||
def __init__(self, *args): | ||
self.entity_description = BinarySensorEntityDescription( | ||
key=BinarySensorDeviceClass.CONNECTIVITY, | ||
device_class=BinarySensorDeviceClass.CONNECTIVITY, | ||
name="Vehicle Connected", | ||
) | ||
self._attr_is_on = False | ||
super().__init__(*args) | ||
|
||
@callback | ||
def _handle_coordinator_update(self) -> None: | ||
"""Handle updated data from the coordinator.""" | ||
self._attr_is_on = self.coordinator.live_session | ||
self.async_write_ha_state() | ||
|
||
@property | ||
def unique_id(self): | ||
"""Return a unique ID for this entity.""" | ||
return f"{DOMAIN}_charger_{self.coordinator.serial}_vehicle_connected" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
colorlog==6.7.0 | ||
homeassistant==2024.3.1 | ||
homeassistant==2024.12.1 | ||
pip>=21.0,<23.2 | ||
ruff==0.0.292 |
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 +1,2 @@ | ||
pytest-homeassistant-custom-component | ||
homeassistant==2024.12.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
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