Describe the bug
When sliding the slide you sometimes get an error:
Failed to call service light/turn_on. Expected int for dictionary value @ data['brightness']
To Reproduce
Steps to reproduce the behavior:
Create a button for a light with type slider.
Slide the slider a couple of times.
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Desktop:
OS: macOS
Browser: Brave (Chromium 120)
Version [e.g. 1.6.2]
Additional context
I've checked the debugger and it seems like it is caused by a divide by zero in updateRange.
function updateRange(x) {
const rect = rangeSlider.getBoundingClientRect();
const position = Math.min(Math.max(x - rect.left, 0), rect.width);
const percentage = position / rect.width;
if (entityId.startsWith("light.")) {
brightness = Math.round(percentage * 255);
} else if (entityId.startsWith("media_player.")) {
volume = percentage;
}
rangeFill.style.transition = 'none';
rangeFill.style.transform = `translateX(${percentage * 100}%)`;
}
Describe the bug When sliding the slide you sometimes get an error:
Failed to call service light/turn_on. Expected int for dictionary value @ data['brightness']
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Desktop:
Additional context I've checked the debugger and it seems like it is caused by a divide by zero in
updateRange
.https://github.com/Clooos/Bubble-Card/blob/main/src/cards/button.ts#L250
I don't know why sometimes the rangeSlider is 0 in every dimension.