Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assistance with javascript conditional #38

Open
muddro1 opened this issue Jan 23, 2025 · 0 comments
Open

Assistance with javascript conditional #38

muddro1 opened this issue Jan 23, 2025 · 0 comments

Comments

@muddro1
Copy link

muddro1 commented Jan 23, 2025

Hoping someone with better skills than me can assist. I am trying to make a reusable bubble card that works for my main use cases lights and fans). I am trying to creates a styles portion of a bubble card that is conditional on the entity being a fan so that way i can have the rotating fan icon when an item is on. I am a bit stuck on how to make that work:

    default:
      - type: slider
    card:
      type: custom:bubble-card
      card_type: button
      entity: '[[entity]]'
      scrolling_effect: false
      icon: '[[icon]]'
      button_type: '[[type]]'
      tap_action:
        action: toggle
      double_tap_action:
        action: more-info
      hold_action:
        action: more-info
      styles_javascript: |2-
          .bubble-icon {
            animation: ${hass.states['[[entity]]'].state === 'on' ? 'slow-rotate 2s linear infinite' : ''};
          }
          @keyframes slow-rotate {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
          }

I havent modified the styles section aside from adding _javascript and [[entity]] to the condition from whats provided on thebubble cards repo. Any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant