Nerwyn/service-call-tile-feature

Slider no longer showing up

wirecuttr opened this issue · 7 comments

Checklist:

  • [ Y] I updated to the latest version available
  • [ Y] I cleared the cache of my browser

Release with the issue:
3.1.7

Last working release (if known):

Browser and Operating System:
Android/Companion app
Windows/Edge
Windows/Chrome

Description of problem:

I had this card with a slider and some buttons working fine in an earlier release:
#3 (comment)
Things were working back in Nov/2023 when this issue 3 was closed
I'm not sure when the slide disappear unfortunately. Any idea?
Javascript errors shown in the web inspector (if applicable):

Your Full Remote Config

Shortening the card to just the slide also doesn't fix things

features:
  - type: custom:service-call
    entries:
      - type: slider
        icon: mdi:ev-station
        service: emporia_vue.set_charger_current
        target:
          entity_id:
            - switch.ev_charger
        range:
          - 6
          - 48
        step: 1
        value_attribute: charging_rate
        thumb: default
        label: ATTRIBUTE[charging_rate] A
        data:
          current: VALUE
type: tile
entity: switch.ev_charger
icon_tap_action:
  action: toggle
icon: mdi:ev-station

yields:
image

Additional information:

Did you recently update? The latest release was almost a month ago so it would be weird if the issue were to suddenly appear. I also see you're still using the obsolete string interpolation system for the label. It should now be '{{ state_attr("switch.ev_charger", "charging_rate") }}' with unit_of_measurement: A.

It looks like it's failing here because it's expecting entity ID to be a string instead of an array. I should fix that.

@wirecuttr can you try the latest alpha? It should fix this.

It's not a new problem. I'm just getting around to logging the issue.

with 3.1.8-alpha.002 the slider shows up, but not correctly:
image

In terms of changing the label format I tried this:

features:
  - type: custom:service-call
    entries:
      - type: slider
        icon: mdi:ev-station
        service: emporia_vue.set_charger_current
        target:
          entity_id:
            - switch.ev_charger
        range:
          - 6
          - 48
        step: 1
        value_attribute: charging_rate
        thumb: default
        label: {{ state_attr("switch.ev_charger", "charging_rate") }}
        unit_of_measurement: A
        data:
          current: VALUE
type: tile
entity: switch.ev_charger
icon_tap_action:
  action: toggle
icon: mdi:ev-station

yields this error:
image

You have to put single quotes around the template.

You have to put single quotes around the template.

Ah. Thanks for your help!
This is working:

features:
  - type: custom:service-call
    entries:
      - type: slider
        icon: mdi:ev-station
        service: emporia_vue.set_charger_current
        target:
          entity_id: switch.ev_charger
        range:
          - 6
          - 48
        step: 1
        value_attribute: charging_rate
        thumb: default
        label: '{{ state_attr("switch.ev_charger", "charging_rate") }}'
        unit_of_measurement: A
        data:
          current: VALUE
type: tile
entity: switch.ev_charger
icon_tap_action:
  action: toggle
icon: mdi:ev-station

Is it possible to alter the color of the slider based on the attribute value?
I'm trying this, but it's not working:

          color: |
            {% if {{state_attr("switch.ev_charger", "charging_rate")}} > 30 %}
              red
            {% else %}
              blue
            {% endif %}

The slider is just grey
image

You have an extra set of brackets within the if statement, and should be using --color instead of color.

--color: |
  {% if state_attr("switch.ev_charger", "charging_rate") > 30 %}
    red
  {% else %}
    blue
  {% endif %}

Fixed in 3.1.8