Categories
CAN4VSCP Paris the VSCP Daemon

How to schedule events/schemas with the daemon #Iot #m2m #vscp

I got the following question from a VSCP users

  • How to turn on lights at sunset.
  • How to turn off the lights at a specified time (either sunset + x hrs, or for example at YY:ZZ).
  • How to turn on at a certain time.
  • How to turn off at sunrise.

So the easiest way to demonstrate this capability of the VSCP daemon  is to show the setup I have here in our house for this. Oh well part of it of course, we should not go to far away from the topic.

Some background

Yes I use VSCP based devices for some things here in the house but just as the shoemakers children have holes in there shoes I am often stuck at fixing things for others before I can do something for myself.  So here it is a lot of  my setups are test setups that are replaced by other test setups that are replaced by even other test setups  etc in a never ending story. Its the just the way it is  for makers I guess.

But some things I use here at least and that is I schedule the lamps in the house so they turn on at sunset and turn off at sunrise and some other things. So the questions above is easily by explaining my own setup.

Now I could have used a Paris module to control lamps and I actually do here in the office but just in a test setup . In our house and for lamps on the  outside I use low cost wireless modules from Nexa and Proove

large

nexa-infalld-fjarrstrombrytare-1000-w

Well you all recognize them. Low cost single way communication modules working over 433 MHz.  Reliable enough for lights IMO. But they could of course equally well have been Z-Wave, KNX, X10 or some other solution.

The CAN4VSCP Roma module will control these things and it sits on my desk at the moment working pretty well. It will be available in the store also one day I hope.

At the moment I us a Tellstick  from Telldus AB to control  lights connected this way. There are other similar products available and Arduino solutions that can do it as well

TellStick_1-600x600_0

Well this solution just let me execute a binary on a Linux machine to turn on/off a group of lamps.  There are similar devices available for all other vertical solutions. So to control KNX units with the VSCP daemon find an executable that can do that and the same for Z-Wave (OpenZwave) or whatever solution you want to integrate. Or write your own script or executable that does it. It is usually not a big deal.

But it of course does not end with an executable. The VSCP daemon can do many other things. Call an URL/send events/start timers etc etc. You can add anything and you should be able to add everything because the world consist and will consist of many different things,

Turn on lights at sunset

So lets look at the first point. This can be done in many ways of course but if you enter the coordinates for your location in the VSCP daemon configuration file  (dm.xml) in the Automation section  the decision matrix will be feed with two events that are of interest for this  type of control

CLASS1.INFORMATION, Type=45, Sunset

Sent when astronomical sunset happens at the location set by the coordinates.

CLASS1.INFORMATION, Type=35, Sunset-Twilight

Sent when astronomical sunset-twilight happens at the location set by the coordinates. The definition of twilight is

Nautical twilight is the period when the center of the Sun is between 6 and 12 degrees below the horizon, when bright stars are still visible in clear weather and the horizon is becoming visible. It is too dark to do outdoor activities without additional lighting.

You have to enable the events also if they are disabled in the configuration file.

Restating the VSCP daemon with

/etc/init.d/vscpd restart

and then opening

http://192.168.1.6:8080/vscp/configure

in your web browser (replacing 192.168.1.6 with your server ip) will show you the calculated times

Screenshot from 2016-01-31 16:17:53

We see that today when this is written the sunset is at 15:57 and the sunset twilight is at 16:44 two times one can use to turn on lights because it’s getting dark outside.

For indoor light I use sunset and for outdoor light I use twilight sunset for this.  It all of course depends on how dark one want it to be before lights are turned on.

So setting this up in the web interface

Screenshot from 2016-01-31 16:25:23

Priority has flags set to zero so we don’t care about it.

Class is set to 20 which is CLASS1.INFORMATION and corresponding  flags are set to 0xFFFF meaning all bits should be checked.

Type is set to 45 which is Sunset and corresponding  flags are set to 0xFFFF meaning all bits should be checked.

GUID has mask all set to zero so we don’t check it.

On control we see that we don’t check index/zone/subzone but that we enable this row.

So at this point we say that events of type   CLASS1.INFORMATION, Type=45, Sunset  will perform what ever action we choose.

Screenshot from 2016-01-31 16:25:37

