Feedback regex?
Feedback regex?
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.
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.
Re: Feedback regex?
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
Re: Feedback regex?
Sorry, it's. In the General Forum.....
Re: Feedback regex?
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.
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.
Re: Feedback regex?
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?
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?
Re: Feedback regex?
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?
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?
Re: Feedback regex?
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.
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.
Re: Feedback regex?
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.
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.
Re: Feedback regex?
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
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
Re: Feedback regex?
nevermind, my stupid mistake.
Re: Feedback regex?
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
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
Re: Feedback regex?
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 yoursRALC 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
Andrew