[userMODULE] eaZy Logic for starters

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: [userMODULE] eaZy Logic for starters

Post by pofs »

dolpheen wrote:
pofs wrote:And how would your parser behave if I have device named "all lights"? :)

It will select device 'all lights' in your house (It's really 'all lights' that you want to operate on isn't it? :))
Not quite sure :)
According to the syntax you described, it should select all devices with tag "lights", but it will select only one device (which might even not have a tag). On the other hand, returning only devices with tag "lights" will violate your syntax rule #1 (select by name). And returning all devices (both by tag and by name) isn't probably what user meant, but also possible. That makes your syntax ambiguous.

That's why they use special symbols in CSS selectors :)
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] eaZy Logic for starters

Post by dolpheen »

I suppose to have the device query in more natural lanuage without special characters (the dark plan is to attach a speech engine and be a competitor for HomeKit and Siri :) )
Yes, there could be trade-off between ambigious/unambigious request, but we can provide a choice for user to clarify it.
_z('all lights') - ambigious whether it's device name or selected devices with all tags. The user have 'all lighs' device, but want to select devices by tag. Then he can issue _z('all lights by tag') of _z( 'all lights by tag by tag') if he has device 'all lights by tag' :)
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] eaZy Logic for starters

Post by dolpheen »

So, here is an update (1.0.1) with code optimized and device query patterns extended (with remarks from pofs) )
Now you can do the next selections to operate on

Code: Select all

//select two dimmers from different fooms and set level to 50
_z('lamp on desk in cabinet, dimmer2 in kitchen').setLevel(50) 

// switch 'lamp at entrance' device in room 'hall'
_z('lamp at entrance in hall').on()

//select all devices with 'lights' tag
_z('all lights') 

//select all devices with 'lights' tag in room 'hall'
_z('all lights in hall') 

//select all devices with 'lights' tag in room 'hall' (force tag use if you have 'all lights' device)
_z('all with tag lights in hall'') 

// Select all devices with 'always armed alarms' tag (flood seensor, etc.), arm it and send notification  
// if breached (you can use Javascript functions instead notifications
_z('all Always Armed alarms').arm().onBreach('Alarm!)   
 
// disarm so that you do not recieve notifications 
_z('all general alarms').disarm() 

// The next device selection patterns exist (also can be passed as array)
_z('dimmer1, 'dimmer2, dimmer3', 'wallplug at basement')
The next part - include 'cron module' events handling. :)
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userMODULE] eaZy Logic for starters

Post by pz1 »

Do you plan to write a formal syntax (e.g. in EBNF or similar?) for this?
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] eaZy Logic for starters

Post by dolpheen »

pz1 wrote:Do you plan to write a formal syntax (e.g. in EBNF or similar?) for this?
Not clear, what kind of syntax, do you mean. Ssyntax for device selection query?
All the proposals are welcome at the moment, as I see, an application of this module is to easily create basic and more common used algorithms for automation. (i suppose, biggest part of automation needs can be put in maximum dozen of lines :) but it depends of course)
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userMODULE] eaZy Logic for starters

Post by pz1 »

dolpheen wrote:Not clear, what kind of syntax, do you mean. Syntax for device selection query?
Yes, the syntax for this little automation programming language you are developing. Formally defining contraints and options. Something one does in defining a dtd/schema for an XML document.
Not a priority now, but possibly useful later for a description.
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] eaZy Logic for starters

Post by dolpheen »

pz1 wrote:Yes, the syntax for this little automation programming language you are developing.
I'm not so tough guy at the moment to create new language :) It's just a pure Javascript with some syntactic sugar to handle common task in automation in an easy way. I got what you mean and I'll do some pattern description for query pattern to select devices from systems, thank you for remark.

At the moment I plan to do the next additions:
- with the current patterns it's not easy to select devices with some tags settings at the same time.
So, I propose to use the next parttern.

Code: Select all

// Select devices with 'lights' and 'general switches'  tag and then select only devices with 'second floor' tag from them
_z('all lights').add('all general switches').filter('all second floor').on()

// You can create and mange group of devices
// He we create groups of devices 'room1', 'room2', 'floor1'
var room1 = _z('all in room one');
var room2 = _z('all in room two');
var floor1 = _z(room1,room2);

// Select device by type
// Select battery device (for example to poll them later)
var battery = _z('all with type battery in kitchen')

//Time schedule with cron module like
var _z('switch1', 'valve in basement').cron("1 2 * * monday').switchOn()

//Add toggle function for devices
var _z('switch1').toggle()
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
SolarFlor
Posts: 261
Joined: 22 Mar 2014 15:23

Re: [userMODULE] eaZy Logic for starters

Post by SolarFlor »

dolpheen wrote: Copy and unpack the attached file to your 'userModules' directory of Razberry.
It seems I have not the permission to move files in /opt/z-way-server/automation/userModules

I know it is a stupid question but shoud I change the permission as follow:

chmod -777 /opt/z-way-server/automation/userModules

?
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] eaZy Logic for starters

Post by dolpheen »

Strange, there should be no problem copying files under pi account.
May be try with sudo?
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
SolarFlor
Posts: 261
Joined: 22 Mar 2014 15:23

Re: [userMODULE] eaZy Logic for starters

Post by SolarFlor »

I have tried with filezilla but no permission. see below
Attachments
filezilla.jpg
filezilla.jpg (53.88 KiB) Viewed 11554 times
Post Reply