Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@state_trigger does not work when changes to 'helper' states are made by pyscript #647

Closed
mefranklin6 opened this issue Oct 22, 2024 · 1 comment

Comments

@mefranklin6
Copy link

Input numbers and booleans (toggles made in HA "helpers" menu) modified by Pyscript do not trigger the state triggers that are listening to them.

For example, nothing is logged when the below is ran even though HA updates the GUI and fires the state_changed events as expected.

@state_trigger("input_number.tv_brightness")
def tv_brightness_set(value=None):
    log.warning(f"TV brightness set to {value}")

input_number.set_value(entity_id="input_number.tv_brightness", value=75)
task.sleep(3)
input_number.set_value(entity_id="input_number.tv_brightness", value=50)
state.set("input_number.tv_brightness", 25)

@state_trigger("input_boolean.dev_bool")
def dev_bool(value=None):
    log.warning(f"dev_bool set to {value}")

input_boolean.toggle(entity_id="input_boolean.dev_bool")
@mefranklin6
Copy link
Author

After digging deeper, it seems this is limited to reloading (saving the .py file) and calling the changes bare. The changes probalby trigger before the decorators have had time to setup so they're not caught. This seems like such an edge case i'll close the issue.

I was also calling input_number changes wrong in some of my files which made me think this was an issue. state.set("input_number.somenumber", 25) is the wrong way to call it as it only updaes the GUI. People should use input_number.set_value(entity_id="something", value=25) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant