#My msg is above if it didn't reply to

1 messages · Page 1 of 1 (latest)

worn cliff
#

Can you post a screenshot of what it looks like?

cyan cosmos
#

I've been messign around with it but..

  - type: horizontal-stack
    cards:
      - type: entities
        title: Bedroom
        entities:
          - type: custom:button-card
            entity: cover.blinds_bed
            icon: mdi:blinds-open
            name: Open
            show_name: true
            show_state: false
            tap_action:
              action: call-service
              service: cover.set_cover_position
              service_data:
                entity_id: cover.blinds_bed
                position: 99
            styles:
              icon:
                - color: white
            state:
              - operator: template
                value: >
                  [[[ return
                  states['cover.blinds_bed'].attributes.current_position ===
                  99;]]]
                styles:
                  icon:
                    - color: orange
          - type: custom:button-card
            entity: cover.blinds_bed
            icon: mdi:blinds
            name: Closed
            show_name: true
            show_state: false
            tap_action:
              action: call-service
              service: cover.set_cover_position
              service_data:
                entity_id: cover.blinds_bed
                position: 1
            styles:
              icon:
                - color: white
            state:
              - operator: template
                value: >
                  [[[ return
                  states['cover.blinds_bed'].attributes.current_position === 1;
                  ]]]
                styles:
                  icon:
                    - color: orange
worn cliff
#

I'm assuming ultimately you want to be able to do all of this in one card, correct?

cyan cosmos
#

Yeah, I'm really trying to just have a simple open/closed button that doesn't take up a huge chunk of the dashboard

worn cliff
#

Okay. I'm going to take your code that you posted above and see what I can come up with. I think you're on the right track with using the state:. Really, you should be able to combine those two cards pretty easily. Then it is just a matter of getting the tap_action to work properly.

#

Secondary question: Do you have more the one set of blinds that you want to be able to control via HA? (That will affect the design that I have in mind to make it easier to scale to more entities if needed.)

cyan cosmos
#

Thanks! And yeah I have two sets of blinds that follow the same template, the stack looks like:

worn cliff
#

This is what I have so far. (This will not work for you yet, but it shows being combined into a single card. Also, note the entity variable being used which references the entity defined in the card at Line 2.) ```yaml
type: custom:button-card
entity: cover.living_room_window
show_name: true
show_state: false
tap_action:
action: call-service
service: cover.set_cover_position
service_data:
entity_id: cover.living_room_window
position: 99
state:

  • operator: template
    value: >
    [[[ return entity.attributes.current_position > 1]]]
    name: Open
    icon: mdi:blinds-open
    styles:
    icon:
    - color: white
  • operator: template
    value: >
    [[[ return entity.attributes.current_position <= 1 ]]]
    name: Closed
    icon: mdi:blinds
    styles:
    icon:
    - color: orange```
#

I also changed the template values. If the current_position is 1 or less, it is closed; otherwise, it is open.

#

First test for my theory seems to work. yaml service_data: entity_id: '[[[ return entity.entity_id ]]]' position: '[[[ return 70 ]]]'

worn cliff
#

I got it working based what I think you want. Take a look at this and see what you think. I added a variables section so the entities can be defined in one spot without having to do it multiple times. It does need an input_boolean (toggle) helper. I would suggest calling it something like input_boolean.blinds_bed_toggle. Double tapping will toggle the input boolean (but I have not incorporated any way to be able to see its setting yet.) There's an option to set the cover position via an entity but it is not incorporated into the code yet. You mentioned a slider at one point but not sure how you are wanting to use it.

#
type: custom:button-card
variables:
  cover_entity: cover.living_room_window
  cover_toggle: input_boolean.tester
  cover_position: input_number.temp_helper
entity: '[[[ return variables.cover_entity ]]]'
tap_action:
  action: call-service
  service: cover.set_cover_position
  service_data:
    entity_id: '[[[ return entity.entity_id ]]]'
    position: |
      [[[ 
        if (entity.attributes.current_position == 0) {
          return (states[variables.cover_toggle].state == "on") ? 20 : 70 
        } else {
          return 0
        }
      ]]]
double_tap_action:
  action: call-service
  service: homeassistant.toggle
  service_data:
    entity_id: '[[[ return variables.cover_toggle ]]]'
state:
  - operator: template
    value: >
      [[[ return entity.attributes.current_position > 1]]]
    name: |
      [[[ return "Open @ " + entity.attributes.current_position + "%" ]]]
    icon: mdi:blinds-open
    styles:
      icon:
        - color: white
  - operator: template
    value: >
      [[[ return entity.attributes.current_position <= 1 ]]]
    name: Closed
    icon: mdi:blinds
    styles:
      icon:
        - color: orange
styles:
  custom_fields:
    cover_toggle:
      - position: absolute
      - right: 2%
      - top: 5%
      - transform: rotate(270deg)
      - opacity: 50%
custom_fields:
  cover_toggle:
    card:
      type: custom:button-card
      entity: '[[[ return variables.cover_toggle ]]]'
      show_name: false
      state:
        - icon: mdi:toggle-switch
          value: 'on'
          color: green
        - icon: mdi:toggle-switch-off
          value: 'off'
          color: red
      size: 50px
      tap_action:
        action: toggle
      styles:
        card:
          - height: 50px
          - width: 50px
          - background-color: transparent
          - border: none
#

You could use something like this. This example shows two different type of toggles being used. One is a custom:button-card and the other is an entities card that has been card-modded to only show the toggle.

#

You could have an "indicator dot". Here, I use the dot to show the battery level on a motion sensor.

cyan cosmos
#

The living room light toggle is what I'm ultimately looking for! And that's able to be setup such that the toggle applies two distinct cover positions? That's example is uysing the custom button card?

worn cliff
#

I've updated the code above. Just add from styles: down and you should be good. Currently, double tapping the entire button card will toggle in input_boolean; tapping the toggle button will also do the same. You can change these options as you see fit. The two positions the card will move to are hard-coded at 20 and 70 which is defined in Line 15. (Cover-position options can be added if you want such as the input_number being referenced instead of 70 (or 20), for example. Or, using two entities, you could adjust both independently.

cyan cosmos
#

Had got caught up with work but ive since implemented this and it's working as intended. It's a much nicer look! Thank you!