hass-swipe-navigation
hass-swipe-navigation copied to clipboard
Implement custom swipe actions
-- Work in progress --
I have started to allow specifying the exact tab index when swiping. This allow more customizations for the user.
It would allow the user to swipe from tab 10 to tab 1 in one swipe.
I'm having trouble loading the configuration, and would need some help, the rest should work fine.
A view has two additional configurations:
{
swipe_back_index: string | number | null | undefined;
swipe_forward_index: string | number | null | undefined;
}
string
: is a path to a tab
number
: is the index of a tab
null
: disables swipe
undefined
: default behaviour (prev/next tab accordingly)
Thank you very much for your contribution. I surely can help.
The main thing to discuss here is whether to:
- Put the custom swipe configuration at the same level of the current config
- In this case the user needs a way to specify which tab refers to each custom-swipe config.
- The advantage is that we have all the config in one place. The disadvantage is that the user needs to remember to update the config when changing tab paths.
- Put the custom swipe configuration at the same level of the "view"s configuration.
- Advantage is that "related things are near" (views and view-specific swipe config), but the configuration is now split across the file. This is both inconvenient and I guess it would also be harder to code.
What's your opinion?
P.S. I'm trying to adhere to conventional commits. I would appreciate if you could try to follow it principles. Have a look at it or try to mimic my commit messages looking at the history. 😊
The code is working now. Both by setting the global configuration and by view. The global overrides the view config.
I don't have time to write tests for this feature or fix any bugs. Feel free to edit the code as you likings.
Thank you very much! I'll take it from here if you don't have time.
Thank you. Just want to mention thats is possible to specify tab by index or path.
I dont know how this works by the built in lovelace? I'm using UI Minimalist.
Really looking forward to this being implemented! Googled this issue and found this PR.
Thanks @NewsGuyTor! I have been running this PR for over a month and it works great.
I think the missing piece for this PR to get merged is to add the documentation for this feature. Currently I don't have time to write it myself. Feel free to do it if you have the time.
We need to rebase everything but there will be a lot of conflicts. I'm thinking about rewriting this, taking huge inspiration from this PR. I'll add Albin in the commit as co-author as well as in the changelog. However, I'm a bit busy currently but It's on the roadmap with top priority.
Hi all. So, this enhancement would be the best software enhancement known to man kind, so many use cases for the swipe back and forward view index option. I see the branch is still pending and there may be a desire to rewrite. Any way we could get this feature without the rewrite? ;-)
Any way we could get this feature without the rewrite? ;-)
No, I don't think so. Problem is that the PR works, but I need to make it stable and future-proof. Since this new feature requires users to change the configuration manually, I need to think of a good config structure in order to leave room for later improvements and actions.
For example, I could allow for arbitrary js execution, not only navigation. But in order to do this I need to sit down and think carefully because once you create the structure it's not very elegant to change it with a breaking change down the road and ask users to comply.
I'm currently busy with work but I haven't forgotten this PR. =) Hang on tight.
Hi all. I'm okay with using the PR version until we get the refactored version. I'm okay if it breaks in the next release, I'll make the needed changes. So, I'm not a javascript developer, how can I convert the ts file to js when loading as a resource in HA? Any help really appreciated. ;)
You can have a look at https://github.com/zanna-37/hass-swipe-navigation/blob/main/CONTRIBUTING.md#build or https://github.com/zanna-37/hass-swipe-navigation/blob/main/.github/workflows/build-on-release.yml.
If you don't know what I'm talking about, I discourage you to continue without having a deeper understanding. However, if you're feeling lucky just run scripts/build.sh
, you should find the compiled file on dist/swipe-navigation.js
.
You can have a look at https://github.com/zanna-37/hass-swipe-navigation/blob/main/CONTRIBUTING.md#build or https://github.com/zanna-37/hass-swipe-navigation/blob/main/.github/workflows/build-on-release.yml.
If you don't know what I'm talking about, I discourage you to continue without having a deeper understanding. However, if you're feeling lucky just run
scripts/build.sh
, you should find the compiled file ondist/swipe-navigation.js
.
Thanks for helping me. I was able to compile the file using the docker method, then took the swipe-navigation.js file from the dist folder, copied it to my-ha-config/www/community/hass-swipe-navigation. I then restart HA and cleared my frontend cache in the iOS companion app, loaded the dashboard, no luck, it did not work. I added "swipe_back_index: security" and it did not honor the path. Below is the structure I used. Any advice?
- title: '' path: security-detail swipe_back_index: security type: custom:vertical-layout badges: [] cards:
Have a look at https://community.home-assistant.io/t/hacs-card-install-wont-update-with-local-code-changes/314328.
Just checking in here. How long do you think it will be before we can use this super awesome feature? :-)