Python client
Closed this issue · 4 comments
Just created a little python client.
It might look overly complex but that is simply because it is designed to be able to plug right in to Home Assistants Plant Monitor component: https://www.home-assistant.io/integrations/plant/
(and currently there is no input validation or validtion of the returned data from the API, so this is not production ready, just a PoC at the moment).
https://github.com/Olen/OpenPlantbook-client/tree/master/python
Added a PR.
An issue right now is that the openplantbook client id and secret needs to be added to all the plants in the config.yaml.
This is because I want to keep the code of the client as close to the implementation I am hoping to get into Home Assistant as soon as I have tested and verified that this works. And in HA we would either need to create openplantbook as a custom_integration, and let the official Plant Monitor component depend on that (which I don't really want), or we need to add the api keys to each plan as a part of the config for that plant.
we need to add the api keys to each plan as a part of the config for that plant.
I think that this should work at initial stage. Not guru in has but is it possible to leverage some kind of macros and put api credentials in there?
Nah, yeah, maybe...
But it won't save you much config.
You would typically use the secrets-file for this, so you just need to add the two lines
plantbook_client_id: !secret plantbook_client_id
plantbook_client_secret: !secret plantbook_client_secret
To each plant.
I have been thinking about something like a "magic" plant, called "_plantbook", and reference the config for that plant in each of the others, but it looks ugly, and does not feel right.
The most correct way would be to add openplantbook as an integration in HA, and use it if it set up, but that involves much more work for just saving two variables in the config of each plant.
The most important right now for this to work, is to be able to query the api using a unique string for each plant.
Fixed this in the HA-integration I am working on.