tmonck / clean_up_snapshots Goto Github PK
View Code? Open in Web Editor NEWService to clean up your home assistant snapshots, so you don't manually have to.
Service to clean up your home assistant snapshots, so you don't manually have to.
In 2023.5.4, using latest version of the service:
This error originated from a custom integration.
Logger: custom_components.clean_up_snapshots_service
Source: helpers/config_validation.py:863
Integration: Clean up snapshots service (documentation, issues)
First occurred: 18:17:38 (1 occurrences)
Last logged: 18:17:38
The 'clean_up_snapshots_service' option near /config/configuration.yaml:1 is deprecated, please remove it from your configuration```
<Integration tmonck/clean_up_snapshots> Could not read manifest.json [Expecting ',' delimiter: line 7 column 23 (char 222)]
with last addon version.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/ci.yml
actions/checkout v4
actions/setup-python v5
actions/checkout v4
actions/setup-python v5
irongut/CodeCoverageSummary v1.3.0
actions/checkout v4
actions/checkout v4
.github/workflows/labels_sync.yml
actions/checkout v4
micnncim/action-label-syncer v1
.github/workflows/release-drafter.yml
release-drafter/release-drafter v6.0.0
.github/workflows/release.yml
actions/checkout v4
requirements.test.txt
Hi,
I am getting errors while trying to execute automation:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 431, in action await script_obj.async_run(variables, context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 151, in async_run await self._handle_action(action, variables, context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 235, in _handle_action await self._actions[_determine_action(action)](action, variables, context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 318, in _async_call_service context=context, File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 98, in async_call_from_config domain, service_name, service_data, blocking=blocking, context=context File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service await handler.func(service_call) File "/config/custom_components/clean_up_snapshots_service/__init__.py", line 105, in async_handle_clean_up for snapshot in snapshots: TypeError: 'NoneType' object is not iterable
I manually installed this integration (don't use HACS, just copying the custom_component folder), so perhaps this issue is self-inflicted. But, I figured I would ask here is these errors I'm seeing in my logs make any sense and if there is an easy fix or not.
I've upgraded recently to the latest version (0.8.2) and see the following in my logs upon a restart:
Logger: homeassistant.helpers.integration_platform
Source: loader.py:535
First occurred: 12:03:13 PM (5 occurrences)
Last logged: 12:03:13 PM
Unexpected error importing clean_up_snapshots_service/recorder.py
Unexpected error importing clean_up_snapshots_service/group.py
Unexpected error importing clean_up_snapshots_service/media_source.py
Unexpected error importing clean_up_snapshots_service/system_health.py
Unexpected error importing clean_up_snapshots_service/logbook.py
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/integration_platform.py", line 33, in _process
platform = integration.get_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 530, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 535, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.clean_backups.recorder'
The clean_up_snapshots_service works as expected and I don't any errors while calling the service. Just curious if there is a way I could clean these up in my logs?
Describe the bug
Warning in Home Assistant 2021.12
Detected integration that called async_timeout.timeout with loop keyword argument.
The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2.
Please report issue to the custom component author for clean_up_snapshots_service using this method at
custom_components/clean_up_snapshots_service/__init__.py, line 47: with async_timeout.timeout(10, loop=hass.loop):
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No warning errors
Log
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:94
Getting this warning:
2021-04-08 21:10:54 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'clean_up_snapshots_service'. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of 'clean_up_snapshots_service'
Hi,
On v0.4, I got an error when i call the service to cleanup snapshots and the snapshots are still there.
I reverted back to 0.3, which works great for me. I use node-red to call the service at 01:00 am, so i only noticed it the next day.
I don’t mind to update it again and send you logs if you want to take a look at the error.
Thanks
Hi,
Thanks for writing this add-on. The backups location has changed in the latest Home Assistant, I'm currently on:
Home Assistant 2022.12.1
Supervisor 2022.11.2
Operating System 9.3
Frontend 20221208.0 - latest
The backups dir is now /backup
not /backups
, and so the add-on does nothing when running.
| | | | /\ (_) | | | |
| |__| | ___ _ __ ___ ___ / \ ___ ___ _ ___| |_ __ _ _ __ | |_
| __ |/ _ \| '_ \ _ \ / _ \ / /\ \ / __/ __| / __| __/ _\ | '_ \| __|
| | | | (_) | | | | | | __/ / ____ \\__ \__ \ \__ \ || (_| | | | | |_
|_| |_|\___/|_| |_| |_|\___| /_/ \_\___/___/_|___/\__\__,_|_| |_|\__|
Welcome to the Home Assistant command line.
System information
IPv4 addresses for eth0: <REMOVED>
IPv6 addresses for eth0: <REMOVED>
IPv4 addresses for wlan0:
OS Version: Home Assistant OS 9.3
Home Assistant Core: 2022.12.1
Home Assistant URL: http://homeassistant.local:8123
Observer URL: http://homeassistant.local:4357
➜ ~
➜ ~ find / -name 'backup*' -type d
/backup
This is not configurable, but maybe it should be just in case this changes again.
Thanks,
In relation to this:
https://developers.home-assistant.io/blog/2021/08/24/supervisor_update/
It appears to be causing an issue now. Perhaps the old /snapshots has now been deleted?
When trying to use this extension I'm getting the following error:
2020-12-26 23:41:55 INFO (MainThread) [custom_components.clean_up_snapshots_service] Attempting to remove snapshot: slug=slug_value
2020-12-26 23:41:55 ERROR (MainThread) [custom_components.clean_up_snapshots_service] Client error on calling delete snapshot
Traceback (most recent call last):
File "/config/custom_components/clean_up_snapshots_service/__init__.py", line 69, in async_remove_snapshots
resp = await session.post(hassio_url + 'snapshots/' + snapshot['slug'] + "/remove", headers=headers, ssl=shouldVerifySsl(hassio_url))
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 632, in _request
resp.raise_for_status()
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1002, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('http://hassio.beachi:8123/api/hassio/snapshots/slug_value/remove')
Running hassio install with Home Assistant 2020.12.1
Let me know if you need anymore info.
Script will find the slugs now and count correctly. When attempting to delete a slug I am seeing a 404 error:
2022-04-17 11:28:59 INFO (MainThread) [custom_components.clean_up_snapshots_service] Stale Snapshots: [{'slug': '8c3be962', 'name': 'DailyBackup: Sunday, April 10, 2022', 'date': '2022-04-10T13:40:39.048521+00:00', 'type': 'full', 'size': 1931.49, 'protected': False, 'compressed': True, 'content': {'homeassistant': True, 'addons': ['core_samba', 'core_letsencrypt', 'a0d7b954_appdaemon', 'a0d7b954_bitwarden', 'a0d7b954_esphome', 'core_configurator', 'a0d7b954_vscode', 'core_zwave_js', 'a0d7b954_portainer', 'a0d7b954_spotify', 'a0d7b954_logviewer', 'a0d7b954_motioneye', 'core_check_config', 'a0d7b954_example', 'local_vlc', 'a0d7b954_nodered', 'a0d7b954_tor', 'a0d7b954_adguard', 'a0d7b954_influxdb', 'a0d7b954_grafana', 'a0d7b954_glances', 'core_mariadb', 'a0d7b954_phpmyadmin', 'core_mosquitto'], 'folders': ['share', 'addons/local', 'ssl', 'media']}}]
2022-04-17 11:28:59 INFO (MainThread) [custom_components.clean_up_snapshots_service] Attempting to remove snapshot: slug=8c3be962
2022-04-17 11:28:59 ERROR (MainThread) [custom_components.clean_up_snapshots_service] Client error on calling delete snapshot
Traceback (most recent call last):
File "/config/custom_components/clean_up_snapshots_service/init.py", line 70, in async_remove_snapshots
resp = await session.post(hassio_url + f"{BACKUPS_URL_PATH}/" + snapshot['slug'] + "/remove", headers=headers, ssl=shouldVerifySsl(hassio_url))
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 640, in _request
resp.raise_for_status()
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://xxxxxxxxxxxxxx.com:8123/api/hassio/backups/8c3be962/remove')
Need to update this integration for ConfigFlow. I want to make sure existing integrations are migrated to the ConfigFlow and announce that the configuration.yaml support will be removed in a future release.
Integration tries to connect to hass over https even if the provided url specifies http.
Example:
host: http://hassio:8123
I believe the wrong logic is in:
https://github.com/tmonck/clean_up_snapshots/blob/master/custom_components/clean_backups/__init__.py#L92
The current logic means that if a hostname is used then ssl is forced. What was the original intention? Why differentiate between hostname and ip configurations in terms of ssl? Why not let the scheme alone determine the protocol?
A workaround right now is to specify the host using an IP.
P.S. nowhere does it say, nor there is an example, that the project will not work if "host" has a slash at the end. Would be preferred if it is specified, or if there is an example or if the code can work with both cases.
Currently the service that is added is call clean_up_snapshots_service
this was inline with the name of the entity it was cleaning when the code was originally written. The name of entity is now Backups and the path to the entity is /backups
. The service should be updated to have a more concise name which doesn't include the word snapshots
,
Thanks, everything works perfect
Shows up in my log:
homeassistant.packages.cleanup.clean_up_snapshots_service: - Package cleanup setup failed. Component clean_up_snapshots_service No module named 'dateutil' - clean_up_snapshots_service:
Hi, the integration stopped working. According to other API issues I've seen across the internet, it looks like it's since 2023.3.3 and going back to 2023.3.1 fixes the issue. Apparently it's related to long-lived tokens. Might be related to #89919
The current values in the configuration.yaml
file are not being properly imported, causing the UI to show 0 as the desired backups to retain.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.