thomasloven / lovelace-state-switch

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

Multiple history graph cards not showing #41

Open clau-bucur opened 3 years ago

clau-bucur commented 3 years ago

I have two states and in each I define a History Graph Card, but the graph shows only in the first state.

I found a similar issue described in the HA community thread, where they said that adding a transition, fixes the problem. Indeed, that fixes it, but I don't want to use transitions.

First state: image

Second state, where graph not visible: image

The code:

- type: custom:state-switch
  entity: hash
  default: scheduler_living
  states:
    scheduler_living:
      type: vertical-stack
      style: "ha-card { height: 100%; }"
      cards:
        - type: horizontal-stack
          cards:
            - type: custom:button-card
              layout: icon_name
              name: Living
              icon: mdi:sofa
              tap_action:
                action: navigate
                navigation_path: '#scheduler_living'
              styles:
                card:
                  - --mdc-ripple-color: var(--accent-color)
                  - --mdc-ripple-press-opacity: 0.5
                icon:
                  - height: 25px
                name:
                  - color: var(--accent-color)

            - type: custom:button-card
              layout: icon_name
              name: Dormitor
              icon: mdi:bed
              styles:
                icon:
                  - height: 25px
                card:
                  - --mdc-ripple-color: var(--accent-color)
                  - --mdc-ripple-press-opacity: 0.5
              tap_action:
                action: navigate
                navigation_path: '#scheduler_bedroom'

        - type: custom:stack-in-card
          cards:
            - type: horizontal-stack
              cards:
                - type: custom:decluttering-card
                  template: climate_template
                  variables:
                    - label: Living
                    - climate_entity: climate.living
                    - temperature_entity: sensor.mi_temperature_living
                    - humidity_entity: sensor.mi_humidity_living
                    - extra_entity1: sensor.heat_pump_energy_power
                    - extra_entity1_icon: mdi:pump

                - type: custom:stack-in-card
                  cards:
                    - type: entities
                      show_header_toggle: false
                      entities:
                        - entity: switch.central_heating
                          name: Centrala termică
                          secondary_info: last-changed
                        - entity: switch.heat_pump
                          name: Încălzire pardoseală
                          secondary_info: last-changed

                    - type: custom:scheduler-card
                      title: false
                      time_step: 1
                      discover_existing: false
                      include:
                        - climate.living
                      display_options:
                        primary_info:
                          - "{entity}: {action} {relative-time}"
                        secondary_info:
                          - "{days} {time}"
                          - additional-tasks

            - type: history-graph
              entities:
                - sensor.mi_temperature_living
              hours_to_show: 48
              refresh_interval: 60

    scheduler_bedroom:
      type: vertical-stack
      style: "ha-card { height: 100%; }"
      cards:
        - type: horizontal-stack
          cards:
            - type: custom:button-card
              layout: icon_name
              name: Living
              icon: mdi:sofa
              tap_action:
                action: navigate
                navigation_path: '#scheduler_living'
              styles:
                card:
                  - --mdc-ripple-color: var(--accent-color)
                  - --mdc-ripple-press-opacity: 0.5
                icon:
                  - height: 25px

            - type: custom:button-card
              layout: icon_name
              name: Dormitor
              icon: mdi:bed
              styles:
                icon:
                  - height: 25px
                card:
                  - --mdc-ripple-color: var(--accent-color)
                  - --mdc-ripple-press-opacity: 0.5
                name:
                  - color: var(--accent-color)
              tap_action:
                action: navigate
                navigation_path: '#scheduler_bedroom'

        - type: custom:stack-in-card
          cards:
            - type: horizontal-stack
              cards:
                - type: custom:decluttering-card
                  template: climate_template
                  variables:
                    - label: Bedroom
                    - climate_entity: climate.bedroom
                    - temperature_entity: sensor.mi_temperature_bedroom
                    - humidity_entity: sensor.mi_humidity_bedroom
                    - toggle_entity: input_boolean.climate_master_bedroom

                - type: custom:stack-in-card
                  cards:
                    - type: entities
                      show_header_toggle: false
                      entities:
                        - entity: switch.central_heating
                          name: Centrala termică
                          secondary_info: last-changed
                        - entity: switch.upstairs_heating_circuit
                          name: Încălzire etaj
                          secondary_info: last-changed

                    - type: custom:scheduler-card
                      title: false
                      time_step: 1
                      discover_existing: false
                      include:
                        - climate.bedroom
                      display_options:
                        primary_info:
                          - "{entity}: {action} {relative-time}"
                        secondary_info:
                          - "{days} {time}"
                          - additional-tasks

            - type: history-graph
              entities:
                - sensor.mi_temperature_bedroom
              hours_to_show: 48
              refresh_interval: 60
bcutter commented 3 years ago

Copy that. Same problem, only with history-graph. Won´t show up at all after being not shown. Doesn´t matter if it´s [1] grafik or [2] grafik

Workaround to use a transition seems to work though.

Update 1: It´s not... not reliably. So this is a real issue without any sufficient workaround :-(

Update 2: Using a transition works for history-graph type [2] but not for type [1]...!

Update 3: Using a transition works for history-graph type [2] only if switch-card is directly applied to the history-graph (and this might result in a malformed mobile view, see https://github.com/thomasloven/lovelace-state-switch/issues/52 !), it doesn´t work for a group of history-graphs (e. g. 3) stacked in a 'custom:vertical-stack-in-card'.

Update 4: Added new side effect/issue https://github.com/thomasloven/lovelace-state-switch/issues/52.

thomasloven commented 2 years ago

Please try release 1.9.0

bcutter commented 2 years ago

Please try release 1.9.0

I tested and referring to https://github.com/thomasloven/lovelace-state-switch/issues/41#issuecomment-841715875 I can say:

thomasloven commented 2 years ago

Please try release 1.9.3

bcutter commented 2 years ago

For me v1.9.3 fixed the remaining issue (using a group of history-cards inside a vertical-stack-in-card inside a state-switch-card). What about yours @clau-bucur ?