Bubble-Card icon indicating copy to clipboard operation
Bubble-Card copied to clipboard

Slider does not update for brightness if adjusted outside of the card after being adjusted in the card

Open StaleLoafOfBread opened this issue 7 months ago • 8 comments
trafficstars

Describe the bug
Slider does not update for brightness if adjusted outside of the card after being adjusted in the card

To Reproduce
Steps to reproduce the behavior:

  1. Create a button slider card attached to a light
  2. Adjust the brightness via the card
  3. Adjust the brightness outside of the card
  4. Observe that the slider does not update

Expected behavior
The slider should update. In my screenshot the slider should fill up the bar. This expected behavior does occur if you do not adjust the brightness via the card before adjusting outside of the card.

Screenshots

Image

YAML
If applicable, add any relevant YAML code.

Your code here

Informations (please complete the following information):

  • OS: [e.g. iOS]
  • Browser/App: [e.g. chrome, safari]
  • Bubble Card version: v2.5.0-beta.9
  • Home Assistant version: [e.g. 2024.6.4]

Additional context
Add any other context about the problem here.

Thank you! 🍻

StaleLoafOfBread avatar Mar 27 '25 04:03 StaleLoafOfBread

Hi and thank again for the feedback! I will check that!

Clooos avatar Mar 28 '25 15:03 Clooos

@StaleLoafOfBread does the value update if you keep moving the mouse outside the card?

I'm not really able to reproduce it the way it's described, but it's very possible that it's related to this fix: https://github.com/Clooos/Bubble-Card/pull/1395

Basically, if you have live updates on, you move the mouse (e.g. outside the card) and stop the mouse movement, the value will not update, as the last mouse move updates are throttled and the value does not update.

AlexDaniel avatar Apr 14 '25 00:04 AlexDaniel

@AlexDaniel By "outside of the card" I meant adjusting it not via the card but rather another card, service call, automation, etc. Additional info below:

  1. Create a button slider card attached to a light
type: custom:bubble-card
card_type: button
modules:
  - default
button_type: slider
entity: light.living_room

  1. Adjust the light's brightness via the card

Image

  1. Adjust the brightness not via the card

Image

  1. Observe how the the card's visuals for the brightness did not update.

StaleLoafOfBread avatar Apr 14 '25 01:04 StaleLoafOfBread

Ahhhh, you're right! Sorry for not getting it right away. I was able to reproduce it, will take a look later.

AlexDaniel avatar Apr 14 '25 02:04 AlexDaniel

OK, the fix for lights is right here: https://github.com/Clooos/Bubble-Card/pull/1400 I'm a bit confused with the difference between last_changed and last_updated, and how it affects other usages of the slider, so I don't know if there are any downsides to that fix.

AlexDaniel avatar Apr 14 '25 19:04 AlexDaniel

@AlexDaniel Funnily enough, I am the one who added last_updated support in https://github.com/Clooos/Bubble-Card/pull/1289 as an attribute (unrelated to the slider code).

That PR has more info that might help clear up the differences but basically last_changed is when the value actually changed last but last_updated is when the value was last refreshed. Sometimes, sensors will recheck their values and the value is the same as it was before. This would cause last_updated to change but not last_changed.

For example, lets say you had a sensor whose value is the current hour. Let's assume this sensor checks the current hour every minute. That sensor's last_changed value will only update once an hour but it's last_updated value will change every minute.

StaleLoafOfBread avatar Apr 15 '25 00:04 StaleLoafOfBread

@StaleLoafOfBread but is that connected to the attributes? If I get it right, when we change the brightness of a light, the main state (on/off) does not change. So, naturally last_changed will remain the same. Am I correct?

AlexDaniel avatar Apr 15 '25 07:04 AlexDaniel

@AlexDaniel last_updated updates on attribute changes but last_changed does not.

Image

{{ states['light.living_room'].state }}
{{ states['light.living_room'].attributes.brightness }}
{{ states['light.living_room'].last_changed }}
{{ states['light.living_room'].last_updated }}

StaleLoafOfBread avatar Apr 15 '25 15:04 StaleLoafOfBread

@AlexDaniel Not sure if its helpful but I just learned of last_reported https://developers.home-assistant.io/blog/2024/03/20/state_reported_timestamp/

StaleLoafOfBread avatar May 06 '25 05:05 StaleLoafOfBread

Hi! I just found the cause of this! This fix will be part of the next beta 😄

Clooos avatar May 12 '25 13:05 Clooos

The new beta is here! 😄

https://github.com/Clooos/Bubble-Card/releases/tag/v3.0.0-beta.7

Clooos avatar May 14 '25 17:05 Clooos

@Clooos out of curiosity, what was the fix?

AlexDaniel avatar May 14 '25 17:05 AlexDaniel

I removed some parts of the code that was used for preventing the slider to move after an update, but I'm planning to rework this a little bit.

Clooos avatar May 14 '25 18:05 Clooos