Feedback regex?

Forum to ask for any help
Post Reply
cavester
Posts: 5
Joined: Fri May 10, 2013 1:14 pm

Feedback regex?

Post by cavester » Sun Dec 22, 2013 11:08 am

Hi,

I think I need to use regex for this but I am not sure how. After looking around the forums and tutorials I don't seem to be able to find a clear answer...

If I have the below XML returned in feedback how can ensure that what is returned includes "Device_Num_9" and "SwitchPower1" variable="Status" value="1""?

I have many of these being returned in order to set the status of icons (light on/off) but I need to differentiate them by there device numbers.

<root LoadTime="1385139141" DataVersion="139142321" UserData_DataVersion="139141022" TimeStamp="1385229600" ZWaveStatus="1" LocalTime="2013-11-23 18:00:00 N">
<Device_Num_9 status="-1">
<states>
<state id="135" service="urn:upnp-org:serviceId:SwitchPower1" variable="Status" value="1"/>
<state id="136" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="10"/>
<state id="137" service="urn:micasaverde-com:serviceId:HaDevice1" variable="Configured" value="0"/>
<state id="138" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="Assocation" value=""/>
<state id="139" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="KopplaProgrammed" value="1"/>

I'm sure it's a simple answer, just can't find it.

Thanks.

ChrisB75
Posts: 52
Joined: Sun Feb 17, 2013 1:11 pm

Re: Feedback regex?

Post by ChrisB75 » Tue Dec 24, 2013 1:02 am

Hi, looks like Veralite, if so take a look at my post Lightwave and Veralite on this forum, hopefully that will answer your question.... Feel free to send me a personal message with any questions. Cheers, Chris

ChrisB75
Posts: 52
Joined: Sun Feb 17, 2013 1:11 pm

Re: Feedback regex?

Post by ChrisB75 » Tue Dec 24, 2013 1:03 am

Sorry, it's. In the General Forum.....

cavester
Posts: 5
Joined: Fri May 10, 2013 1:14 pm

Re: Feedback regex?

Post by cavester » Thu Dec 26, 2013 11:27 am

Thanks, Chris.

I did already see that and tried to follow however it didn't work for me. Obviously I am doing something wrong.

I will take another look now and see if I can figure it out.

Thanks,

Lee.

cavester
Posts: 5
Joined: Fri May 10, 2013 1:14 pm

Re: Feedback regex?

Post by cavester » Fri Dec 27, 2013 1:07 pm

Ok, I have everything working, except the status of the icon changing.

The icon is setup correctly, if I set the number to 1 or 0 the icon changes good.

However when I use the 2 way feedback form to assign the status of a lamp to the number controlling the icon it does not work. If I assign the information to a label I can see it passes 1 or 0 so the regex is extracting the correct information however it is just not working when setting to the number.

Anyone any ideas?

cavester
Posts: 5
Joined: Fri May 10, 2013 1:14 pm

Re: Feedback regex?

Post by cavester » Sat Dec 28, 2013 12:08 pm

Could this be a bug?

If I have a number that has an action to set a flag, it does when I manually set the number but not when I pass the same number from the feedback form using regex. I confirm the number being extracted by also setting it to a label so I can see regex is extracting 0 or 1 as required, but the number does not set the flag?

cavester
Posts: 5
Joined: Fri May 10, 2013 1:14 pm

Re: Feedback regex?

Post by cavester » Sat Dec 28, 2013 8:14 pm

A little more digging, I can only assume this is a bug unless someone has an explanation...

Assigning a number via the 2 way feedback form to a number variable which in turn has an associated action to set a flag, the action does not fire.

However if in the 2 way feedback form I set a number to the number variable and then within the 2 way feedback action I set the number variable to itself then it triggers the associated number variable action.

User avatar
DemoPad
Site Admin
Posts: 769
Joined: Thu Jun 14, 2012 10:46 am
Contact:

