Hi everyone.
I have a question about http requests and received values.
I have setup emoncms and when i use a link with the api key and specific id i get in my browser the specific value. For example if i hit in a browser
http://192.168.xxx.xxx/emoncms/feed/fetch.json?ids=3&apikey=skejferjfuerfuu45345345j345j34, i get a returned value [“16.37”] in the browser.
How can i make that value display in openhab 2???
Thanks in advance
Thanks but i still can’t get it to work.
Could i have some examples please ?
I have tried everything i could reading from the openhab 2 documentation for http binding but i cant get it to work.
I just want that number to appear in my openhab interface nothing more
You need to configure the binding for incoming requests:
http="<[<url>:<refreshintervalinmilliseconds>:<transformationrule>]"
, so in your case
Number Temperature "Temperatur [%.1f °C]" { http="<[http://192.168.xxx.xxx/emoncms/feed/fetch.json?ids=3&apikey=skejferjfuerfuu45345345j345j34] }
or something similar should work. I cannot give you a working example, I’m using the binding only for outgoing messages.
For more information you need to read the json section:
http://docs.openhab.org/addons/bindings/http1/readme.html#handling-json
I would first try it with a String item:
String Temperature "Temperatur [%s °C]" { http="<[http://192.168.xxx.xxx/emoncms/feed/fetch.json?ids=3&apikey=skejferjfuerfuu45345345j345j34:10000:REGEX(.*\["(.*)"\].*)] }
If that works then try it with a Number item:
Number Temperature "Temperatur [%.1f °C]" { http="<[http://192.168.xxx.xxx/emoncms/feed/fetch.json?ids=3&apikey=skejferjfuerfuu45345345j345j34:10000:REGEX(.*\["(.*)"\].*)] }
Thank you guys.
I solved the problem by installing the regex transform.
I tried all of the above but with no luck at first and then i noticed in the console an error about regex rule.I installed the transformation and with the appropriate format i finally see my values.
Thanks once more.
Hello,
can you share your solution with us? I have the same problem.
Thank you in advance!
Here is my item config.
String Phase_1 "1η Φάση [%s Watt]" <energy> { http="<[http://192.168.xxx.xxx/emoncms/feed/value.json?id=3&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:8000:REGEX((.*))]"}
String Phase_2 "2η Φάση [%s Watt]" <energy> { http="<[http://192.168.xxx.xxx/emoncms/feed/value.json?id=4&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:8000:REGEX((.*))]"}
String Phase_3 "3η Φάση [%s Watt]" <energy> { http="<[http://192.168.xxx.xxx/emoncms/feed/value.json?id=5&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:8000:REGEX((.*))]"}
Hi,
This is my item:
String HomePower “Consumption [%s Watt]” { http="<[http://192.168.xxx.xxx/emoncms/feed/value.json?id=2&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:8000:REGEX((.*))]"}
My sitemap includes:
String item=HomePower icon=“energy”
feed ID and apikey are OK - I get the right number if I type in browser:
http://192.168.xxx.xxx/emoncms/feed/value.json?id=2&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
After putting this item in .items my BasicUI and ClassicUI stopped responding.
Am I missing something? Where I go wrong?
Thanks in advance,
Janez
In my sitemap i have
Frame label="Καταναλώσεις" {
Text label="Καταναλώσεις" icon="energy" {
Text item=Phase_1
Text item=Phase_2
Text item=Phase_3
Text item=Total_Power_Consumption
}}
And here some screenshots
Tried with many Regex expressions but no luck
I will keep trying. I will post if I succeed.
Thank you for help.
Hello.
Finnaly I have connect OH2 and EmonCMS via MQTT.
My home.sitemap include:
Text item=HomePower icon=“energy”
My home.items include:
Number HomePower “Power [%s Watts]” { mqtt="<[emonhub:emon/emontx1/power1:state:default]" }
My mqtt.cfg (in folder services) include:
#OpenEnergymonitor
mqtt:emonhub.url=tcp://192.168.x.x:1883
mqtt:emonhub.user=xxxxxxx (default:emonpi)
mqtt:emonhub.pwd=xxxxxxx (default:emonpimqtt2016)
mqtt:emonhub.qos=0
mqtt:emonhub.retain=true
I’m not sure if everything is by the book but it is working for me. I did not change anything on EmonCMS site.
Cheers.