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

Update status with one request #36

Closed
mariusz2108 opened this issue Feb 19, 2019 · 4 comments
Closed

Update status with one request #36

mariusz2108 opened this issue Feb 19, 2019 · 4 comments

Comments

@mariusz2108
Copy link
Contributor

Currently for one thermostat there are at least four exactly the same requests.

Below log:
[19.02.2019, 18:29:11] [Thermostat] getTargetHeatingCoolingState from: http://localhost:9010/REST/homekit/status
[19.02.2019, 18:29:11] [Thermostat] getTargetRelativeHumidity: 0.5
[19.02.2019, 18:29:11] [Thermostat] getTemperatureDisplayUnits: 0
[19.02.2019, 18:29:11] [Thermostat] getHeatingThresholdTemperature : 25
[19.02.2019, 18:29:11] [Thermostat] getCurrentTemperature from: http://localhost:9010/REST/homekit/status
[19.02.2019, 18:29:11] [Thermostat] getCurrentHeatingCoolingState from: http://localhost:9010/REST/homekit/status
[19.02.2019, 18:29:11] [Thermostat] getTargetTemperature from: http://localhost:9010/REST/homekit/status

So in above example there are four calls to http://localhost:9010/REST/homekit/statusw which is very inefficient

@phenotypic
Copy link
Contributor

phenotypic commented Feb 19, 2019

@mariusz2108 I agree that this is quite inefficient; however, implementing this isn't straight forward due to the way HomeKit requests information.

The way I can see around it is for there to be a central function called something like getStatus which will do the one request; then, when a variable is requested e.g. getTargetTemperature, it asks the getStatus function for this info rather than requesting it directly from the thermostat. However, the central function must ensure that the info is up-to-date.

Like I said, I agree that this would be an improvement and I'm interested in looking into implementing this into my fork of the plugin in the near future then creating a pull request into the main branch.

Best, Tom

@PJCzx
Copy link
Owner

PJCzx commented Feb 19, 2019

I also agree, but according on how you will ask SIRI/Home App information, you will still have 4 Calls. Indeed, we can separate the call to get a lighter payload, but at the time I did the plugin, I didn't saw much difference.

And then I think about all the peoplle the have a working API that could be broken with a new implementation.

Do you think this is really an issue ?

@Tommrodrigues, if you do a PullRequest (what can be nice) I will wrap it into a new version. V1.X.X

Thx

@PJCzx PJCzx closed this as completed Feb 19, 2019
@mariusz2108
Copy link
Contributor Author

I have made POC with "caching" results and it makes huge difference for me (my home bridge runs on raspberry pi).
First request gets data and save it.
Then I start timer for one minut.
Sice now for one minute every request is taken from "cache".

I am not sure if it's good solution since I don't know well JS. But it works.

@PJCzx
Copy link
Owner

PJCzx commented Feb 19, 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