Help get this topic noticed by sharing it on Twitter, Facebook, or email.

HTTP Feedback parsing problem

I’m a complete iRule noob, and need some help.

I searched but can’t find the solution to my problem...


I am trying to get the power state feedback from fibaro lightning modules via HTTP and domoticz.

I get the numerical feedback with no trouble.

I can’t get the textual feedback :/


Here’s the command I send via HTTP get : /json.htm?type=devices&rid=4

Here’s what you get in return through a browser :

{

  • ActTime: 1452791637,
  • ServerTime: "2016-01-14 18:13:57",
  • Sunrise: "08:40",
  • Sunset: "17:18",
  • result:
    [

    • {
      • AddjMulti: 1,
      • AddjMulti2: 1,
      • AddjValue: 0,
      • AddjValue2: 0,
      • BatteryLevel: 255,
      • CustomImage: 0,
      • Data: "Off",
      • Description: "",
      • Favorite: 1,
      • HardwareID: 2,
      • HardwareName: "zStick",
      • HardwareType: "OpenZWave USB",
      • HardwareTypeVal: 21,
      • HaveDimmer: true,
      • HaveGroupCmd: false,
      • HaveTimeout: false,
      • ID: "0000301",
      • Image: "Light",
      • IsSubDevice: false,
      • LastUpdate: "2016-01-14 17:42:43",
      • Level: 79,
      • LevelInt: 79,
      • MaxDimLevel: 100,
      • Name: "Couloir",
      • Notifications: "false",
      • PlanID: "0",
      • PlanIDs:
        [
        • 0
      • ],
      • Protected: false,
      • ShowNotifications: true,
      • SignalLevel: "-",
      • Status: "Off",
      • StrParam1: "",
      • StrParam2: "",
      • SubType: "ZWave",
      • SwitchType: "Dimmer",
      • SwitchTypeVal: 7,
      • Timers: "false",
      • Type: "Lighting 2",
      • TypeImg: "dimmer",
      • Unit: 1,
      • Used: 1,
      • UsedByCamera: false,
      • XOffset: "0",
      • YOffset: "0",
      • idx: "4"
    • }
  • ],
  • status: "OK",
  • title: "Devices"

}



For the numerical feedback, I used :

prefix : Level:

Suffix : ,

and it works fine



For the textual feedback, I used :

prefix : Data: “

suffix : “,

And it doesn’t work


What am I missing ?

1 person has
this question
+1
Reply
  • Is there 1 space or 2 between Data: and the "? Could make a difference.

    For the suffix, you might try "*

    To really see what is going on, you may need to use a telnet client, such Docklight Scripting or Hercules to send commands and see the actual returned data. Browsers sometimes modify the response that you see.

    In iRule, there are 3 levels to feedback, Feedback, Code, and Value. You could try setting the Code level prefix to Data: and the suffix to ,*. Then set Target Value in the Value level to "Off", and Replace With to Off.

    Another trick with feedbacks is to use the * character between the start of the data and the actual part you want. The * will "absorb" the stuff in between that you don't want. This is particularly helpful when the stuff in between changes, so you don't know exactly what it is.

    Also, iRule Support is usually pretty responsive if you email them at support@iruleathome.com.

    Good Luck!

    Mike
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • try:
    prefix :*Data: "
    suffix :"*

    Side note, do you want to use the data field or the status field?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Thanks for your answers.

    Mike you were right saying the browser was not showing the "answer" properly.
    I finally had it working after talking to the support team.
    When I right clicked in the browser and choose "View Source" I got the correct data to parse.

    Here's the setup in case someone ever needs it :

    Starts With: blank
    Ends with: blank
    Prefix: *"Data" : "
    Suffix: ",*"Description"*
    Target Value: *

    Thanks for your help
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated