I have some reasonably complex functionality that warranted a python_script
instead of just a normal series of actions for my automation. However, I need to do some date arithmetic to get the difference between two dates in text format that are obtained by the script. It seems to be a pain in the but when normally I could just from datetime import datetime
.
Has anyone proposed whitelisting some well-known imports so that they could be used in these python scripts? Or is there another relatively easy way to accomplish some date arithmetic, or parsing a datetime to a timestamp without using the imports?
This is the bane of my existance, currently:
2022-10-15 14:35:33.198 ERROR (SyncWorker_1) [homeassistant.components.python_script.calendar_notifications.py] Error executing script: __import__ not found
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
exec(compiled.code, restricted_globals)
File "calendar_notifications.py", line 5, in <module>
ImportError: __import__ not found