From bab-tec.de wiki
Cyclic telegram generator
You can use the time sender as a cyclic telegram generator. Many of the jobs in the eibPort need a triggering telegram. If you want to call this jobs cyclic interval just use the time telegrams from the time sender as input.
Counting working hours
So if the time sender has an interval of 60 seconds, the counter holds the approximate minutes, the light was switched on.
astable multivibrator (flip-flop)
17/0 Start (first input NAND)
17/2 second input NAND
17/3 enable/disable (Gateobject)
Sending minimum / maximum daily values
The task to determine a minimum or maximum value per day and to send it via e-mail can be accomplished in a very simple way: every value telegram is compared to the previous reference value for minimum and maximum and will replace the previous reference value if neccessary. Around midnight, this value is sent by mail and reset. The following example explains how to capture a maximum temperature per day.
- Comparator to determine the maximum value
- Weektimer for triggering the lightscene (see below)
- Lightscene for triggering the E-Mail job and resetting the maximum value at midnight
- E-Mail Job for sending the maximum value
Groupaddresses for the following example:
- 16/1 Value Input
- 16/2 Maximum Value
- 16/3 Trigger for E-Mail
- 16/4 Trigger for Scene (sending + resetting value)
With http-Request it is possible to request and process content from websevers or to transmit data to a server. For this purpose the methods GET and POST are avaiable. Thereby the URL (uniform resource locater) is been put together out of different parts, the base URL, the target and the value object(s) resp. the contents as content type. Mandatory fields are 'Element name', 'Input Object' and 'Base URL'. For the processing of the servers' response a module is available which searches the answer with regular expressions and is triggering actions in the KNX bus depending on that.
Control Axis PTZ network camera via http request job
To control an Axis PTZ network camera with a KNX group address you have to use an http request Job.
The commands are documented in the “http request API”. Available on the manufacturer homepage. Here the link for Axis cameras: http://www.axis.com/au/en/support/developer-support/vapix
The PTZ commands are placed under the section “Pan/Tilt/Zoom API” (PTZ). Here the direct download link of the PDF: http://www.axis.com/files/manuals/vapix_ptz_52933_en_1307.pdf
On Page 20 you find the http request syntax you have to use for the PTZ function: http://<ip-address-camera>/axis-cgi/com/ptz.cgi?<argument>=<value>
Parameters: <ip-address-camera> - Give the IP address of the Axis camera. <argument> - Type the command “move” for PTZ function. Find more commands in the table starts from page 20 <value> - Give the possible values for the “move” command. Possible values are “home, up, down, left, right, upleft, upright, downleft, downright, stop” (see table on page 21) control the camera.
See the screen shot of an example http request Job:
To control the camera with the KNX group address 31/0/200 (see example screen shot), trigger the job with the value:
- 0 to move the camera up
- 1 to move the camera down
- 2 to move the camera left
- 3 to move the camera right
Request 'uptime' and 'load' of the eibPort
The URL you will need:
Here is the regular expression with that this is done:
"up (.*), load average: ([\.\d]*), ([\.\d]*), ([\.\d]*)"
The four groups in the expression maps on the four output objects of the job. The datatype of all four outputs has to be EIS 15, otherwise the floating point values will not be shown correctly.
Note: Requesting the load average to often per minute can cause a much more higher load ;)
Request database status of the eibPort
under construction !
Request Weather Data
Weather data can be synchronized from the internet using the HTTP Request job: Weatherdata
The google weather api has been cancelled. This is just the example configuration for the HTTP Request job.
With a request to the google weather data server ("Google weather API") the eibPort gets an XML-file as response. The response is then filtered by the regular expression and the values are handed over by the outputs objects to the visualisation. For the request the following settings are necessary:
Request Type: GET
GET-URL / Post Data: /ig/api?weather=Dortmund
Note: It is important to ensure, that the response of the request is made in the correct language. Is for example "google.de" used instead of "google.com" the response is given in german language.
With the city name behind "weather=" it is defined from which place the weather data is collected. Theoretically it is been possible to change this value dynamically by the help of the value objects.
If the URL of this request is been copied into the browser line and is requested, the response will be shown as an XML-file in the browser window. In our example we want to give out the current weather conditions, the current temperature in celsius, the current humidity and the maximum temperature for the next day. At first we create the expression for every single output, after this we fit them together.
Note: The expressions which are created are best verified with a tool. There are different tools available online, for example: http://dev.radsoftware.com.au/downloads /Rad.RegexDesigner.Setup.1.4.exe. Thereby it is to be considered that some of the flags have another meaning (e.g. Dot All = Singleline).
|Important:||In Mozilla Firefox it might be that you have a space sign behind the expression string when you copy it directly into the array of the job. Is this the case the expression won't work, so please check out exactly what is written in your expression array.|
Current Weather Conditions:
The current weather data is written in the part "<current_conditions>". After it the information "<condition data=" is following. However this is repeated three times in the information "<forecast conditions>". To avoid that the expression is matching on all "condition data=" the string "<current_conditions>" must be prepent.
In order to have success with this expression there must be placed a ".*?" (dot - asterik - question mark) between the proper expression and the string "<current_conditions>" with the flag "DotAll" enabled. The background is, that this two strings are placed in different lines. By the help of the flag "DotAll" the expression is also taking care of the line ends (otherwise it would try to match line by line) and with the ".*?" the behaviour of the expression is "ungreedy".
This is the first group matching, thats why the output opbject 1 is defined as EIS 15 text.
Current temperature in celsius
The output of the current temperature is written behind the string "<temp_c data=". This appears only one time in the whole text. According to that the expression is:
There must no flag be enabled. Because this is an temperature value the output object is been formatted in EIS 5. The data configuration is "ASCII – Unsigned long deicmal".
The output of the current humidity is following behind the string "Humidity:". Should the the response be given in german language at this place is written "Feuchtigkeit" and the expression is not working (equally with other languages).
No flag is enabled for this. This is an percent value, thats why the output object is formatted EIS 6. The data configuration is "ASCII – Unsigned long deicmal".
Maximum temperature of the next day
The forecast for the upcoming days can be found in the section "<forecast_conditions>". There exists an information "high data=" in which the maximum temperature of the respective day is been given out. Certainly this section is existing altogether four times, for each of the following four days. In the recent case we are only interessested into the temperature of tomorrow, that means the first entry of "high data=".
All flags are disabled. This expression is giving out the first entry of altogether 4 matches. As it is a temperature value the output object is again formatted as EIS 5. The data configuration is "ASCII – Unsigned long deicmal".
All outputs in one regular expression
For the reason that 4 outputs objects can be used in one job, it is possible to filter out all above mentioned information with one regular expression and place them by help of the group configuration into the four objects. Thereby it is to be considered that the flag "DotAll" is been enabled, because the expression has to detect end of line. Between the different expression a ".*" is placed each.
<current_conditions>.*?<condition data="([a-zA-ZäÄöÖüÜ\s]+)".*temp_c data="([\-\+]?[0-9]+).*Humidity: ([0-9]+).*?high data="([\-\+]?[0-9]+)
Note: Between the expression for the humidity and the maximum temperature beside the ".*" a question mark must be placed to get the expression "ungreedy".
This section about the math job is listing all current function and operations. Further information you will find in the latest eibPort documentation. It is available in the download area of http://www.bab-tec.de/en/service/download/
The math module is subjected to enhancement as well as the eibPort firmware. At present there are two version: The version 1.1 and the version 1.2. The version number of the module can be requested by the function "version()" of the math job itself. Here is a little configuration example:
Output: 31/7/10 EIS 14 Input: 31/7/11 EIS 1 mathematical operation: version()
If now the math job receives a 1bit telegram on the input 31/7/11 it is giving out the number 17 (stands for 0x11 that means version 1.1) or the number 18 (stands for 0x12 that means the version 1.2).
All functions in math job version 1.1 (0x11)
|+||Addition (resp. stringing together)|
|/||Division (real numbers)|
|%||Modulo (rest of an integer division)|
|&||bit by bit AND operation|
||||bit by bit OR operation|
Logical (boolean) operations
|>||Comparison operation "Greater than"|
|>=||Comparison operation "Greater than or equal"|
|<||Comparison operation "Less than"|
|<=||Comparison operation "Less or equal"|
|==||Comparison operation "equality"|
|<<||Shift left by x places (result = 0x01 << 3 // the result is 0x08)|
|>>||Shift right by x places (result = 0x08 >> 3 // the result is 0x01)|
|&||Bitwise AND (get LSB: result = 0x05 & 0x01)|
||||Bitwise OR (set LSB: result = 0x04 | 0x01)|
|^||Exclusive OR (result = 0x03 ^ 0x01 // the result is 0x02)|
|~||Binary invert (result = ~0x07 // the result is 0x08)|
|'(' and ')'||Parenthesis for changing the operation process|
Built in functions
|sqrt(x)||Square root calculation|
|max(x,...)||Maximum determination of an (finite) amount of values|
|min(x,...)||Minimum determination of an (finite) amount of values|
|rad(x)||Conversion from degrees into radian (sheet calculation)|
|asin(x)||arc sine calculation|
|acos(x)||arc cosine calculation|
|atan(x)||arcus tangens calculation|
|ceil(x)||Calculation of the smallest integer values, which is not smaller than the argument ("round off")|
|floor(x)||Calculation of the largest integer values, which is not larger than the argument ("round down")|
|abs(x)||Calculation of the absolute value of an argument|
|exp(x)||Calculation of the base 'e' exponential function (euler's constant)|
|log10(x)||Calculation of the base 10 logarithm|
|pow(x,y)||Exponential function is calculating x^y|
|time()||Ist giving out the system time in seconds from the beginning of the era (00:00:00 UTC, January 1, 1970)|
|srand(x)||Is setting the (pseudo-)random generator to a definated start value|
|rand()||Delivers the next random value|
|eo_sum(x,...)||Adds the KNX-objects with the numbers according to the arguments|
|int(x)||Is cutting off the real number and delivers only the integer value|
|modf(x)||Delivers the decimal point of a real number (the places behind the decimal point)|
|round(x)||Delivers a correct rounded integer of an real argument|
|round(x, n)||Delivers a rounded value with n decimal places|
Number types and strings:
|Exponential number||1.23e3 für 1.23 * 10^3 oder 1023.0|
|M_PI||The constant Pi (3.14.....)|
|M_E||The euler's constant (Base of the natural logarithm)|
|M_LOG2E||Base 2 logarithm of 'e'|
|M_LOG10E||Base 10 logarithm of 'e'|
|M_LN2||Natural logarithm of 2|
|M_LN10||Natural logarithm of 10|
|M_PI_2||Pi divided by 2 ("Pi-half")|
|M_PI_4||Pi divided by 4 ("Pi-quarter")|
|M_1_PI||Reciprocal value of Pi (1 divided by Pi)|
|M_2_PI||2 times 1 divided by Pi|
|M_2_SQRTPI||2 times 1 divided by root of Pi|
|M_SQRT2||Root of 2|
|M_SQRT1_2||Reciprocal of squareroot (resp. root of 1/2)|
New functions in math job version 1.2 (0x12)
Access on the output value
Configuration of the inputs
- Always: The calculation is been executed as soon as any input is detected at the input objects.
- Never: The calculation is never been executed by this input. Certainly the value of the input object is been considered during the execution of the expression.
- On value change: Only when the input value changes according to the former value, the calculation is been executed.
|~||negate bit by bit|
|!||logical negate (NOT)|
Built in functions:
|eoiga()||Delivers the group address which has triggered the expression (not formatted!)|
|eo_ga(idx, idx_ga)||Delivers the group address of an object unformatted. "idx" defines the index number of the input, "idx_ga" defines the index number of the group address in the object. Both counting is beginng at "0" (from left to right).|
|ga_str(ga, fmt)||Delivers the desired group address (ga = index number) as a string (EIS 15) on the output. With "fmt" 2- or 3-digit notation is been determined.|
|str_ga(str)||Delivers the desired group address as an integer. 2- or 3-digit notation is no important factor.|
|version()||Delivers the version number of the mathematic module. Currently this is "18" = version 1.2 (0x12) and "17" = version 1.1 (0x11).|
|override_addr||If the value of this variable is unequal "0", the original output address is been discarded and the value of this variable is been interpreted as the new output address instead (1-digit notation).|
|override_eis||If the value of this variable is unequal "0", the original datatype configuration is been overwritten by that. Thereby there will be no adjustment of the value.|
|override_skip_send||If the value of this variable is unequal "0", the transmission is been aborted. The running operation comes to no result.|
|override_keep_data||If the value of this variable is unequal "0", not the calculated output value, but the input value which has triggered the operation is been used.|
This examples are showing how the functions, variables and operations are insert into the mathematical expression:
- „eo(1) + 100“ => Returns the value of the KNX-object with the number 1 (mentioned as EO_1 in the following) plus 100. Of course it is important to consider the possible range of KNX-output objects!
- „eo(3)*eo(4)“ => Multiplies EO_3 and EO_4. If there is no group address assigned to a KNX-object an error is been dropped.
- „100 / eo(1)“ => Divides 100 by EO_1. Attention: If a zero is been sent on input 1, the calculation of this expression delivers a run-time-error! ("Division by zero").
- „sqrt(eo(0)^2+eo(1)^2)“ => Is calculating the length of the hypotenuse in a right angled triangle, if on EO_0 and EO_1 the length of the cathetus is been sent. ("Pythagorean theorem")
- „eoi()“ => Returns 2, if on the KNX-Object with the number 2 is received something.
- „eo(eoi())“ => Returns the received value.
- „eo(eoi())^2“ => Is calculating the square of the received telegram value.
- „rand()“ => Returns a random value.
- „rand() & 0xff“ => Limits this value from 0 to maximum 255. So the result can be displayed with EIS 14.
- „srand(time())“ => Returns nothing (resp. zero), but initiate the random generator with a pseudo-random start value.
- „eo(0)+eo(2)+eo(3)+eo(1)+eo(5)+eo(6)+eo(4)“ => Is calculating the sum of multiple KNX-Objects.
- „eo_sum(0,1,2,3,4,5,6)“ => Like above, but much more "runtime friendlier" and insightful.
- „"foo" + "bar"“ => Returns "foobar" as result. This can only be sent as EIS 15 on the output.
- „eo(0)>23?1:0“ => Returns 1 if the value of the input object is above 23 (degrees EIS 5) and 0 if the value is smaller or equal than 23.
- „eo_ga(0,1)“ => Returns the second group address in the first input object (eo(0)) as unformatted number.
- „ga_str(0,2)“ => Returns the group address of the input 1 as string (EIS 15 text) in two digit notation on the output. "...(0,3)" returns the address in three digit notation.
- „str_ga("17/1/2")“ => Returns the number "35074" on the output.
- „override_addr=(eo(0)>10?61482:61480); eo(0)>10?1:0“ => Sends 1 on the address 30/0/42 if the input value is larger than 10, and 0 on the address 30/0/42 if the input value is smaller than 10.
- „override_addr=(eo(0)>10?61482:61480); override_eis=(eo(0)>10?1:9); eo(0)>10?1:2400“ => Sends 1 as EIS 1 (1bit) on the address 30/0/42 if the input value eo(0) is larger than 10, and sends 2400 as EIS 9 (4byte) on the address 30/0/40 if the input value is smaller than 10.
- „override_addr=(5<<11) | (1<<8) | eo(0); 1“ => sends value '1' to the group address 5/1/x, where x is the value of eo(0)
- „override_skip_send=(eo(0)>10?1:0)“ => Is the input value of eo(0) smaller than 10, a 0 is been sent on the output, if the value is larger than 10 the jobs sends nothing.
- „x=(eo(0)>10?1:0); override_keep_data=x“ => Returns a output value from 0 to 10 or the value of the triggering input telegram.
- „version()“ => Returns the current version number of the math job with a arbitrary input telegram.
Triggering Lightscenes with EIS 14
The eibPort lightscene can only handle EIS 1 telegrams and can be started with the value 0 or 1 (depends on the configuration). There are many demands to trigger lightscenes with an EIS 14 value (e.g. value 5 triggers scene 5).
This can be done with the Math job with this formula:
override_addr = (MAIN << 11) | (MIDDLE << 8) | eo(0); 1
MAIN and MIDDLE needs to be replaced with the main group and middle group the lightscene shall be triggered. So if I want to have 10 lightscenes which are triggered with the adresses 1/5/1-10 I'd insert 1 for MAIN and 5 for MIDDLE. The eo(0) is a variable for the first input of the job (with value 1-10). So the first part of this formula build the target group adress which is the trigger for the scene. The last 1 is just the value which will be sent to this address to trigger the scene.
In order to send e-mails with the eibPort at different locations settings has to be made.
E-Mail Provider settings
The e-mail provider settings you will reach by browsing “System” > “Configuration” > “eMail accounts”. There are two mail providers pre-set. Both providers can be used for testing proposals. Overall 10 providers can be set up.
If an individual provider should be used you will need the correct connection data. You will get this data from your e-mail provider, please enter this data according to it. By this you have to consider the following entries:
- Enabled: The entry must be enabled!
- TLS: Please ask you provider which authentication method is required!
- Realm: Means a group of users which accessed to the same server among other groups. Depending on the realm it is differed to which user group the client belongs. If it is not mentioned explicit at this point there is no entry necessary.
- Force default “From:”: Some mail server expect an designated e-mail address in the “From” array. Is an wrong address entered there the dispatch will not work. With the option “Force default “From:” every e-mail is sent with the here entered “From settings”, and not with the one which are entered into the e-mail Job!
By saving the provider the entry automatically gets an ongoing number. In case of the third set provider this is “mail_provider02”. This name is used to link the e-mail job.
In order to have a working e-mail job the provider must be accessible. Beyond the standard configuration it is important to enter the following entries:
- Default gateway: The default gateway is the router which connects the network in which the eibPort is located with another one (mostly the internet). Normally here the address of the local router is been entered (e.g. 192.168.1.1).
- DNS-Server: A DNS Server is responsible for resolving hostnames (e.g. bab-tec.de) into ip-addresses (184.108.40.206) in the network. This service is normally offered by a server outside the own network in the internet. Modern routers (from the home market) dispose certainly over a “DNS forwarding” function and refers the DNS requests from the local network to the corresponding DNS servers. In this case here also the ip-address of the default gateway can be entered.
Another possibility would be to search for the valid DNS server entries in the configuration interface of the router and to transfer them into the eibPort or to use so called “Public DNS server” (e.g. from Google: 220.127.116.11). If the name resolution do not work, the e-mail job cannot resolve the hostname of the provider (e.g. mx.eibport.de) and therefore cannot connect to the e-mail server!
It is recommended always to use the server from you local internet service provider (DSL provider etc.)!
To verify if the connection settings are done correctly you can use the RSS Feed element in the Ajax Visualisation (Control L). Unlike the Java Visualisation the RSS Feed is requested by the eibPort itself and not by the visualisation client. If the RSS Feed is displayed the eibPort can establish a connection to the internet and is able to resolve hostnames!
E-Mail Job settings
In order to trigger an e-mail now only a E-Mail Job is necessary. The E-Mail Jobs are configured at “Editor” - “Job Editor” - “Send eMail”. For the beginning there should be used an easy configuration.
- Fill in the arrays “Job Name”, “Input Group Addresses”, “Receiver”, “Subject” and “Text”.
- Choose a desired “eMail-Provider” (the correct number you will find in the eMail Provider settings s.o.).
- Enter the correct Sender, if this is not done in the provider settings.
The triggering telegram (“Input Group Addresses”) must be an 1bit telegram (EIS 1). As the default send condition of the job is “ON or OFF”, the job reacts either on “1” than on “0”! For testing purpose add a switch element on a visualisation page and trigger it. You should then briefly receive an e-mail in the desired mailbox. Please consider that the e-mail service can be delayed at any time and an e-mail must not be received at once!
If the e-mail dispatch does not work despite all efforts, please contact the bab-tec support at firstname.lastname@example.org.