In the “when-section” we select when the action should happen. Her from the beginning of time to the the end of time and all weekdays and all times.  As you see it is possible to have different schemas for different weekdays and for different time of year.

Screenshot from 2016-01-31 16:25:48

And then we have the action to perform. In my case I execute an external file and turn on lamps in section 1. But there are many actions to choose from and Send Event is one. Typically used in his case to send to a group of Paris modules to instruct them to switch some relays on.

You can have many rows that trigger on the same event and therefore easily mix technology and control KNX, Z-wave, VSCP and other alongside each other.

The XML row for this scenario looks like this

<row enable=”true” groupid=”Tellstick” >
<mask priority=”0″
class=”65535″
type=”65535″
GUID=” 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00″ > </mask>
<filter priority=”0″
class=”20″
type=”45″
GUID=” 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00″ >
</filter>
<control>0x0</control>
<action>0x10</action>
<param>/usr/local/bin/tdtool –on 1
<comment>Turn on window ligts when sun goes down</comment>
<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>
<index bMeasurement=”false” > 0</index>
<zone>0</zone>
<subzone>0</subzone>
</row>

Turn off at sunrise

To turn off lights at sunrise just trigger on CLASS1.INFORMATION, Type=44, Sunrise or  CLASS1.INFORMATION, Type=52, sunrise twilight time.  The rest is the same as the above case.

Turn off the lights at a specified time

Here in this house I turn of some lights for the night at 02:00 regardless. This is how that is done

Screenshot from 2016-01-31 16:55:11

Priority is not used and therefore it’s corresponding  flags are set to zero.

Class is set t 65535 which is CLASS2.VSCP. The corresponding flags are set to all ones or 0xffff.

Type is set to 6 and that means we will trigger on CLASS2.VSCP, Type=6, Minute events. This event is feed through the matrix every minute. The corresponding flags are set to all ones or 0xffff.

GUID has mask all set to zero so we don’t check it.

On control we see that we don’t check index/zone/subzone but that we enable this row.

Screenshot from 2016-01-31 16:55:30

Again in the “when-section” we select when the action should happen. Her from the beginning of time to the the end of time and all weekdays.  The difference here frm the previous example is the

*-*-* 02:00:00/10/20/30/4/50

The

*-*-*

says the action will be triggered on every date.  If we want a specific thing to happen just on x-as eve we enter that here.

02:00:00/10/20/30/4/50

This part could have just been

02:00:00

meaning trigger at that time. But here we added some more times we now trigger on

02:00:00
02:00:10
02:00:20
02:00:30
02:00:40
02:00:50

that is on several times ten second apart.  A way to enter this without having a new DM row for each. This is possible on all fields in allowed time. So it is easy to do things at certain days of the month etc.

For the curious I did this so lights definitely will be turned off as I had some interference with the radio signal some times.

Screenshot from 2016-01-31 17:12:19

And then again we have the action which in this case turn off section 1 instead of on.

And yes turning on something at a certain time is just the same but with another action and also here one can send events or do other things.

The xml line looks like this

<row enable=”true” groupid=”” >
<mask  priority=”0″  class=”65535″  type=”65535″  GUID=” 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00″ > </mask>
<filter  priority=”0″  class=”65535″  type=”6″  GUID=” 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00″ > </filter>
<control>0x0</control>
<action>0x10</action>
<param>/usr/local/bin/tdtool –off 1;
<comment>Turn off window lights @ 02:00</comment>
<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>*-*-* 02:00:00/10/20/30/40/50</allowed_time>
<index  bMeasurement=”false”  > 0</index>
<zone>0</zone>
<subzone>0</subzone>
</row>

 

The future

Time time is a resource that is limited.  When I did the DM of the VSCP daemon a long time ago an external nice and user friendly interface to edit it was planed. Not the web based interface that is available to day which is targeting a technical user.  Actually editing is possible remotely also today so it is only the UX code missing.  That will probably come in place one day. Giving this functionality the attention and usability it deserves.

An even more exciting feature that will come to this functionality, probably in the next release, is scripting right inside the VSCP daemon. That will make this an extremely cool cat.

Hopefully this gave some lights of the magic’s of the VSCP daemon DM.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.