Mushroom Entity Card - Tap_action based upon entity state, help needed

Good morning,
I’m trying to edit my Mushroom Entity cards for window blinds, and I’m running into several issues.

Specifically I am using iBlinds v3.1 z-wave motors, which have recently updated to the recently integrated Window Covering. This is causing some issues in what Mushroom cards (entity or cover) is expecting (as well as the now native Tile cards, which are very similar to mushroom). Clicking on the icons renders failures, because now instead of a binary or multi-level switch (blind_class), which is what the iBlinds used to show up as, the only actionable entry the horizontal_slats_angle (window_class). I’m told from the manufacturer that the blind class is meant for roller blinds, so closed is at one end of the range, open is at the other. With the window class, you have two closed targets (0 and 100), and open is at 50, or really anywhere in between 0 and 100. The window class updates the entries immediately, which was often a problem when having two types of switches in the blind class.

Developer tools for blind class

Developer tools for window class

In any case, this new class is causing headaches. I’ve been able to work my way through a lot of the problems, and really it functions almost as normal. I’m not thrilled with the only control option as being a slider, but it works.

The last headache I’m working through is the tap option for the entity. What I’ve come up with for the icon tap is a single tap calls a service (cover.open_cover_tilt) and a double tap cover.set_cover_tilt_position to tilt_position: 100

    entity: cover.office_blind_left_horizontal_slats_angle
    tap_action:
      action: call-service
      service: cover.set_cover_tilt_position
      target:
        device_id: ca026520264bf08069085d96b0346575
      data:
        tilt_position: 100

    double_tap_action:
      action: call-service
      service: cover.open_cover_tilt
      target:
        device_id: ca026520264bf08069085d96b0346575
      data: {}

What I’d like to do is have a single entry for tap action, so it changes based upon the state of the entity. Unfortunately, as you see in the screen shot above, the Window Class shows a state of unknown. This appears to be a bug which I’ve reported to the manufacturer, who is in contact with the ZWaveJS and HA developers, and they’ve told me they’ll bring it to their attention. This is also likely what causes some of the issues when I try to use entity or cover cards and click on the icon, as it doesn’t know the state of the cover.

I’m able to display the correct state and what percentage the blinds are open by using some if statements and variables based upon the horizontal_slats_angle/current_tilt_position. I’m wondering if I can do something similar to call the the above tap actions, based on the state_attr below.

    secondary: >-
      {% if state_attr('cover.office_blind_left_horizontal_slats_angle',
      'current_tilt_position') == 100  %}
        Closed (down inside)
      {% elif state_attr('cover.office_blind_left_horizontal_slats_angle',
      'current_tilt_position') == 0  %}
        Closed (up inside)      
      {% else %}
        Open - {{ state_attr('cover.office_blind_left_horizontal_slats_angle','current_tilt_position') -1 }}%
      {% endif %}
    icon: >
      {% set c = state_attr('cover.office_blind_left_horizontal_slats_angle',
      'current_tilt_position') |int(0) %} {{ 'phu:blind-tilt-open' if 100 > c >
      0 else 'phu:blind-tilt-closed' }}
    icon_color: >
      {% set c = state_attr('cover.office_blind_left_horizontal_slats_angle',
      'current_tilt_position') |int(0) %} {{ 'blue' if 100 > c > 0 else 'grey'
      }}

I really appreciate any help that anyone can provide.

More information:
I tried just using the variable statement I had used in the icon and icon color to set the tilt position data, but it is throwing an error.

    tap_action:
      action: call-service
      service: cover.set_cover_tilt_position
      target:
        device_id: ca026520264bf08069085d96b0346575
      data: >
        {% set c = state_attr('cover.office_blind_left_horizontal_slats_angle', 'current_tilt_position') |int(0) %} {{ 'tilt_position: 100' if 100 > c > 0 else 'tilt_position: 50' }}

You cannot template the tap action in a Mushroom Card.

Yeah, that’s what I was just reading. I have to figure out another way unfortunately.

Either you switch to another card that supports templating, or you create a script and call it in your tap action:


alias: set cover tilt position
sequence:
  - service: cover.set_cover_tilt_position
    data:
      tilt_position: |
        {% set c = state_attr('cover.office_blind_left_horizontal_slats_angle', 'current_tilt_position') |int(0) %}
        {{ '100' if 100 > c > 0 else '50' }}
    target:
      entity_id: cover.office_blind_left_horizontal_slats_angle

1 Like

It’s probably going to need to be a script. I haven’t found a card that plays nice with the new window class. They all throw errors with just basic GUI driven setups, let alone templating. I’m sure it’s only a matter of time until these issues are resolved, but for now it’s messing up my dashboards. I’ve already opened an issue on the lovelace-mushroom github page, as well as contacting iBlinds support, who is actively working with the ZWaveJS and HA developers. They were the ones pushing for the device class to be implemented in Home Assistant, so hopefully they’ll get all the wrinkles ironed out.