Calling Pyton script from Command line sensor #258
Unanswered
Ogurtsov-D
asked this question in
Q&A
Replies: 1 comment
-
Pyscript scripts cannot run under plain Python. They require all of the infrastructure that the Pyscript Custom Component provides to run as expected. If you want to create a sensor with pyscript, you'll have to do it entirely in pyscript (not using a command line sensor). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I'm trying to use pyscript with command line sensor.
The overall goal is to to do several HTTP requests :login at remote resourse with POST, get the cookie, then use this cookie to GET required data, then logout and pass this data to this sensor.
Sensor code in Home assistant:
The script is the following:
During initial compilation with debug messages it works and I get the required data, but when this script is called from sensor - the goes an error:
After some debugging I found out that log.warning and task.executor both cause "Command failed" error, although both obviously work during reloading.
For example, this script works fine and sensor gets "Success" value:
So python works, import also seems to work. But the python script cannot be called from sensor for some reason.
That should be something simple or I miss someting. Please help.
Beta Was this translation helpful? Give feedback.
All reactions