Skip to content

Commit

Permalink
Add forbidden capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
WebSpider committed Nov 3, 2024
1 parent 9440e50 commit 84a8540
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions custom_components/myskoda/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ def device_info(self) -> DeviceInfo: # noqa: D102
def required_capabilities(self) -> list[CapabilityId]:
return []

def forbidden_capabilities(self) -> list[CapabilityId]:
return []

def is_supported(self) -> bool:
return all(
self.vehicle.has_capability(cap) for cap in self.required_capabilities()
)

def is_forbidden(self) -> bool:
return all(
self.vehicle.has_capability(cap) for cap in self.forbidden_capabilities()
)

def get_renders(self) -> dict[str, str]:
"""Return a dict of all vehicle image render URLs, keyed by view_point.
Expand Down
5 changes: 3 additions & 2 deletions custom_components/myskoda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def add_supported_entities(
for vin in coordinators:
for SensorClass in available_entities:
sensor = SensorClass(coordinators[vin], vin)
if sensor.is_supported():
entities.append(sensor)
if not sensor.is_forbidden():
if sensor.is_supported():
entities.append(sensor)

async_add_entities(entities, update_before_add=True)

0 comments on commit 84a8540

Please sign in to comment.