Skip to content

Commit

Permalink
Update volvooncall, add hybrid plug status (home-assistant#58919)
Browse files Browse the repository at this point in the history
  • Loading branch information
decompil3d authored Dec 3, 2021
1 parent 88b9354 commit c915aa1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ homeassistant/components/vizio/* @raman325
homeassistant/components/vlc_telnet/* @rodripf @dmcc @MartinHjelmare
homeassistant/components/volkszaehler/* @fabaff
homeassistant/components/volumio/* @OnFreund
homeassistant/components/volvooncall/* @molobrakos @decompil3d
homeassistant/components/wake_on_lan/* @ntilley905
homeassistant/components/wallbox/* @hesselonline
homeassistant/components/waqi/* @andrey-git
Expand Down
22 changes: 17 additions & 5 deletions homeassistant/components/volvooncall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def discover_vehicle(vehicle):
hass,
PLATFORMS[instrument.component],
DOMAIN,
(vehicle.vin, instrument.component, instrument.attr),
(
vehicle.vin,
instrument.component,
instrument.attr,
instrument.slug_attr,
),
config,
)
)
Expand Down Expand Up @@ -192,7 +197,7 @@ def __init__(self, config):
self.config = config[DOMAIN]
self.names = self.config.get(CONF_NAME)

def instrument(self, vin, component, attr):
def instrument(self, vin, component, attr, slug_attr):
"""Return corresponding instrument."""
return next(
(
Expand All @@ -201,6 +206,7 @@ def instrument(self, vin, component, attr):
if instrument.vehicle.vin == vin
and instrument.component == component
and instrument.attr == attr
and instrument.slug_attr == slug_attr
),
None,
)
Expand All @@ -223,12 +229,13 @@ def vehicle_name(self, vehicle):
class VolvoEntity(Entity):
"""Base class for all VOC entities."""

def __init__(self, data, vin, component, attribute):
def __init__(self, data, vin, component, attribute, slug_attr):
"""Initialize the entity."""
self.data = data
self.vin = vin
self.component = component
self.attribute = attribute
self.slug_attr = slug_attr

async def async_added_to_hass(self):
"""Register update dispatcher."""
Expand All @@ -241,7 +248,9 @@ async def async_added_to_hass(self):
@property
def instrument(self):
"""Return corresponding instrument."""
return self.data.instrument(self.vin, self.component, self.attribute)
return self.data.instrument(
self.vin, self.component, self.attribute, self.slug_attr
)

@property
def icon(self):
Expand Down Expand Up @@ -287,4 +296,7 @@ def extra_state_attributes(self):
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self.vin}-{self.component}-{self.attribute}"
slug_override = ""
if self.instrument.slug_override is not None:
slug_override = f"-{self.instrument.slug_override}"
return f"{self.vin}-{self.component}-{self.attribute}{slug_override}"
4 changes: 2 additions & 2 deletions homeassistant/components/volvooncall/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ async def async_setup_scanner(hass, config, async_see, discovery_info=None):
if discovery_info is None:
return

vin, component, attr = discovery_info
vin, component, attr, slug_attr = discovery_info
data = hass.data[DATA_KEY]
instrument = data.instrument(vin, component, attr)
instrument = data.instrument(vin, component, attr, slug_attr)

async def see_vehicle():
"""Handle the reporting of the vehicle position."""
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/volvooncall/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "volvooncall",
"name": "Volvo On Call",
"documentation": "https://www.home-assistant.io/integrations/volvooncall",
"requirements": ["volvooncall==0.8.12"],
"codeowners": [],
"requirements": ["volvooncall==0.9.1"],
"codeowners": ["@molobrakos", "@decompil3d"],
"iot_class": "cloud_polling"
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ vilfo-api-client==0.3.2
volkszaehler==0.2.1

# homeassistant.components.volvooncall
volvooncall==0.8.12
volvooncall==0.9.1

# homeassistant.components.verisure
vsure==1.7.3
Expand Down

0 comments on commit c915aa1

Please sign in to comment.