AnthonMS / my-cards

Bundle of my custom Lovelace cards for Home Assistant. Includes: my-slider, my-slider-v2, my-button
Other
104 stars 27 forks source link

[Bug]: Max does not work #60

Open briodan opened 1 month ago

briodan commented 1 month ago

Current Behavior

when setting the max option in the card config, the card allows the value to be set higher then max value.

Expected Behavior

when sliding up i expect the value to stop at what was set under the max setting. in my case TV volume can not be set above 20.

Steps To Reproduce

add the following card code

type: custom:my-slider-v2
entity: media_player.living_room_tv_2
vertical: true
styles:
  card:
    - height: 182px
    - width: 110px
  min: 1
  max: 20
  showMin: true
  disableScroll: true
layout_options:
  grid_columns: 1
  grid_rows: 3

slide volume and observe setting change on the device

Environment

- OS: HAOS 12.1
- Node:
- Version: current
- Hassio: 2024.9.3

Anything else?

No response

AnthonMS commented 1 month ago

I haven't tested if it is because of this, but pretty sure it because you set the min and max in the styles. You need to put those config keys in the root of the slider config. The same is true with the showMin and disableScroll. You should only add css styling inside the styles key. So your example should look like:

type: custom:my-slider-v2
entity: media_player.living_room_tv_2
vertical: true
min: 1
max: 20
showMin: true
disableScroll: true
styles:
  card:
    - height: 182px
    - width: 110px
layout_options:
  grid_columns: 1
  grid_rows: 3

Let me know if this works so we can close the issue. If not, then I will try to find some time to look at it soon.

Jonny-T-cyber commented 1 week ago

Hi, this solution seems to work only if the card is in the "normal" yaml flow of the page. But it no longer works if I open the card in a popup with browser_mod. In this case, while maintaining the directions you gave, the max does not lock at the level set in the code.

I specify that this anomaly occurs only for the MAX value and not for the MIN... There is that a reason?

_Off-topic: I anticipate that there are other anomalies with "my-card.js" that you can already see in yellow color in the image I am about to provide you. For which I will open a specific issue. (I have verified that these additional anomalies always occur, even without using browsermod)

Anyway, returning to the topic, an error appears on the page and, moreover, in the console it reads:

connection-mixin.ts:156 Uncaught (in promise) 
{code: 'invalid_format', message: 'Invalid value for input_number.slider_intensity: 6.0 (range 1.0 - 5.0)'}
code
: 
"invalid_format"
message
: 
"Invalid value for input_number.slider_intensity: 6.0 (range 1.0 - 5.0)"

image

Thanks for the support