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

Add "script" sensor type #295

Closed
tvStatic opened this issue Jun 4, 2019 · 0 comments
Closed

Add "script" sensor type #295

tvStatic opened this issue Jun 4, 2019 · 0 comments

Comments

@tvStatic
Copy link
Contributor

tvStatic commented Jun 4, 2019

You have an existing sensor type "remote". A "script" sensor type is similar, except that it runs a shell script locally. This allows simplified development of new sensor types, since one can develop the shell script (or python script as I have done) separately to the TerrariumPI source code, eliminating the need to restart the system.

My personal use case was to add support for the AM2320 temp/humidity sensor (for which I will create another issue). I created some python scripts, then added a "Script" sensor with a location set to "python ../pythonScript.py" to get the values.

I have a local change that adds support for this and will submit a pull request when necessary.

One possible hang up I see with this is the possible security issues. My current implementation gives the user a lot of power to do some damage to the system. Possible alternatives might be to provide a scripts directory and only scripts within that directory can be executed via the sensor code (if you have the ability to put stuff in the scripts directory, you pretty much have control of the system).

Another issue that I've encountered is that for python 2, my current (simple) implementation doesn't have a timeout for the script. A more advanced implementation might be necessary to ensure that the system doesn't hang because of a bad script.

Interested to hear your thoughts. The only workaround I can think of to do the same thing would be to run a local daemon that responds to http requests and use the "Remote" sensor type, which is a non-trivial solution to the problem.

Edit: would be worth doing a similar thing for switches, but I'll raise that as a separate case if necessary.

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