I trying to write python scripts under python_script component and don’t really understand what going on.
When I try to use functions like max() and list() I am getting errors like
“Error executing script: name ‘max’ is not defined”
datetime.datetime module works, but others don’t.
So I have two questions:
Where can I find a list of modules that will work? For example re will work?
Why function like list() and max() fail? Those native python functions should work without any modules loaded.
I might be wrong, but python_script seems to have the same restrictions as templates in terms of what’s available - here in docs they explain how to use min/max.
I can definitely say that you cannot import anything and can only have access to what’s already imported by HA, and date time module is one of those.
However, I don’t know where to get the exhaustive list of imported modules.
p.s maybe it’s not the best idea to publish a question and add Share your Project tag to it, don’t you think so?
Don’t see reason to limit in this way scripts.
HA installation not run as public service with users creating scripts.
No need for such security measures. Just complecating things.