Yes
3030304D4950302D30303A30303A30322E3030302C302E302C302E302C302C302E302C302C302C302C302C302C302C302C302C302C302C302C302C302E302C302C302C302C302C302C302E3030302C32353135392E35352C3237313630362E352C302C302C302C302C302E302C2A2C302E3030302C2A2C2A2C333237362E382C302E302C302C302E3030300D0A3030304D495054312C302E302C302E302C302E302C302E302C302C302C302C302C302E302C302C302E302C302C342C302E302C302E302C302E302C302E302C302E302C302C302E302C302C332C302C302C302C302C302C302E302C30300D
PVM Complex data types binary data
So if your original device message looks like that:
{"attr":"3030304D4950302D..."}
Then with pvm code .attr ==> %hexstr ==> #decoded.attr
you will get that resulting message:
{"attr":"3030304D4950302D...","decoded.attr":"000MIP0-..."}
If you need to break down that HEX-decoded string into separate parameters - you have to know how those parameters are encoded in your string
- Edited
Yes, Thanks
It's My Result
can i have a way to map it i mean to convert it as a
key: value
to exemple
{
key_1 : 000MIPT1,
Key_2:0,
Key_3:0,
}
like this ?
SouhailOusbouane-Bakioui yes, is possible if you can describe a way to split each value. Please note that you have two lines of the comma-separated value, and some of them are not numbers. How that exceptions should be handled?
kial Hi
thank you for your reply
I want to ask you about this code ".attr ==>% hexstr ==> #decoded.attr"
I'm just making sure befor run it
Now , my attribute name is "paylod"
If in my code it should be like this;
.paylod ==>% hexstr ==> # decoded.paylod
the correct ?
kial
thank you for your reply ,
Yes the point is, how should these exceptions be handled with extra flespi code, can I find a way to do it?
- Edited
SouhailOusbouane-Bakioui Yes, but without extra spaces after %
and #
: .paylod ==> %hexstr ==> #decoded.paylod
By the way, you can use any suitable name like this: ... ==> #result_property
Is it a plugin that runs just before the data is entered into the database? Or should every request be worked by a REST API event attribute saved in the database in hex format?
I mean if I have an old value in hexadecimal form, and when I make a request by a REST API, should the plugins work? Or just work with new data ?
SouhailOusbouane-Bakioui Plugins work only with real-time data, there is no built-in feature to apply plugins to data already stored in the flespi device.
SouhailOusbouane-Bakioui but you may re-post the data back to flespi using this guide: https://flespi.com/kb/how-to-re-post-historical-data
Hi
how can i calculate the power of a number in PVM ?
AminaBALAMHITOU Do you mean pow()-like function? https://en.wikipedia.org/wiki/Exponentiation
for example : 2 ^ 2 =4
raising to the power 2
kial yes i mean this.
AminaBALAMHITOU We'll add such a feature the next week
ok, i have a problem with the division x /y
example : 3 / 2 should equal to 1.5 but the result is 1
how can i solve this problem ?
- Edited
AminaBALAMHITOU
You can do it like this: 3 / 2.0
AminaBALAMHITOU We have added math.pow[...]
to pvm. So with following plugin code:
.value ==> math.pow[.power] ==> #result
The message {"power":10,"value":2}
will be transformed into {"power":10,"result":1024,"value":2}