thomasloven / lovelace-state-switch

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

Card does not appear when dashboard is shown #119

Open CoryAlbrecht opened 1 month ago

CoryAlbrecht commented 1 month ago

In a web browser (Chrome, Ubuntu) the card does not appear when the dashboard is loaded but will appear on a manual page refresh (e.g. Ctrl+R). If you go to another tab on the same dashboard and return, it is gone again and you have to refresh to get it back.

In the companion app (Samsung Galaxy Tab S6 Lite, Google Pixel 8) the card does not appear and the app cannot be refreshed by swiping down.

I have multiple cards like this to show if there are any active alarms or timers on any of the Google/Nest Minis throughout my home, and they all act like this.

type: custom:state-switch
entity: >-
  {% set nt = state_attr('sensor.bathroom_mini_alarms', 'alarms')|count %} {% if
  (nt >= 1) and (nt <= 3) %}
    {{state_attr('sensor.bathroom_mini_alarms', 'alarms')|count}}
  {% elif nt >= 4 %}3{% endif %}
tap_action:
  action: more-info
states:
  '1':
    type: custom:timer-bar-card
    name: Active Alarms
    entities:
      - entity: sensor.bathroom_mini_alarm_1
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_1
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_1
                  alarm_device: sensor.bathroom_mini_alarms
              styles:
                button:
                  margin: 0px 0px 0px 8px
  '2':
    type: custom:timer-bar-card
    name: Active Alarms
    entities:
      - entity: sensor.bathroom_mini_alarm_1
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_1
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_1
                  alarm_device: sensor.bathroom_mini_alarms
              styles:
                button:
                  margin: 0px 0px 0px 8px
      - entity: sensor.bathroom_mini_alarm_2
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_2
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_2
                  alarm_device: sensor.bathroom_mini_alarms
              styles:
                button:
                  margin: 0px 0px 0px 8px
  '3':
    type: custom:timer-bar-card
    name: Active Alarms
    entities:
      - entity: sensor.bathroom_mini_alarm_1
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_1
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_1
                  alarm_device: sensor.bathroom_mini_alarms
              styles:
                button:
                  margin: 0px 0px 0px 8px
      - entity: sensor.bathroom_mini_alarm_2
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_2
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_2
                  alarm_device: sensor.bathroom_mini_alarms
              styles:
                button:
                  margin: 0px 0px 0px 8px
      - entity: sensor.bathroom_mini_alarm_3
        extend_paper_buttons_row:
          position: right
          entity: sensor.bathroom_mini_alarm_3
          buttons:
            - layout: icon
              icon: mdi:delete
              tap_action:
                confirmation:
                  text: Do you want to delete the alarm? (Cannot be undone.)
                action: call-service
                service: script.delete_google_home_alarm
                service_data:
                  alarm_id: sensor.bathroom_mini_alarm_3
                  alarm_device: sensor.bathroom_mini_alarms
                styles: null
                button:
                  margin: 0px 0px 0px 8px
ildar170975 commented 1 month ago

You have plenty of custom cards inside state-switch - and yet open an issue for state-switch... Suggest to replace inner cards with simple stock cards & re-test.

CoryAlbrecht commented 1 month ago

117 #118

CoryAlbrecht commented 1 month ago

You have plenty of custom cards inside state-switch - and yet open an issue for state-switch... Suggest to replace inner cards with simple stock cards & re-test.

It makes no difference with only standard cards.

ildar170975 commented 1 month ago

It makes no difference with only standard cards.

Try to understand that people who will look at your problem (plugin author, other volunteers) may want to reproduce your issue. That is why it is CUSTOMARY to post a MINIMAL code which demonstrates the problem, not a >100 lines code with custom stuff.

mrgrlscz commented 1 week ago

I have a similar problem on my config... my card do not show at first load, i have to refresh manually (sometimes several times) i tried with stock cards: here's the code:

type: custom:state-switch
entity: input_boolean.test
states:
  'on':
    type: entities
    entities:
      - sun.sun
  'off':
    type: entities
    entities:
      - sun.sun
      - sun.sun
      - sun.sun
parautenbach commented 1 day ago

Set a default – see the docs.

zSprawl commented 17 hours ago

Set a default – see the docs.

This fixed the issue perfectly. Thanks!

parautenbach commented 10 hours ago

Cool, I ran into the same issue after my HA upgrade.