Mystrom, http, json and displaying usage...a bit lost

  • Platform information:
    • Hardware: VM on ESXi
    • OS: Ubuntu 16.04
    • Java Runtime Environment: Zulu-8
    • openHAB version: latest

Hello guys and girls,

Long time Domoticz user, I got a bit tired of the very few updates it gets. It works OK at home, but I need something with more active development so I checked out OH2.

So, I’m just playing with it at the moment, went through the beginners guide in the documentation. But I can’t figure out what I’m not doing properly, googled around but still stuck.

Long story short, I got a few MyStrom plugs at home. I currently retrieve power/status in domoticz with a php script. I know there’s a MyStrom add-in for OH, but I do not have a mystrom account and do not intend to create one.

Here’s the situation. MyStrom ouputs a very simple JSON at the URL: http:/ip/report, and it looks like this:

{
“power”: 801.924622,
“relay”: true
}

So I figured using http binding and JSON transform was the way to go. in http.cfg I have:

mystrom1.url=http://192.168.3.243/report
mystrom1.updateInterval=5000

Created an item with this:

Number mystrom1 “mystrom1 Usage” { http="<[http://192.168.3.243/report:5000:JSONPATH($.power)]" }

In events.log, I can see the power usage change every 5 seconds, so polling works.

Now my question is, how do I display this information in a sitemap? I tried this:

sitemap mine label=“Mine” {
Number item=mystrom1 label=“mystrom1 Usage”
}

But OH errors out saying it couldn’t find any number (in openhab.log). I just don’t understand exactly what I’m doing wrong so if someone could pich in that 'be great :slight_smile:

Thanks

OK got it myself, had to do some formatting:

Number mystrom1 “Value: [%.0f W]” { http="<[http://192.168.3.243/report:5000:JSONPATH($.power)]" }

In the sitemap:

sitemap mine label=“Mine” {
Text item=mystrom1 label=“RIG1 Usage”
}

You don’t need to set the label twice. This feature is only useful if you want the same item in different places in your sitemap with different labels (e.g. a group of all lights in a house should have the room in the label, while the same item should not have the room in the label when placed in a group with all items of a room)

As you defined a http cache (this is in http.cfg) you should use this for the item:

Number mystrom1 “RIG1 Usage [%.0f W]” { http="<[mystrom1:5000:JSONPATH($.power)]" }

or simply delete the cache, as it’s not useful here :wink: (would be, if you want get other information from the same cached report)

Hello Udo,

Thanks for the tip, indeed the caching will not be necessary here!

Cheers