Re: Feedback regex?

Post by DemoPad » Tue Dec 31, 2013 10:41 am

This is not a bug, it is just the way the feedback routine works. When numbers are assigned by way of a regular expression, custom number actions do not fire. To get them to fire, also have an action which sets the number (call it "MyNumber" equal to the data: "[MyNumber]" (without the quotes!). This will set the number equal to itself, and hence fire the custom number actions - as per the post above.

The reasoning behind this behaviour is to stop an infinite loop of commands - for example if you associate a number to a volume gauge, and alter the gauge to a value, a custom number action might fire to send the volume command to an amplifier. The amplifier will typically respond with a status which contains the new volume - which would then be assigned to the number, which would otherwise fire the custom number actions again, which sends another volume command to the amplifier etc etc.

d_hero
Posts: 71
Joined: Mon Jul 30, 2012 9:32 pm

Re: Feedback regex?

Post by d_hero » Tue Jun 09, 2015 8:54 pm

Hi

if Cavester is still reading this, please can you let me know how you got your regex working? Im struggling to get it to work with the multi line xml response where I need to isolate the device id then look for a state a little bit further down.

Anyone got any ideas?

Thanks

d_hero
Posts: 71
Joined: Mon Jul 30, 2012 9:32 pm

Re: Feedback regex?

Post by d_hero » Tue Jun 09, 2015 9:53 pm

nevermind, my stupid mistake.

RALC
Posts: 2
Joined: Wed Nov 18, 2015 11:00 am

Re: Feedback regex?

Post by RALC » Sat Dec 19, 2015 4:28 pm

Hi anyone got any tips on multiline xml - as previous poster, the pattern I need to match includes an ID and a value which are in separate lines in the returned xml.

have tried the following pattern:

<R1>\xAO<description>Relay1</description>\xAO<value>(.*?)</value>

but it returns nothing. As a test if I set a pattern for something all on one line (e.g. '<value>(.*?)</value>') it works as expected.

If I fabricate the xml response with Hercules to return it either all on same line or on separate lines using $AO between lines (Hercules convention for \x0A then it works. So my guess is that the unit is returning something other than \x0A, \x0D, \x0A\x0D or \x0D\x0A at the end of each line, but how do I work out what I is.

Note I have got my all-on-one-line and Hercules tests above working with the terminator set to either \x0A or </Monitor> which is the last xml token returned.

sorry to hijack Arnold thread but I have created a new thread but there seems to be a delay in displaying it. I have some time this weekend to get this working and am struggling.

Thanks in advance, Rich

AKWillows
Posts: 53
Joined: Mon Aug 25, 2014 5:46 pm

Re: Feedback regex?

Post by AKWillows » Thu Apr 07, 2016 8:04 pm

RALC wrote:Hi anyone got any tips on multiline xml - as previous poster, the pattern I need to match includes an ID and a value which are in separate lines in the returned xml.

have tried the following pattern:

<R1>\xAO<description>Relay1</description>\xAO<value>(.*?)</value>

but it returns nothing. As a test if I set a pattern for something all on one line (e.g. '<value>(.*?)</value>') it works as expected.

If I fabricate the xml response with Hercules to return it either all on same line or on separate lines using $AO between lines (Hercules convention for \x0A then it works. So my guess is that the unit is returning something other than \x0A, \x0D, \x0A\x0D or \x0D\x0A at the end of each line, but how do I work out what I is.

Note I have got my all-on-one-line and Hercules tests above working with the terminator set to either \x0A or </Monitor> which is the last xml token returned.

sorry to hijack Arnold thread but I have created a new thread but there seems to be a delay in displaying it. I have some time this weekend to get this working and am struggling.

Thanks in advance, Rich
Hi Rich, did you get anywhere with this? I have learnt lots whilst developing my Demopad controls, but have still not been able to master the regex when the feedback is on multiple lines like yours
Andrew

Post Reply