After restarting home assistant, I'm getting the following exception when it tries to load one of my scripts that use the generated stubs:
Exception in </config/pyscript/scripts/home/smoke_alarm_low_battery_notifications.py> line 25:
@state_trigger(get_str_expr(sensor.basement_staircase_smoke_co_alarm_battery_level))
^
NameError: name 'sensor.basement_staircase_smoke_co_alarm_battery_level' is not defined
This is the first script that pyscript attempts to load. My other scripts do not seem to have this same problem. If I save the file again in my IDE without making any changes, it reloads successfully without any errors. Is this a timing issue of some sort?
Update:
I no longer get that exception if I change my @state_trigger to:
@state_trigger('float(sensor.basement_closet_smoke_co_alarm_battery_level) <= 80.0')
And I don't get the NameError when I use sensor.basement_closet_smoke_co_alarm_battery_level in the function.
It seems there's just an issue with it being used inside @state_trigger, and only after restarting home assistant, not after forcing a reload by saving the file.