Received my Shelly 3EM today and as the Shelly binding is unusable (dunno why it is listed in the bindings then ;o) I use the HTTP binding to get the JSON via the Shelly API.
So when calling http://10.0.100.19/status I get as Json returned (parts cut off):
So the values I’m interested in (voltage, current and power) are returned as numbers…
But why do I have to define the channel as String?
When set as Number always UNDEF is returned…
But when set as String channel no analyze button is available and therefore no graph is created.
thanks in advance
Then something is wrong with your config, which we cannot see.
openhab.log may have something to say on the matter.
Remember that JSONPATH is an optional add-on.
The thing code looks like:
label: Shelly 3EM HTTP
- id: shelly3em_voltage_1
label: Shelly 3EM Voltage 1
This results in:
2022-11-10 12:30:10.683 [WARN ] [ofiles.JSonPathTransformationProfile] - Could not transform state 'UNDEF' with function '$.emeters.voltage' and format '%s'
- id: shelly3em_voltage_a
label: Shelly 3EM Voltage A
is fine…but since it is then a String it is not graphed…
Well…just saw that the Shelly binding does support the 3EM, just not the Pro 4PM, which I’m gonna reflash with esphome anyway…
Your problem is that you are using a profile.
A profile operates on the link between channel and Item.
In other words, the profile takes the final output from the channel and modifies it.
If you use a JSONPATH profile, then you must pass it the whole JSON string to work with, which of course means using a string type channel.
Should the profile result after processing be numeric, you may link to a Number type Item - the profile has done the conversion from channel-string to Item-number.
If you use a number type channel to pass the whole JSON, it is non-numeric, simply doesn’t fit, and you get UNDEF passed out of the channel and onwards to the profile.
JSONPATH profile cannot process “UNDEF” of course, and complains.
What people do is not use a profile at all.
The HTTP channel has built-in configuration for transformations, including JSONPATH. Its in the docs.
This allows processing before the channel passes the value along.
If JSONPATH can extract a numeric, you would use a number type channel and the output will be a number.
You may even add a unit at the channel, if you know the numeric is say expressed in volts, “V”, and link to an quantity type Item.
You’re not alone in getting drawn into using profiles, something about the GUI invites people into this trap every week.