đŸ”č state-switch - conditional card on steroids

Ah! Thank you for the tip. I used ‘stack-in-card’ and it worked.

      'c5cfe6f8-e92c2008':
        type: custom:stack-in-card
        title: Testing State Switch
        mode: vertical
        keep: 
          background : true
        cards:
          - type: markdown
            <<: *mark_anchor2
          - type: light
            entity: light.hallway_bulb
          - type: markdown
            <<: *mark_anchor1
          - type: markdown
            content: >
              NewLaptop2

Screen Shot 2020-08-02 at 11.51.24 AM

Love the card, thanks again for all these.

not sure if this is possible.

I have a dropdown, which has 3 options
Office, Living Room, Kitchen.

input_select:
  room_temp_display:
    name: Display Room Temp Info
    options:
      - Office
      - Living
      - Kitchen
    initial: Jamie

I want to “link” these values, to an “average"sensor:
So " ‘Average Temp - Living Room’” linked to the drop down “Living”
and ‘Average Temp - Jamie Office’ linked to “office”

## HACS: https://github.com/Limych/ha-average
  - platform: average
    name: 'Average Temp - Living Room'
    entities:
      - sensor.living_room_button_st
      - sensor.living_room_window_st_dz_temp
      - sensor.living_room_temperature_tracker

  - platform: average
    name: 'Average Temp - Jamie Office'
    entities:
      - sensor.jamie_office_motion_hue_dz
      - sensor.jamie_office_door_st_dz
      - sensor.jamie_office_temperature_tracker

Then, with the values, i want to use that for the graph card:

color_thresholds:
  - color: '#f39c12'
    value: 20
  - color: '#d35400'
    value: 25
  - color: '#c0392b'
    value: 30
entities:
  - sensor.average_temp_jamie_office
hours_to_show: 168
name: Jamie Office Average Temp - Past Week
show:
  average: true
  extrema: true
  labels: true
type: 'custom:mini-graph-card'

is it possible to somehow link what you selected in the “input select” to the entity used for the graph card.
or do i need to just copy and paste the graph code (15x) for each room in the house?
seems like a load to load up, if thats the case

type: vertical-stack
cards:
  - type: entities
    title: Select Room
    entities:
      - entity: input_select.room_temp_display
  - type: 'custom:state-switch'
    entity: input_select.room_temp_display
    states:
      Jamie:
        color_thresholds:
          - color: '#f39c12'
            value: 20
          - color: '#d35400'
            value: 25
          - color: '#c0392b'
            value: 30
        entities:
          - sensor.average_temp_jamie_office
        hours_to_show: 168
        name: Jamie Office Average Temp - Past Week
        show:
          average: true
          extrema: true
          labels: true
        type: 'custom:mini-graph-card'
      Living:
        type: glance
        title: Lights
        entities:
          - light.livingroom_all

Try using a template: https://github.com/thomasloven/lovelace-state-switch#template

Thanks! if i have 15 rooms, i would need to have all 15 graphs coded in, then the template would pick which one to call?

Sorry, I didn’t read your question closely enough.

You will need one graph card for each graph, but you can probably make heavy use of node anchors to keep the line count down (in yaml mode).

nice! thanks for the quick reply. Just trying to see if i can get it working via the other card suggested first, if not, will try this!

any luck figuring out what’s going on here?

trying my luck with state-switch, to display a button depending on which Lovelace dashboard I am on. Closest I could find in the current available options would be a css media rule using the media query parameter, but dont think I can create a template using

window.location.pathname

?
this would be awesome if possible:

Schermafbeelding 2020-09-01 om 23.27.37 and allow for some nifty display tricks.

Anyone can help me realize this? If not possible in the current available options, Thomas, would this be something you could and would add?

considered using the template option, but don’t think the window.location.pathname is available in Jinja?

like this (and yes I know this isn’t correct, but I hope it illustrates what I am after):

