matches data automatically inserted into lovelace raw editor
lockyt opened this issue · 7 comments
Hi @postlund. Thanks for making a great search bar - just what I was looking for.
However, I seem to be having a problem. I have added the following to the badges section on the lovelace configuration:
- max_results: 10
type: 'custom:search-card'
When I save it, it works just fine, giving me a search bar along the very top of the screen where I can search etc no problems.
However, when I go back into the raw config editor, it has changed it to this:
- max_results: 10
type: 'custom:search-card'
actions:
- &ref_0
matches: '^((magnet:.*)|(.*.torrent.*))$'
name: Add to Transmission
icon: 'mdi:progress-download'
service: transmission.add_torrent
service_data:
torrent: '{1}'
- *ref_0
and if I save and go back into the editor again, it appends even more of the same each time:
- max_results: 10
type: 'custom:search-card'
actions:
- &ref_0
matches: '^((magnet:.*)|(.*.torrent.*))$'
name: Add to Transmission
icon: 'mdi:progress-download'
service: transmission.add_torrent
service_data:
torrent: '{1}'
- *ref_0
- *ref_0
- matches: '^((magnet:.*)|(.*.torrent.*))$'
name: Add to Transmission
icon: 'mdi:progress-download'
service: transmission.add_torrent
service_data:
torrent: '{1}'
The appended data doesn't stop it working but it obviously is doing something strange. Seems like a bug as I don't even have a torrent integration. Any ideas as to why it keeps doing it? Perhaps cause it is in the badges section? I wanted to have it in the badges section to be at the very top and full width of the screen.
Looking forward to hearing from you.
Thanks.
Sorry just one thing I noticed, it works in edit mode on lovelace (not raw config, just the first step) and when I close edit it works, but if I refresh the screen, I lose the search bar.
Hi @postlund - just to let you know I managed to properly organise my Lovelace using the layoutcard.js plugin and fixed it by not using the badges section. I guess it is not designed to work in badges so all good. Apologies if I was just being a gumby.
Thanks anyway.
Yeah, I have never tested it as a badge. Interesting idea though. There seems to be a bug with saving actions though, will have to look at that.
@postlund The problem appears to be due to the following code:
this.config.actions = BUILTIN_ACTIONS.concat(this.config.actions || []);
Since this is concatenating the built-in actions to the actions property of the config object, this is causing them to be written every time the config is saved. If you want the built-in actions to be used without appearing in the config when editing you could potentially change it to this:
this.actions = BUILTIN_ACTIONS.concat(this.config.actions || []);
and then use this.actions
in place of this.config.actions
in the other parts of the code.
@gadgetchnnel You are right as it seems. I'm making this exact change as part of fixing #17, so hopefully this problem will go away now.
Note: 131 days have passed, and I'm not seeing this. Time to close?
Agree!