{"id":13585563,"url":"https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver","last_synced_at":"2025-04-07T10:31:12.696Z","repository":{"id":49948876,"uuid":"271398374","full_name":"PiotrMachowski/Home-Assistant-custom-components-Saver","owner":"PiotrMachowski","description":"This custom component allows you to save current state of any entity and use its data later to restore it.","archived":false,"fork":false,"pushed_at":"2023-09-30T21:12:14.000Z","size":38,"stargazers_count":61,"open_issues_count":3,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-02T16:01:32.999Z","etag":null,"topics":["automation","helper","home-assistant","save","script","variable"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiotrMachowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"ko_fi":"piotrmachowski","custom":["buycoffee.to/piotrmachowski","paypal.me/PiMachowski","revolut.me/314ma"]}},"created_at":"2020-06-10T22:26:28.000Z","updated_at":"2024-06-15T17:46:10.000Z","dependencies_parsed_at":"2023-01-30T19:35:19.073Z","dependency_job_id":"472fb5dc-9d98-4663-8ca7-d612ab445d5d","html_url":"https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrMachowski%2FHome-Assistant-custom-components-Saver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrMachowski%2FHome-Assistant-custom-components-Saver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrMachowski%2FHome-Assistant-custom-components-Saver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrMachowski%2FHome-Assistant-custom-components-Saver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiotrMachowski","download_url":"https://codeload.github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223277958,"owners_count":17118691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","helper","home-assistant","save","script","variable"],"created_at":"2024-08-01T15:05:00.998Z","updated_at":"2025-04-07T10:31:12.689Z","avatar_url":"https://github.com/PiotrMachowski.png","language":"Python","funding_links":["https://ko-fi.com/piotrmachowski","buycoffee.to/piotrmachowski","paypal.me/PiMachowski","revolut.me/314ma","https://ko-fi.com/piotrmachowski'","https://paypal.me/PiMachowski","https://www.buymeacoffee.com/PiotrMachowski"],"categories":["Python"],"sub_categories":[],"readme":"[![HACS Default][hacs_shield]][hacs]\n[![GitHub Latest Release][releases_shield]][latest_release]\n[![GitHub All Releases][downloads_total_shield]][releases]\n[![Community Forum][community_forum_shield]][community_forum]\u003c!-- piotrmachowski_support_badges_start --\u003e\n[![Ko-Fi][ko_fi_shield]][ko_fi]\n[![buycoffee.to][buycoffee_to_shield]][buycoffee_to]\n[![PayPal.Me][paypal_me_shield]][paypal_me]\n[![Revolut.Me][revolut_me_shield]][revolut_me]\n\u003c!-- piotrmachowski_support_badges_end --\u003e\n\n\n[hacs_shield]: https://img.shields.io/static/v1.svg?label=HACS\u0026message=Default\u0026style=popout\u0026color=green\u0026labelColor=41bdf5\u0026logo=HomeAssistantCommunityStore\u0026logoColor=white\n[hacs]: https://hacs.xyz/docs/default_repositories\n\n[latest_release]: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/releases/latest\n[releases_shield]: https://img.shields.io/github/release/PiotrMachowski/Home-Assistant-custom-components-Saver.svg?style=popout\n\n[releases]: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/releases\n[downloads_total_shield]: https://img.shields.io/github/downloads/PiotrMachowski/Home-Assistant-custom-components-Saver/total\n\n[community_forum_shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Forum\u0026style=popout\u0026color=41bdf5\u0026logo=HomeAssistant\u0026logoColor=white\n[community_forum]: https://community.home-assistant.io/t/custom-component-saver/204249\n\n\n# Saver\n\nThis custom component allows you to save current state of any entity and use its data later to restore it.\n\nAdditionally, you can create simple variables and use their values in scripts.\n\n## Installation\n\n### Using [HACS](https://hacs.xyz/) (recommended)\n\n[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=PiotrMachowski\u0026repository=Home-Assistant-custom-components-Saver\u0026category=Integration)\n\nThis integration can be installed using HACS.\nTo do it search for `Saver` in *Integrations* section.\n\n### Manual\n\nTo install this integration manually you have to download [*saver.zip*](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/releases/latest/download/saver.zip) and extract its contents to `config/custom_components/saver` directory:\n```bash\nmkdir -p custom_components/saver\ncd custom_components/saver\nwget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/releases/latest/download/saver.zip\nunzip saver.zip\nrm saver.zip\n```\n\n## Configuration\n\n### Using UI\n\n[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=saver)\n\nFrom the Home Assistant front page go to **Configuration** and then select **Integrations** from the list.\n\nUse the \"plus\" button in the bottom right to add a new integration called **Saver**.\n\nThe success dialog will appear or an error will be displayed in the popup.\n\n### YAML\n\nAdd following code in configuration.yaml:\n```yaml\nsaver:\n```\n\n## Available services\n\n### Save state\nSaves the state and parameters of the entity.\n```yaml\nservice: saver.save_state\ndata:\n  entity_id: cover.living_room\n```\n\n### Delete saved state\nDeletes a saved state for an entity.\n```yaml\nservice: saver.delete\ndata:\n  entity_id: cover.living_room\n```\n\n### Set variable\nSets the value to the variable.\n```yaml\nservice: saver.set_variable\ndata:\n  name: counter\n  value: 3\n```\n\n### Delete variable\nDeletes a saved variable.\n```yaml\nservice: saver.delete_variable\ndata:\n  name: counter\n```\n\n### Clear\nDeletes all saved data.\n```yaml\nservice: saver.clear\n```\n\n### Deprecated services\n\n\u003cdetails\u003e\n\u003csummary\u003eShow\u003c/summary\u003e\n\n\n#### Restore state\nExecutes the script using saved state of the entity.\n\nTo use state of an entity you have to use a following value in a template: `state`.\n\nTo use state attribute (in this case `current_position`) of an entity you have to use a following value in a template: `attr_current_position`.\n\n```yaml\nservice: saver.restore_state\ndata:\n  entity_id: cover.living_room\n  restore_script:\n    - service: cover.set_cover_position\n      data_template:\n        entity_id: cover.living_room\n        position: \"{{ '{{ attr_current_position | int }}' }}\"\n    - service: input_text.set_value\n      data_template:\n        entity_id: input_text.cover_description\n        value: \"Cover is now {{ '{{ state }}' }}\"\n```\n\n#### Execute script\nExecutes a script using all saved entities and variables.\n\nTo use state of an entity (in this case `cover.living_room`) you have to use a following value in a template: `cover_living_room_state`.\n\nTo use state attribute (in this case `current_position`) of an entity you have to use a following value in a template: `cover_living_room_attr_current_position`.\n\n```yaml\nservice: saver.execute\ndata:\n  script:\n    - service: cover.set_cover_position\n      data_template:\n        entity_id: cover.living_room\n        position: \"{{ '{{ cover_living_room_attr_current_position | int }}' }}\"\n    - service: input_text.set_value\n      data_template:\n        entity_id: input_text.cover_description\n        value: \"Cover is now {{ '{{ cover_living_room_state }}' }}\"\n    - service: input_text.set_value\n      data_template:\n        entity_id: input_text.counter_description\n        value: \"Counter has value {{ '{{ counter }}' }}\"\n```\n\n\n\u003c/details\u003e\n\n\n## Using saved values in templates\nIt is possible to use saved data in templates using `saver_entity` and `saver_variable` functions:\n```yaml\n{{ saver_entity(\"sun.sun\") }}  # returns saved state of \"sun.sun\" entity\n{{ saver_entity(\"sun.sun\", \"azimuth\") }}  # returns \"azimuth\" attribute of saved \"sun.sun\" entity\n{{ saver_variable(\"counter\") }}  # returns saved variable \"counter\"\n```\n\n## Events\n\nAfter the completion of the services mentioned before, the following events are fired:\n\n| **Service Function** | **Event ID**                 | **Provided Arguments** |\n|----------------------|------------------------------|------------------------|\n| **execute**          | event_saver_executed         | script                 |\n| **save_state**       | event_saver_saved_entity     | entity_id              |\n| **restore_state**    | event_saver_restored         | entity_id              |\n| **delete**           | event_saver_deleted_entity   | entity_id              |\n| **clear**            | event_saver_cleared          |                        |\n| **set_variable**     | event_saver_saved_variable   | variable, value        |\n| **delete_variable**  | event_saver_deleted_variable | variable               |\n\nThe events can be used to trigger further automations that depend on the completion of the services. The documentation is provided [here](https://www.home-assistant.io/docs/automation/trigger/#event-trigger). \n\n\n\u003c!-- piotrmachowski_support_links_start --\u003e\n\n## Support\n\nIf you want to support my work with a donation you can use one of the following platforms:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003ePlatform\u003c/th\u003e\n    \u003cth\u003ePayment methods\u003c/th\u003e\n    \u003cth\u003eLink\u003c/th\u003e\n    \u003cth\u003eComment\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eKo-fi\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003ePayPal\u003c/li\u003e\n      \u003cli\u003eCredit card\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href='https://ko-fi.com/piotrmachowski' target='_blank'\u003e\u003cimg height='35px' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003eNo fees\u003c/li\u003e\n      \u003cli\u003eSingle or monthly payment\u003c/li\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ebuycoffee.to\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003eBLIK\u003c/li\u003e\n      \u003cli\u003eBank transfer\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://buycoffee.to/piotrmachowski\" target=\"_blank\"\u003e\u003cimg src=\"https://buycoffee.to/btn/buycoffeeto-btn-primary.svg\" height=\"35px\" alt=\"Postaw mi kawę na buycoffee.to\"\u003e\u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ePayPal\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003ePayPal\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://paypal.me/PiMachowski\" target=\"_blank\"\u003e\u003cimg src=\"https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg\" border=\"0\" alt=\"PayPal Logo\" height=\"35px\" style=\"height: auto !important;width: auto !important;\"\u003e\u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003eNo fees\u003c/li\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eRevolut\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003eRevolut\u003c/li\u003e\n      \u003cli\u003eCredit Card\u003c/li\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://revolut.me/314ma\" target=\"_blank\"\u003e\u003cimg src=\"https://assets.revolut.com/assets/favicons/favicon-32x32.png\" height=\"32px\" alt=\"Revolut\"\u003e\u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003cli\u003eNo fees\u003c/li\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### Powered by\n[![PyCharm logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport)\n\n\n[ko_fi_shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Ko-Fi\u0026color=F16061\u0026logo=ko-fi\u0026logoColor=white\n\n[ko_fi]: https://ko-fi.com/piotrmachowski\n\n[buycoffee_to_shield]: https://shields.io/badge/buycoffee.to-white?style=flat\u0026labelColor=white\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw1AUhU9TpaIVh1YQcchQnayIijhKFYtgobQVWnUweemP0KQhSXFxFFwLDv4sVh1cnHV1cBUEwR8QVxcnRRcp8b6k0CLGC4/3cd49h/fuA4R6malmxzigapaRisfEbG5FDLzChxB6MIZ+iZl6Ir2QgWd93VM31V2UZ3n3/Vm9St5kgE8knmW6YRGvE09vWjrnfeIwK0kK8TnxqEEXJH7kuuzyG+eiwwLPDBuZ1BxxmFgstrHcxqxkqMRTxBFF1ShfyLqscN7irJarrHlP/sJgXltOc53WEOJYRAJJiJBRxQbKsBClXSPFRIrOYx7+QcefJJdMrg0wcsyjAhWS4wf/g9+zNQuTE25SMAZ0vtj2xzAQ2AUaNdv+PrbtxgngfwautJa/UgdmPkmvtbTIEdC3DVxctzR5D7jcAQaedMmQHMlPSygUgPcz+qYcELoFulfduTXPcfoAZGhWSzfAwSEwUqTsNY93d7XP7d+e5vx+AIahcq//o+yoAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5wETCy4vFNqLzwAAAVpJREFUOMvd0rFLVXEYxvHPOedKJnKJhrDLuUFREULE7YDCMYj+AydpsCWiaKu29hZxiP4Al4aWwC1EdFI4Q3hqEmkIBI8ZChWXKNLLvS0/Qcza84V3enm/7/s878t/HxGkeTaIGziP+EB918nawu7Dq1d0e1+2J2bepnk2jFEUVVF+qKV51o9neBCaugfge70keoxxUbSWjrQ+4SUyzKZ5NlnDZdzGG7w4DIh+dtZEFntDA98l8S0MYwctNGrYz9WqKJePFLq80g5Sr+EHlnATp+NA+4qLaZ7FfzMrzbMBjGEdq8GrJMZnvAvFC/8wfAwjWMQ8XmMzaW9sdevNRgd3MFhvNpbaG1u/Dk2/hOc4gadVUa7Um425qii/7Z+xH9O4jwW8Cqv24Tru4hyeVEU588cfBMgpPMI9nMFe0BkFzVOYrYqycyQgQJLwTC2cDZCPeF8V5Y7jGb8BUpRicy7OU5MAAAAASUVORK5CYII=\n\n[buycoffee_to]: https://buycoffee.to/piotrmachowski\n\n[buy_me_a_coffee_shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Buy%20me%20a%20coffee\u0026color=6f4e37\u0026logo=buy%20me%20a%20coffee\u0026logoColor=white\n\n[buy_me_a_coffee]: https://www.buymeacoffee.com/PiotrMachowski\n\n[paypal_me_shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=PayPal.Me\u0026logo=paypal\n\n[paypal_me]: https://paypal.me/PiMachowski\n\n[revolut_me_shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Revolut\u0026logo=revolut\n\n[revolut_me]: https://revolut.me/314ma\n\u003c!-- piotrmachowski_support_links_end --\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPiotrMachowski%2FHome-Assistant-custom-components-Saver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPiotrMachowski%2FHome-Assistant-custom-components-Saver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPiotrMachowski%2FHome-Assistant-custom-components-Saver/lists"}