thomasloven / lovelace-state-switch

🔹Dynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

Feature Request: Add useragent as a template variable (like custom header) or as a separate entity #37

Closed rccoleman closed 2 years ago

rccoleman commented 4 years ago

I would like to choose a different card configuration for desktop and mobile and it seems like I can currently only achieve that by calling out individual DeviceIDs. I can pull out the relevant card configs into separate files and include it for each device, but it's not a very scalable solution, and using a template based on useragent would be much more convenient. Custom Header makes the useragent available as a Jinja variable for use in templates, and something like that would be very useful here.

If there's a better/more elegant way to handle this, please let me know.

rccoleman commented 4 years ago

I ended up adding a new user ("Mobile") and logging into that on my mobile devices, so that lets me switch the card stack without having to call out each device ID. I don't know if using a different user will make trouble down the road when I want to keep both users configurations in sync, but it will work for now. Being able to switch on some portion of the useragent would be a better solution, IMHO.

thomasloven commented 2 years ago

https://github.com/thomasloven/lovelace-state-switch#mediaquery