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

[FR] expose sensor info via OctoPrint eventmanager. #260

Open
StefanCohen opened this issue Oct 2, 2019 · 8 comments
Open

[FR] expose sensor info via OctoPrint eventmanager. #260

StefanCohen opened this issue Oct 2, 2019 · 8 comments

Comments

@StefanCohen
Copy link
Contributor

Hi!

I'm developing the Dashboard plugin and I recently received a feature request to support dht11 temperature sensors. Rather than implementing this myself, I'm looking to see if you would be interested in exposing the sensor info you have to other plugins?

I haven't investigated your viewModel or API yet. I have a feeling that it is probably possible to get the info via those mechanisms but I see two problems with that:

  1. The viewModel approach makes the solution fragile and vulnerable to UI changes on your end.
  2. The API requires user configuration.

I propose that you implement support for custom events via the OctoPrint eventManager.

This could be an event that is fired on a fixed time interval (every two seconds?) or whenever there is a change in any of the sensor values.

I'm primarily interested in temperature sensors but there may be others that are interesting to expose to other plugins too.

Is this something you would be interested in?

@UnchartedBull
Copy link
Contributor

Funny thing, I just thought about the same thing for OctoDash. We're basically developing a similar thing (his is for the Website, mine for the Display) and we are running into the same problems.

I've tried reading the temperature sensor via a electron app which is not really that reliable and limits the electron builds to armv7l architecture basically. I did some research and found out, that you can retrieve the temperature via the settings API. It doesn't seem to update though and is kind of hacky and carries lot of unnecessary data.

I'll open a pull request where I tried to add a GET API for the temperature sensors and tried sticking to your existing code style. I don't want to open another issue for this, but exposing the data via an API will be great and there is demand for that. I'll link the PR once I've confirmed that it is working.

@vitormhenrique
Copy link
Owner

vitormhenrique commented Oct 9, 2019 via email

@UnchartedBull
Copy link
Contributor

You mean the OctoPrint-telegram Plugin? Because I can't find any use of the Enclosure Plugin there. I've also had a look at your code and it seems like you can retrieve most of the stuff except the rpi_inputs array, which is the one I'm interested in. If there is a way to retrieve the inputs please kindly point me in the right direction.

Enjoy you vacation!

@StefanCohen
Copy link
Contributor Author

Thanks for the feedback!
I would just like to know if you would be open for a PR if I and @UnchartedBull work together to improve how the data is exposed thru both the existing API and thru the event manager?

We are both interested in the same information but we have slightly different use cases. My Dashboard plugin will always run on the same OctoPrint Instance as the Enclosure plugin and therefore share the event bus. It would therefore reduce the configuration effort for users and also reduce the complexity to use the built-in messaging feature so that's the reason for me pursuing that path rather than the rest api. OctoDash will mostly (always?) run on another host so it makes sense to use the rest api in that case.

Best regards,
Stefan

@vitormhenrique
Copy link
Owner

vitormhenrique commented Oct 9, 2019 via email

@vitormhenrique
Copy link
Owner

vitormhenrique commented Oct 9, 2019 via email

@UnchartedBull
Copy link
Contributor

Ok I think we can take on this challenge then. @StefanCohen and I will work on the same fork to do a proper REST API and the custom events thing. it may take a few days but it hopefully helps more people after that!

And yeah OctoDash always runs on a separate instance, because it is javascript based and doesn't have direct access to the Python OctoPrint instance.

@vitormhenrique
Copy link
Owner

vitormhenrique commented Oct 9, 2019 via email

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

3 participants