Logic Machine Forum
Wiser for KNX, hours counter - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Wiser for KNX, hours counter (/showthread.php?tid=1440)

Pages: 1 2


Wiser for KNX, hours counter - Ruslan25 - 11.06.2018

Hello 
I need help with Wiser for KNX.
How to activate hours counter for switch actuator, set limit, after the reaching limit, send email and alarm. Then I want visualize hours counter and how many hours is left? Can i do it with functions block editor?


RE: Wiser for KNX - Daniel - 11.06.2018

Hi
Something like that should do. Load this to FB and select your correct objects and generate.
If this works I can make you email block for FB as there is none at the moment.
BR


RE: Wiser for KNX - Ruslan25 - 11.06.2018

(11.06.2018, 11:25)Daniel. Wrote: Hi
Something like that should do. Load this to FB and select your correct objects and generate.
If this works I can make you email block for FB as there is none at the moment.
BR
Thanks, I'll try


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

Hi
Here is the email block
To add it first go to Scripting -> User libraries and import this library.  You have to edit it and set your email account parameters



Code:
-- "from" field, only e-mail must be specified here
   from = 'example@gmail.com',
   -- smtp username
   user = 'example@gmail.com',
   -- smtp password
   password = 'mypassword',
   -- smtp server
   server = 'smtp.gmail.com',
   -- smtp server port
   port = 465,
   -- enable ssl, required for gmail smtp
   secure = 'sslv23',

It should looks like the json attached in FB
BR


Wiser for KNX, hours counter - Ruslan25 - 12.06.2018

Where you find function “send email” in FB editor?


Skickat från min iPhone med Tapatalk


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

(12.06.2018, 12:12)Ruslan25 Wrote: Where you find function “send email” in FB editor?


Skickat från min iPhone med Tapatalk

Once you import the library it will be under User.FB_Email


Wiser for KNX, hours counter - Ruslan25 - 12.06.2018

Thanks a lot. One more question.
Under setpoint you wrote 20 and its in seconds, how can I convert to hours. Because I want visualize how many hours is left


Skickat från min iPhone med Tapatalk


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

(12.06.2018, 14:11)Ruslan25 Wrote: Thanks a lot. One more question.
Under setpoint you wrote 20 and its in seconds, how can I convert to hours. Because I want visualize how many hours is left


Skickat från min iPhone med Tapatalk

To be honest with you I never ever used this block Smile.  I looked on the code behind and it is already in hours. 

Code:
   local hours = (os.time() - start) / 3600
   return hours, setpoint - hours, hours > setpoint and true or nil
The 20 should be 20 hours


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

And? This is just how the end scripts looks like, The one I checked is the function used by this script. This is where all the calculation is actually hiding.


Wiser for KNX, hours counter - Ruslan25 - 12.06.2018

Do you mean under common functions?


Skickat från min iPhone med Tapatalk


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

(12.06.2018, 15:00)Ruslan25 Wrote: Do you mean under common functions?


Skickat från min iPhone med Tapatalk

No  apps have their own library and you don't see them anywhere by default.  If you really want to look you can import them in  user libraries from here.
https://forum.logicmachine.net/showthread.php?tid=818&pid=4849#pid4849
You are looking for the last one.


RE: Wiser for KNX, hours counter - Ruslan25 - 12.06.2018

Sorry, I mean that remaining time is in seconds

(12.06.2018, 15:11)Daniel. Wrote:
(12.06.2018, 15:00)Ruslan25 Wrote: Do you mean under common functions?


Skickat från min iPhone med Tapatalk

No  apps have their own library and you don't see them anywhere by default.  If you really want to look you can import them in  user libraries from here.
https://forum.logicmachine.net/showthread.php?tid=818&pid=4849#pid4849
You are looking for the last one.

Which data type should I use for hours counter?


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

No it is in hours. Setpoint - hours = Remaining. This is the second parameter in the function I posted.


RE: Wiser for KNX, hours counter - Ruslan25 - 12.06.2018

(12.06.2018, 15:51)Daniel. Wrote: No it is in hours.  Setpoint - hours = Remaining. This is the second parameter in the function I posted.

Interesting that hours counter in hours, but remainig time is in seconds, under Objects - current value


RE: Wiser for KNX, hours counter - Daniel - 12.06.2018

Ok you interest me to check it myself. It looks like the block posted in the forum do not match what it is actually in the FB Editor.
Import the library from forum and replace existing block by the one from user library. It will be in hours then. I will check with the source why it was changed. Or you can use divide block to divide it by 3600 then it will be in hours too.


RE: Wiser for KNX, hours counter - Tokatubs - 15.06.2018

I ran your script Daniel and works good.

But i want to just trigger and send an alarm, lets say when an temperatur goes higher than 20.
I was thinking of linking the temp to an "greater than" and use a value for the input 2. I guess this will trigger the alarm.
But i would like to send the value as well as the message text?

Is there some solution for this..


RE: Wiser for KNX, hours counter - Daniel - 15.06.2018

Try using the combine text block from strings. Not sure if it will accept numbers or if you also have to convert it with int to str


RE: Wiser for KNX, hours counter - Tokatubs - 15.06.2018

(15.06.2018, 13:02)Daniel. Wrote: Try using the combine text block from strings. Not sure if it will accept numbers or if you also have to convert it with int to str

I did some testing. And ended up with an Greater then block, combine text and Send email.

Which seems to work great with the result i want.

BUT i made an output 9/3/1 group in Logic Machine to send the output. But this keeps changing without the "Greater than" block has any change. Watchable in the linked video. I really dont understand why it keeps changing. .

Any idea would be highly appreciated  Smile

I could not attach an wmv so i put it to an ddropbox folder..

https://www.dropbox.com/sh/c131ixflgi1thjm/AAA_JC7QrGTMOEcMrgzVTdIXa?dl=0


RE: Wiser for KNX, hours counter - Daniel - 18.06.2018

Hi
Save your diagram in json and drop here please. The timer value maximum value is 60, not sure why you were able to make so bug one.
BR


RE: Wiser for KNX, hours counter - Tokatubs - 18.06.2018

(18.06.2018, 07:28)Daniel. Wrote: Hi
Save your diagram in json and drop here please.  The timer value maximum value is 60, not sure why you were able to make so bug one.
BR

Here is the json file. Thanks for the help..