Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Can I do time calculation, without using epoc format?


Question

Posted

 

I want to subtract "tid_entre" from "tid" and check if it is longer than "entre".
 

Please login or register to see this code.

 

Is it possible to do this without using epoc numbers for time?

 

 

11 answers to this question

Recommended Posts

  • 0
Posted

 

Please login or register to see this image.

 

 

or 

 

sWNjjrc1EK.png

 

so. my question is: what is wrong here?

 

Please login or register to see this code.

 

Please login or register to see this code.

 

  • 0
  • Inquirer
  • Posted (edited)

    I have a working scene that looks like this (deleted the rest of the sensors):

    Please login or register to see this code.

     

    What I try to find out; is it possible to do this by using:

     

    Please login or register to see this code.

    and compare it with a variable stored in the same format?

    Or must all calculations be done with epoch time format and then convert it to readable format?

     

    Trying to see if I can solve this by using only readable time format in the code/variable.

     

     

    @

    Please login or register to see this link.

    What program have you used in the first picture?

    Looks like a good program to explore code, before copying it into Fibaro window.

    Edited by Teza
    • 0
    Posted

     

    13 minutes ago, Teza said:

    and compare it with a variable stored in the same format?

    Or must all calculations be done with epoch time format and then convert it to readable format?

    1

     

    Please login or register to see this code.

    simple use this function,.

     

    14 minutes ago, Teza said:

    What program have you used in the first picture?

     

    1) 

    Please login or register to see this link.

    2) install

    3) add plugin 

    Please login or register to see this image.

    4) so. now you can simply write and debug any LUA programmes

    final step

    5) create a folder for example : D:\My Documents\LUA

    6) create sub folder here libs. D:\My Documents\LUA\libs

    7) unpack this arch here (attach) (no malware/viruses)

    8) back yo up D:\My Documents\LUA

    8) create fibaro.lua file with content here


     

    Please login or register to see this code.

    9) open VScode. create file test.lua 

     

     

    Please login or register to see this code.

    F5

     

    10) yay!

     

    2SdDxl1vPz.png

     

     

     

    Please login or register to see this attachment.

    UPD: 

    fibaro_emu.lua in archive.

    modify!

     

    local hc2IPAddress = "192.168.1.36"
    --

    Please login or register to see this link.


    local hc2AuthHash = "b2xlZy5kZW5pc2Vua29AZ21haWwuY29tOjEwZGVyU3VwcG9ydA=="
     

    • Thanks 1
    • 0
  • Inquirer
  • Posted
    5 minutes ago, 10der said:

     

     

    Please login or register to see this code.

    simple use this function,.

     

     

    Thanks, simple depends on the knowledge of the user.

    For every line of code I write, i spend quite some time with google  :)

     

    Now I will only have to understand your solution, and most likely have a code that can be very useful for me in the future.

    • 0
  • Inquirer
  • Posted
    12 hours ago, 10der said:

     

    Please login or register to see this code.

    simple use this function,.

     

    Still struggling to figure out how to implement this code.

    But it makes me wonder if the same code can be used to avoid repeating my code all the time.

     

    For example the following code:

    Please login or register to see this code.

     

    I don't like to repeat the same code for each sensor/variable:

    Please login or register to see this code.

     

    I think this is a bad way to do things, and I believe it can be done smarter with a better code.

    And therefore I wonder if your code can be adapted to simplify the code above?

    • 0
    Posted

    OMG!

     

    sample one

    Please login or register to see this code.

     

    sample two

     

    Please login or register to see this code.

     

    sample three

     

    Please login or register to see this code.

     

    sample four

     

    Please login or register to see this code.

     

     

     

     

    • Like 1
    • 0
    Posted
    1 hour ago, 10der said:

    fibaro:forum("@10der", "Hey! friend! can you re-write my code for beer?");

    I'm developer :) Don't hesitate to call if you need me. :)

     

    Hi @10der,

     

    didn't you ask for it? :-D

     

    • Like 1
    • 0
    Posted
    Just now, Bodyart said:

     

    didn't you ask for it? :-D

     

     

     

    You are the best!

    • Like 1
    • 0
    Posted
    1 hour ago, 10der said:

    fibaro:forum("@10der", "Hey! friend! can you re-write my code for beer?");

    Just excellent !!:-D

    • 0
    Posted

    @10der,

     

    almost :-D

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted
    7 minutes ago, 10der said:

     

    Please login or register to see this code.

     

     

    Sorry mate, don't think that amount of beer is good for any person  ;)

    Thank you, finding out about this on my own would most likely taken me months.

     

     

     

    Forgot to submit the reply, to busy with google functions, strings, arguments and predefined classes.

    I thought is was way more complicated than including the function and simply use hm2sec(forsinkelseEntre).

     

    Trying to get a grasp on what is really going on in the code, before continuing on example three :) 

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...