-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add firmware update entity to IronOS integration (#123031)
- Loading branch information
Showing
12 changed files
with
315 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
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,76 @@ | ||
"""Update platform for IronOS integration.""" | ||
|
||
from __future__ import annotations | ||
|
||
from homeassistant.components.update import ( | ||
UpdateDeviceClass, | ||
UpdateEntity, | ||
UpdateEntityDescription, | ||
UpdateEntityFeature, | ||
) | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
|
||
from . import IronOSConfigEntry | ||
from .coordinator import IronOSBaseCoordinator | ||
from .entity import IronOSBaseEntity | ||
|
||
UPDATE_DESCRIPTION = UpdateEntityDescription( | ||
key="firmware", | ||
device_class=UpdateDeviceClass.FIRMWARE, | ||
) | ||
|
||
|
||
async def async_setup_entry( | ||
hass: HomeAssistant, | ||
entry: IronOSConfigEntry, | ||
async_add_entities: AddEntitiesCallback, | ||
) -> None: | ||
"""Set up IronOS update platform.""" | ||
|
||
coordinator = entry.runtime_data.firmware | ||
|
||
async_add_entities([IronOSUpdate(coordinator, UPDATE_DESCRIPTION)]) | ||
|
||
|
||
class IronOSUpdate(IronOSBaseEntity, UpdateEntity): | ||
"""Representation of an IronOS update entity.""" | ||
|
||
_attr_supported_features = UpdateEntityFeature.RELEASE_NOTES | ||
|
||
def __init__( | ||
self, | ||
coordinator: IronOSBaseCoordinator, | ||
entity_description: UpdateEntityDescription, | ||
) -> None: | ||
"""Initialize the sensor.""" | ||
super().__init__(coordinator, entity_description) | ||
|
||
@property | ||
def installed_version(self) -> str | None: | ||
"""IronOS version on the device.""" | ||
|
||
return self.coordinator.device_info.build | ||
|
||
@property | ||
def title(self) -> str | None: | ||
"""Title of the IronOS release.""" | ||
|
||
return f"IronOS {self.coordinator.data.name}" | ||
|
||
@property | ||
def release_url(self) -> str | None: | ||
"""URL to the full release notes of the latest IronOS version available.""" | ||
|
||
return self.coordinator.data.html_url | ||
|
||
@property | ||
def latest_version(self) -> str | None: | ||
"""Latest IronOS version available for install.""" | ||
|
||
return self.coordinator.data.tag_name | ||
|
||
async def async_release_notes(self) -> str | None: | ||
"""Return the release notes.""" | ||
|
||
return self.coordinator.data.body |
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,62 @@ | ||
# serializer version: 1 | ||
# name: test_update.2 | ||
'**RELEASE_NOTES**' | ||
# --- | ||
# name: test_update[update.pinecil_firmware-entry] | ||
EntityRegistryEntrySnapshot({ | ||
'aliases': set({ | ||
}), | ||
'area_id': None, | ||
'capabilities': None, | ||
'config_entry_id': <ANY>, | ||
'device_class': None, | ||
'device_id': <ANY>, | ||
'disabled_by': None, | ||
'domain': 'update', | ||
'entity_category': <EntityCategory.CONFIG: 'config'>, | ||
'entity_id': 'update.pinecil_firmware', | ||
'has_entity_name': True, | ||
'hidden_by': None, | ||
'icon': None, | ||
'id': <ANY>, | ||
'labels': set({ | ||
}), | ||
'name': None, | ||
'options': dict({ | ||
}), | ||
'original_device_class': <UpdateDeviceClass.FIRMWARE: 'firmware'>, | ||
'original_icon': None, | ||
'original_name': 'Firmware', | ||
'platform': 'iron_os', | ||
'previous_unique_id': None, | ||
'supported_features': <UpdateEntityFeature: 16>, | ||
'translation_key': None, | ||
'unique_id': 'c0:ff:ee:c0:ff:ee_firmware', | ||
'unit_of_measurement': None, | ||
}) | ||
# --- | ||
# name: test_update[update.pinecil_firmware-state] | ||
StateSnapshot({ | ||
'attributes': ReadOnlyDict({ | ||
'auto_update': False, | ||
'device_class': 'firmware', | ||
'entity_picture': 'https://brands.home-assistant.io/_/iron_os/icon.png', | ||
'friendly_name': 'Pinecil Firmware', | ||
'in_progress': False, | ||
'installed_version': 'v2.22', | ||
'latest_version': 'v2.22', | ||
'release_summary': None, | ||
'release_url': 'https://github.com/Ralim/IronOS/releases/tag/v2.22', | ||
'skipped_version': None, | ||
'supported_features': <UpdateEntityFeature: 16>, | ||
'title': 'IronOS V2.22 | TS101 & S60 Added | PinecilV2 improved', | ||
'update_percentage': None, | ||
}), | ||
'context': <ANY>, | ||
'entity_id': 'update.pinecil_firmware', | ||
'last_changed': <ANY>, | ||
'last_reported': <ANY>, | ||
'last_updated': <ANY>, | ||
'state': 'off', | ||
}) | ||
# --- |
Oops, something went wrong.