type: custom:state-switch
entity: template
template: "{% if window.location.pathname == '/ui-settings/time_settings' %} day {% else %} night {% endif %}"
states:
  day:
    type: markdown
    content: Where do you want to go today?
  night:
    type: markdown
    content: Sleep tight!

thanks for considering

edit

been able to do this in custom:button-card with below code:

      - type: custom:button-card
        template: button_shortcut_menu
        icon: >
          [[[ return (window.location.pathname.split('/')[1] == 'ui-settings')
              ? 'mdi:remote-desktop' : 'mdi:flash'; ]]]
        tap_action:
          action: navigate
          navigation_path: >
            [[[ return (window.location.pathname.split('/')[1] == 'ui-settings')
              ? '/ui-settings/developer' : '/ui-data/home_energy'; ]]]
        variables:
          path: >
            [[[ return (window.location.pathname.split('/')[1] == 'ui-settings')
              ? 'developer' : 'home_energy'; ]]]

which is alright, but quite laborious. A state-switch could do this more efficiently?

found an issue, which I am not sure is a bug or a feature


showing a button-card based on the state of a binary_sensor, which is checking the state of a sensor, sensor.saver_trash_today, see the ‘off’ conditioned card, being none or not. If not, (the sensor exists) it should show the button, using the sensor for entity.

If indeed none, and the binary_sensor (problem) is on, it should show a button card with a entity_picture. translates to:

type: custom:state-switch
entity: binary_sensor.saver_offline
states:
  'on':
    type: custom:button-card
    aspect_ratio: 1/1
    show_entity_picture: true
    entity_picture: /local/afvalwijzer/kringloop.png
    hold_action:
      action: navigate
      navigation_path: tijd_agenda

  'off':
    type: custom:button-card
    entity: sensor.saver_trash_today
    aspect_ratio: 1/1
    show_icon: false
    show_name: false
    show_label: true
    tap_action:
      action: more-info
    hold_action:
      action: navigate
      navigation_path: tijd_agenda
     etc etc etc

however, this is in the inspector:

button-card.js?v=3.3.6:1643 ButtonCardJSTemplateError: TypeError: Cannot read property 'state' of undefined in 'if (states['sensor.saver_trash_tomorrow'].state == 'Geen') return `url("${entity.attributes.entity...'
    at HTMLElement.eval (eval at _evalTemplate

which seems to indicate, the state_switch doesn’t prevent the button (that shouldn’t be displayed) from being considered by the system.

Is this to be expected? I would have thought, the binary being ‘on’, it state_switch would only make the ‘on’ card to be considered

thanks for having a look

Hi, can someone help me build a simple setup please?, I completely don’t understand how to do it. All I need is 4 buttons at the top and each of them will open a new card with entities, lights etc. It will be nice to have some effect as well.

Hi,

Looking to do something similar but without going the button-card route. Did anybody manage something like this?

like what?

Sorry for the confusion. I’m looking to display content (in my case an image element on a picture-elements card) based on the navigation_path or window.location.pathname.

not really sure what you are trying to do with the day and night here, but I don’t think the window.location.pathname is available to jinja templates (which is serverside backend). It is used in the javascript templates, and really a browser side frontend thing.

Unless state-switch has access to the path in one way or another, this wont go. You might be able to try the #hash option:


but I havent tried that myself yet.

Hi all,

How to make buttons like image

@thomasloven

Thanks for the work on this. I needed to disable buttons for an irrigation process for about 10 seconds and this worked out perfect.

irrigationgif

Have you read through the readme and attempted to put together any code?

Sir, thank you so much for sharing this. It worked for me.
Sir i have one requirement.
Whenever a switch or light is turned on or off, i need to inform the owner on his iphone.
I was wondering when an entity shows up/or leaves this conditional card, how can i use the state and entity name to be displayed as a notification?

Thanks for another great card. Finally I was able to achieve some kind of satisfying layout. It uses other great custom cards and layouts, but without making it too complex I created an interface that emulates a windows 10 desktop. I would be nice to have an option for up-down slide (or down-up slide).

Check out Lovelace: Swiper card