Escape characters and RegExp use

Begonnen von andyclimb, 03 August 2013, 10:32:01

Vorheriges Thema - Nächstes Thema

andyclimb

Hi,

Two more questions from the uk!

I've been using perl expressions to create logic situations including
fhem (" define abc at +00:10:00 set lamp on")

But I can't  to get it to work with a nested perl commands to work as below

fhem (" define abc at +00:10:00 {if(MyTwilight <=4) {fhem("set lamp on")} }")
Any ideas?

My second question is how to set regexp for notify when the event is more complex than device:on|off. For example a FHT8V generates events such as devicename valve 100, I can't seem to get a regexp to work fully to differentiate between valve 0 and valve 100.

Any ideas much appreciated.

Thanks

Andrew
AM

fiedel

Hi Andy,

and here one more answer from the GDR ;o)

My solution for your first question is to make an additional notify, that is not lsitening to events. This notify then you trigger out of your "at" and into this notify you put your second function. Looks like this:



define test_notify notify test_notify {\
       if(MyTwilight <=4);;\
    {fhem("set lamp on")};;\
}

# your first function
fhem (" define abc at +00:10:00 trigger test_notify")



For your second question i have no idea.

Many greetings from east Germany ;o)

Frank
FeatureLevel: 6.1 auf Wyse N03D ; Deb. 11 ; Perl: v5.14.2 ; IO: HM-MOD-RPI-PCB + VCCU|CUL 868 V 1.66|LinkUSBi |TEK603
HM: SEC-SCO|SCI-3-FM|LC-SW4-PCB|ES-PMSW1-PL|RC-4-2|SEN-MDIR-O|SEC-WDS-2
CUL: HMS100TF|FS20 S4A-2 ; OWDevice: DS18S20|DS2401|DS2406|DS2423

rudolfkoenig

MyTwilight <=4 should report a syntax error, as MyTwilight is not a perl variable.
I do not use Twilight at all, but as far as I understand it from the code, you probably want to use its STATE value. In this case you should write
Value("MyTwilight") <= 4
But since twilight seems to issue events, in FHEM it would be a lot better to write a notify instead of polling the value with at.
It would be nice if the maintainer of Twilight would document all generated events in commandref.html, as a workaround you could define an eventTypes instance and check the events available after a whole day.

>  I can't seem to get a regexp to work fully to differentiate between valve 0 and valve 100.

There are some regexp testers on the net, where you can enter your regexp and the event, and check if your regexp works. Note: the events must be in the form device:eventand the Event monitor shows the timestamp and the module type as additional (i.e. not to be entered in the regexp) fields in the output.

The FHT8V won't generate any events directly, as it is a receiver only device, but FHEM will generate an event for each set command.

The regexp for 0 should be devicename:valve.0 and for 100 devicename:valve.100 (untested)

andyclimb

Thanks again for the help.

Using Trigger is a brilliant idea and that solves the issue, of escape characters, so thanks.

Sorry the mytwilight variable was my fault, it should read $MyTwilight.  I was writing code to demonstrate a problem, if I put
fhem (" define abc at +00:10:00 set lamp on")  
It works

if i put
fhem (" define abc at +00:10:00 { fhem(" set lamp on") } ")  
it does not.  

Thanks again rudolf, the device:event.value works perfectly.  Is there any chance of adding that example to the commandref?
I agress the Twilight module seems to do a lot of things that are not documented.  For example there is an unexplained condition event, the Value("MyTwilight") actually goes from 1 to 6 (dawn) 7-12(dusk) and reflects the STATE of the device.  Whereas the ReadingsVal("MyTwilight","light",0) goes from 0 to 6 and then back to 0 again.  I will try a notify

define MyTwilight.notify.dusk notify MyTwilight:value.9 set lamp on

Thanks again everyone for all your help.  

My next mission is to set up database logging.  I used to run an SQL database for fhem and XBMC from my QNAP, but it is not a fast machine.  The new FHEM server is a core-i3 and now host the XBMC SQL database and it is so much faster than the QNAP so i shall try again.  The rPi that used to run FHEM struggled a bit too much I think as well.

Regards

Andrew
AM

Groby

Andrew,

it works this way:

fhem ("define abc at +00:10:00 {fhem('set lamp on')}")

Best regards, Groby