thomasloven / lovelace-state-switch

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

FR: add useragent as entity option #76

Open Mariusthvdb opened 2 years ago

Mariusthvdb commented 2 years ago

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

which would be awesome because allowing switching based on browser type. Use case: trying to show a view and /or cards based on the user agent of the Chrome browser, which is the only one that can Cast.

if we could use

type: custom:state-switch
entity: useragent
states:
# [Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15]
  "safari":
    type: markdown
    content: >
      This can not show type:cast
# [Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 
  "chrome":
    type: markdown
    content: >
      This browser can Cast
# Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0
  "firefox":
    type: markdown
    content: >
      This can not show type:cast

Ive filed a FR( in the HA Frontend repo for the view option based on hide_if_unavailable: true but that has been unanswered. Second best thing would be showing a card based on that, or based on user agent.