custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

tap action behaviour different between Web browser & Companion app #749

Closed migueldc73 closed 1 year ago

migueldc73 commented 1 year ago

I have implemented embedded buttons through custom fields:

Custom Button bug

type: custom:button-card
theme: Mushroom
name: Zwembad Cover
entity: cover.pool_cover
show_icon: true
show_state: true
size: 40px
styles:
  custom_fields:
    open:
      - position: absolute
      - left: 70%
      - top: 5%
      - height: 100px
      - width: 100px
    stop:
      - position: absolute
      - left: 70%
      - top: 35%
      - height: 100px
      - width: 100px
    close:
      - position: absolute
      - left: 70%
      - top: 65%
      - height: 00px
      - width: 100px
custom_fields:
  open:
    card:
      type: custom:button-card
      theme: Mushroom
      name: Open
      tap_action:
        action: call-service
        service: cover.open_cover
        data:
          entity_id: cover.pool_cover
  stop:
    card:
      type: custom:button-card
      theme: Mushroom
      name: Stop
      tap_action:
        action: call-service
        service: cover.stop_cover
        data:
          entity_id: cover.pool_cover
  close:
    card:
      type: custom:button-card
      theme: Mushroom
      name: Close
      confirmation:
        text: Please check nobody is in the pool before closing
      tap_action:
        action: call-service
        service: cover.close_cover
        data:
          entity_id: cover.pool_cover

This works perfectly well in the Companion App. When I click on Open, Stop or Close, it calls the appropriate service

But in the Web browser, I get the error message : "Failed to call service cover/open_cover. must contain at least one of entity_id, device_id, area_id

Mariusthvdb commented 1 year ago

thats odd.. I just tested this:

tap_action:
  action: call-service
  service: >
    [[[ return entity.state == 'open'
          ? 'cover.close_cover' : 'cover.open_cover'; ]]]
  data:
    entity_id: entity
  confirmation:
    text: Alle rolluiken togglen?

and it works just fine.

could you test it with the entity and see what happens?

RomRider commented 1 year ago

But in the Web browser, I get the error message : \"Failed to call service cover/open_cover. must contain at least one of entity_id, device_id, area_id

That's a browser caching issue. Your browser is still using the old version while the companion app is using the new one.

migueldc73 commented 1 year ago

It's actually the other way around. My web browser cache was clean, but not the one from my companion app. Now it also does not work on the companion app.

Even this simple custom button which turns a group of lights off when doing a hold action, does not work anymore, while it did yesterday:

type: custom:button-card
theme: Mushroom
name: Gelijkvloers
show_icon: false
show_state: false
styles:
  card:
    - height: 50px
  grid:
    - position: relative
  custom_fields:
    notification:
      - background-color: |
          [[[
            if (states['sensor.light_group_gelijkvloers'].state == 0)
              return "var(--background-color)";
            return "orange";
          ]]]
      - border-radius: 50%
      - position: absolute
      - left: 85%
      - top: '-50%'
      - height: 30px
      - width: 30px
      - font-size: 18px
      - line-height: 30px
custom_fields:
  notification: |
    [[[ 
      if (states['sensor.light_group_gelijkvloers'].state > 0)
      return states['sensor.light_group_gelijkvloers'].state 
    ]]]
tap_action:
  action: navigate
  navigation_path: /overview-with-icons-for-phone/gelijkvloers
hold_action:
  action: call-service
  service: light.turn_off
  target:
    entity_id: light.group_gelijkvloers

I have the impression something is broken in my HASS config. Or my custom button. This is really weird !

migueldc73 commented 1 year ago

So, I went back to a full backup of the previous day, re-implemented my custom button cards and it now all works as predicted.

My guess is that I installed or removed an important library while fiddling and that somehow broke the custom button card behaviours (other cards still worked fine)

Can't stress the importance of regular backups !!