Categories
HowTo's

#VSCP howto: Compare values without coding

Measurement events is a central part of any VSCP system of course. The standardisation of measurement makes it possible to hook in parts to a system and read write measurement values in a deterministic way.

The VSCP server can collect measurements from many sources, it can convert them, send them further to other destinations, save them in databases, diagram data,  well, do a lot with the values of measurements.

Many time one want to compare measurement values.  If a certain value is bigger than a set point an alarm may be sounded or some other action may be needed. Usually this is functionality that is handled by program code. This is possible in VSCP also of course. You can even put this code inside the VSCP server using Javascript or Lua or outside in executable files written in any language. But comparing measurement values is also build right into the decision matrix (DM) mechanism of the VSCP server also.

I show the XML format for setting this up here but the database can be used in the same way.

Every DM configuration row can have a measurement part that looks something like this

<measurement compare="eq"
                 unit="1"                                           value="5.014567" />

If this tag is in a DM row  additional checks will be performed on an event before an action is triggered. Here the value of the measurement will be compared to the value 5.014567  for equality and if they are equal AND the unit is the same (here 1) the action will be triggered.

A typical full row for a temperature check will look like

<row enable="true" groupid="measurement_compare_test" >

<comment>
 Test measurement compare: eq
 </comment>

<mask priority="0"
 class="0xFFFF"
 type="0xFFFF"
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<filter priority="0"
 class="10"
 type="6"
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<action>0x10</action>
 <param>
     scripts/alarm.sh "match"%event
 </param>

<index measurementindex="true">1</index>

<!-- eq|neq|gt|gteq|lt|lteq -->
 <measurement compare="eq"
 unit="1"
 value="5.014567"/>

</row>

Here we have a row that will execute the external script alarm.sh when a temperature event with a temperature   given in degrees Celsius (unit=1) is received and the measurement value is equal to  5.014567

You can of course trigger other actions instead. Send another event, run a Javascript or a Lua script, do an http page post…

As you probably have expected  you can do other compares to,  like greater than, less than and so on. They are all listed here.

If you want to play further with this you have some test setups here.

More info about the decision matrix in the VSCP server is here and info about general decision matrix logic in VSCP is here.

Stay Hungry, stay foolish!

 

Categories
IoT M2M

20 billion connected #IoT devices by 2023… more than two will be #VSCP based

https://www.ericsson.com/en/mobility-report/reports/november-2017/internet-of-things-outlook?utm_source=twitter&utm_medium=organic?utm_campaign=iot_mobilityreport2017&hootPostID=9e5bf633465999b69c18d3ac6f7e191a

Categories
General

LG01 LoRa OpenWrt IoT Gateway

Nice an open LoRa gateway.

https://www.tindie.com/products/edwin/lg01-lora-openwrt-iot-gateway/?utm_source=twitter.com&utm_medium=referral&utm_content=tweet&utm_campaign=product_back_in_stock_tweets

Categories
Sponsoring

New donation to the #VSCP project

We today got a EUR 20 donation from Iain Galloway to  the project.

Thank you!

Categories
Open Source Programming

Why we never thank open source maintainers

https://windsooon.github.io/2017/11/23/Why%20we%20never%20thank%20open%20source%20maintainers/

 

Categories
Sponsoring

Donation

We today got a EUR 75 donation from https://superbwebsitebuilders.com/  to
the project.

Thank you!

Categories
HowTo's

#VSCP Howto: Do something every five minutes

The when selection block of the decision matrix of the VSCP server looks like this

<allowed_from>0000-01-01 00:00:00</allowed_from>
<allowed_to>9999-12-31 23:59:59</allowed_to>
<allowed_weekdays>mtwtfss</allowed_weekdays>
<allowed_time>*-*-* *:*:*</allowed_time>
allowed_from – allowed_to

Here the action is allowed to is allowed from prehistoric times and way into the future. We can say it is allowed to occur forever/always. This is always specified in a time range pair <allowed_from> and <allowed_to>. To say forever/always you can also use a ‘*’ like in

<allowed_from>*</allowed_from>
<allowed_to>*</allowed_to>

which also means forever. Leaving them out and not specifying an allowed time range at all also will be interpreted as forever/always.

allowed_weekdays

The next thing you can do is to select which weekdays the action can occur at. This is always seven characters or a ‘*’ meaning every weekday.  Again leaving it out also means all days.

Some samples

Every day of the week <allowed_weekdays>mtwtfss</allowed_weekdays>

Every day of the week <allowed_weekdays>*</allowed_weekdays>

Only on mondays <allowed_weekdays>m------</allowed_weekdays>

Mondays and Fridays  <allowed_weekdays>m---f--</allowed_weekdays>
allowed_time

The last tag the <allowed_time> gives most control of when the action should occur. You can be VERY specific as in

<allowed_time>2028-12-02 14:32:30</allowed_time>

and the action can only happen this specific year, date and time down to the second. The allowed date range must always be valid and also the weekday must be set to allowed on this day.

You can also be looser and specify

<allowed_time>2028-*-* *:*:*</allowed_time>

which is anytime in year 2028.

But you can also specify

<allowed_time>*-*-* *:30:*</allowed_time>

which means that things can occur every half hour.

For anytime you can specify

<allowed_time>*</allowed_time>

or

<allowed_time>*-*-* *:*:*</allowed_time>

oer leave the tag out all together.

So how do one specify that something should happen every five minutes?

Just specify

<allowed_time>
*-*-* *:0/5/10/15/20/25/30/35/40/45/50/55:*
</allowed_time>

and trigger on the internal minute event with.

<mask priority="0" 
 class="0xFFFF" 
 type="0xFFFF" 
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<filter priority="0" 
 class="0xffff" 
 type="6" 
 GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

It’s as easy as that and you can of course use this technique for the other parts of the allowed_time tag as well.