pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

'StateVal' object has no attribute 'old'

Open ALERTua opened this issue 1 year ago • 0 comments

I'm trying to receive a notification on 'sensor.hacs' value raise only, rather than lower and raise, and I came up with unexpected behavior. In case you don't know what 'sensor.hacs' is, this sensor indicates the total number of HACS updates available, so if a new update appears, it goes up, and when you install one of them, it goes down.

@state_trigger(int(sensor.hacs) > int(sensor.hacs.old), state_check_now=True)

Results in

int(sensor.hacs) > int(sensor.hacs.old)
                       ^
AttributeError: 'StateVal' object has no attribute 'old'

but the documentation states that .old can be used and only results in None if the .old hasn't yet been filled.

ALERTua avatar Sep 22 '22 12:09 ALERTua