Both have a single unit
Both have default unit
Both have required attribute called “value”
In both cases, I was only emitting the event with the numeric value only, without unit.
It is working fine for “voltageMeasurement” and throwing the following error for “powerMeter”:
[string “st/dispatcher.lua”]:233: Error encountered while processing event
…
[string “st/utils.lua”]:112: bad argument #1 to ‘for iterator’ (table expected, got number)
Then I thought: For some unknown reason, “powerMeter” is not handling single value without informing unit as I was expecting, just like it does with voltageMeasurement
So I changed the code to inform the unit and the error disappeared.
Maybe changing {"type": "number"} to {"$ref": "Number"} would fix that behavior.
The $ref is a schema reference to the predefined Number that is presumably intended to be used instead of using "type": "number" explicitly.
It may simply be that the Edge libraries are enforcing the use of units inconsistently for the two capabilities. It has been commented before how requiring units for capabilities that are defined to have optional units is a source of confusion.
Hi, @w35l3y
I will report this behavior, so, only the “powerMeter” capability is the one with the issue without the unit being included in the event, right?
I discovered this because I have a profile with these capabilities and the device report both values in a single event with generic raw data.
Then I read it and generate 2 separate events, voltageMeasurement and powerMeter.
So it was working for voltageMeasurement and not for powerMeter.
And you know the rest of the history because it is in the first topic.