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

More efficient temp download #1

Open
psoberoi opened this issue Nov 27, 2018 · 0 comments
Open

More efficient temp download #1

psoberoi opened this issue Nov 27, 2018 · 0 comments

Comments

@psoberoi
Copy link

Hi,

Thanks a lot for this guide. It was very helpful in helping me set up my wireless tag sensors. I made a few small and easy tweaks which I thought I'd share.

You've used the ethDownloadMultiStatsCSV method to download stats, which returns the entire sensor history. It can be pretty long, and all of it is discarded. Instead, it is possible to fetch just the latest temperature using the ethLogShared method. Here's an example from one of my sensors (openhab2 syntax, from conf/services/http.cfg):

wirelessTagOutdoor.url=https://my.wirelesstag.net/ethLogShared.asmx/GetLatestTemperatureRawDataByUUID?uuid=
wirelessTagOutdoor.updateInterval=60000

Since it returns very little data, I reduced the update interval to one minute. I can use the following JS to extract the temperature from it:

(function(i) {
x = i.indexOf("<temp_degC>") + 11;
y = i.indexOf("</temp_degC>");
return i.substring(x, y);
})(input)

The same http resource can also be used to extract humidity using this JS:

(function(i) {
x = i.indexOf("") + 5;
y = i.indexOf("");
return i.substring(x, y);
})(input)

The item definitions are pretty much unchanged from yours:

Number Temperature_Outdoor "Outdoor Temperature [%.1f °C]" { http="<[wirelessTagOutdoor:60000:JS(wirelessTagTemp.js)]" }
Number Humidity_Outdoor "Outdoor Humidity [%.1f %%]" { http="<[wirelessTagOutdoor:60000:JS(wirelessTagHumidity.js)]" }

One other thing that tripped me up is that depending on when the sensors were bought, the API url can be different. There is an explanation here (or search for "New Cloud Architecture with Multiple Databases" in the API docs):

https://groups.google.com/d/msg/wireless-sensor-tags/cyGI5sauSmg/DMvpFWvpAQAJ

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