Add Nextcloud update entity (#106690)
* add nextcloud update entity * don't init update entity on older nextcloud versions * ruff * pass skipUpdate to module * bump deps * bump requirements * Update homeassistant/components/nextcloud/update.py Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> * Update homeassistant/components/nextcloud/update.py Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> * bump requirements * Update homeassistant/components/nextcloud/update.py Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> * Update homeassistant/components/nextcloud/update.py Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> --------- Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
This commit is contained in:
parent
0b09ffbcde
commit
e7d5ae7ef6
6 changed files with 58 additions and 5 deletions
|
@ -844,6 +844,7 @@ omit =
|
|||
homeassistant/components/nextcloud/coordinator.py
|
||||
homeassistant/components/nextcloud/entity.py
|
||||
homeassistant/components/nextcloud/sensor.py
|
||||
homeassistant/components/nextcloud/update.py
|
||||
homeassistant/components/nfandroidtv/__init__.py
|
||||
homeassistant/components/nfandroidtv/notify.py
|
||||
homeassistant/components/nibe_heatpump/__init__.py
|
||||
|
|
|
@ -24,7 +24,7 @@ from homeassistant.helpers import config_validation as cv, entity_registry as er
|
|||
from .const import DOMAIN
|
||||
from .coordinator import NextcloudDataUpdateCoordinator
|
||||
|
||||
PLATFORMS = (Platform.SENSOR, Platform.BINARY_SENSOR)
|
||||
PLATFORMS = (Platform.SENSOR, Platform.BINARY_SENSOR, Platform.UPDATE)
|
||||
|
||||
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
|
||||
|
||||
|
@ -52,7 +52,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
entry.data[CONF_URL],
|
||||
entry.data[CONF_USERNAME],
|
||||
entry.data[CONF_PASSWORD],
|
||||
entry.data[CONF_VERIFY_SSL],
|
||||
verify_ssl=entry.data[CONF_VERIFY_SSL],
|
||||
skip_update=False,
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/nextcloud",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": ["nextcloudmonitor==1.4.0"]
|
||||
"requirements": ["nextcloudmonitor==1.5.0"]
|
||||
}
|
||||
|
|
51
homeassistant/components/nextcloud/update.py
Normal file
51
homeassistant/components/nextcloud/update.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
"""Update data from Nextcoud."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.update import UpdateEntity, UpdateEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import NextcloudDataUpdateCoordinator
|
||||
from .entity import NextcloudEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up the Nextcloud update entity."""
|
||||
coordinator: NextcloudDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
if coordinator.data.get("update_available") is None:
|
||||
return
|
||||
async_add_entities(
|
||||
[
|
||||
NextcloudUpdateSensor(
|
||||
coordinator, entry, UpdateEntityDescription(key="update")
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class NextcloudUpdateSensor(NextcloudEntity, UpdateEntity):
|
||||
"""Represents a Nextcloud update entity."""
|
||||
|
||||
@property
|
||||
def installed_version(self) -> str | None:
|
||||
"""Version installed and in use."""
|
||||
return self.coordinator.data.get("system_version")
|
||||
|
||||
@property
|
||||
def latest_version(self) -> str | None:
|
||||
"""Latest version available for install."""
|
||||
return self.coordinator.data.get(
|
||||
"update_available_version", self.installed_version
|
||||
)
|
||||
|
||||
@property
|
||||
def release_url(self) -> str | None:
|
||||
"""URL to the full release notes of the latest version available."""
|
||||
if self.latest_version:
|
||||
ver = "-".join(self.latest_version.split(".")[:3])
|
||||
return f"https://nextcloud.com/changelog/#{ver}"
|
||||
return None
|
|
@ -1352,7 +1352,7 @@ neurio==0.3.1
|
|||
nexia==2.0.8
|
||||
|
||||
# homeassistant.components.nextcloud
|
||||
nextcloudmonitor==1.4.0
|
||||
nextcloudmonitor==1.5.0
|
||||
|
||||
# homeassistant.components.discord
|
||||
nextcord==2.0.0a8
|
||||
|
|
|
@ -1076,7 +1076,7 @@ nettigo-air-monitor==2.2.2
|
|||
nexia==2.0.8
|
||||
|
||||
# homeassistant.components.nextcloud
|
||||
nextcloudmonitor==1.4.0
|
||||
nextcloudmonitor==1.5.0
|
||||
|
||||
# homeassistant.components.discord
|
||||
nextcord==2.0.0a8
|
||||
|
|
Loading…
Add table
Reference in a new issue