Persistent state_set outside of pyscript domain? #324
-
Hi! Just found out about pyscript yesterday - and I am already planning on moving all my automation from NodeRed to pyscript. :-D Thanks for all the work! I create a lot of custom sensors with pyscript, just as a better alternative to template sensors. Check out this example:
This works perfectly fine! But I'd like to use Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It is entirely possible (i.e. Home Assistant will allow it). However, the decision was made to limit it to the "pyscript" domain. Changes need to be made here to allow it to persist in any domain. Edit: Keep in mind, persisting sensor and binary_sensor is safe and easy since there are no service calls to be made on them. However, persisting light, for instance, is problematic with a change like this. While the state updates will work, this will not handle service calls (i.e. light.turn_on). So the light entity it creates will not response to UI button presses, etc. The proper implementation for light, switch, climate, etc is to implement the Home Assistant setup methods for each of those platforms with hooks back into user land pyscript code to handle the service calls. |
Beta Was this translation helpful? Give feedback.
It is entirely possible (i.e. Home Assistant will allow it). However, the decision was made to limit it to the "pyscript" domain. Changes need to be made here to allow it to persist in any domain.
Edit: Keep in mind, persisting sensor and binary_sensor is safe and easy since there are no service calls to be made on them. However, persisting light, for instance, is problematic with a change like this. While the state updates will work, this will not handle service calls (i.e. light.turn_on). So the light entity it creates will not response to UI button presses, etc. The proper implementation for light, switch, climate, etc is to implement the Home Assistant setup methods for each of those …