Hello,
I was trying to find out, what am I doing wrong, but even when I use sample rules, it just does not work for me.
I am trying to do a rule to “copy” humidity value from air condition to virtual humidity sensor. But all the time I am getting just error like “Error adding rule “Test”. 422 The request is malformed. Unknown target: Malformed body on line 1:26”. I saw, that the position is affected by the rule name, which is because the JSON format see it like one row or something?
Can anyone tell me, please, where is the issue?
Not sure, if that matters, I have AEOTEC Hub.
How are you creating the Rules? If you are pasting into the Advanced Web App there is a ‘gotcha’ because it only wants the actions array. So not the outer {}, not the name line, and not the "actions": key. Just the [ ... ].
However regardless of that your if action doesn’t look correct. To be testing for a change to a device attribute I would expect you to be using a changes operator, then an operand operator and the the device operand.
Yes, I am using the Advanced Web App. I did not know, that there is any other “easy way”, because the CLI looks like far more advanced version for me.
Could you please point me where is the information written, so I could read it there?
Or write part of the code how it should look like in my case?
Yes, sorry, I forgot to edit that part. I am using virtual device, which can do the setHumidity via setvHumidity command.
I am trying to figure it out, so far no luck, I need to take a look into it later again. I never did anything in JSON before to be honest. I know, that the formatting is wrong now. If anyone can help me to correct my mistake, I would really appreciate that.
And thank you guys for your help so far!
I was trying a lot of things, I have no idea, what is wrong. When I put the code below, I get
Error updating rule logic. 422 The request is malformed. then: Unrecognized field “then” (class v20190122.internal.st.behaviors.Action), not marked as ignorable
Error updating rule logic. 422 The request is malformed. type: Unrecognized field “type” (class v20190122.internal.st.behaviors.Action), not marked as ignorable
The if action object is an object with a number of properties. The three main ones are: a condition such as changes, equals or and; then; and else.
So the structure in AWA is:
[
{
"if": {
"changes": {},
"then": []
}
}
]
I know that isn’t what I wrote earlier but I don’t write Rules in JSON and got so tangled in the formatting using a mobile that I put the then in the wrong place.
The type key is one of a few things that appear in Routines but not the Rules API. It always appears as the last property in the JSON objects, despite the order of the properties not otherwise being important. I would imagine this creates a more rigid structure to the JSON that facilitates recreating the Routines in the app.