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


Recommended Posts

Testing Telegram setup, get this error but message arrives anyway. 

Please login or register to see this image.

/monthly_2019_08/285833939_Skrmavbild2019-08-11kl_12_47_53.png.ffa627d4b6c605bcaa124a089c2162dd.png" />

Link to comment
Share on other sites

Guest kallecux

Hello!


I'm really trying to connect to Node-Red, but without success.

This is my structure:

 

Please login or register to see this code.

and in Node-Red i have this simple flow:

 

Please login or register to see this image.

/monthly_2019_08/379482671_Bildschirmfoto2019-08-11um15_01_31.png.9cfce314d5291ed578a17bbfacc154c1.png" />

 

with this details:

 

954212966_Bildschirmfoto2019-08-11um15_05_41.png.82ffe4f27c8d601344612c44619c309e.png

 

There is no debug-Output.

Do you have any tip?

 

Thanks!

 

 

 

 

 

Edited by kallecux
Link to comment
Share on other sites

  • Topic Author
  • 2 hours ago, kallecux said:

    Hello!


    I'm really trying to connect to Node-Red, but without success.

    This is my structure:

     

    Please login or register to see this code.

     

     

    Sure port is 1880 and not 8080?

    Btw, I posted v3 B46 that has better error messages if a request to nodered goes wrong (http request)

    4 hours ago, jompa68 said:

    Testing Telegram setup, get this error but message arrives anyway. 

    Please login or register to see this link.

    The "Handshake error" seems to come from inside http:request(...) ?

    The "network unreachable" is what the error handler for the http:request gets back. I'm a bit clueless as I haven't seen this before.

    Is it this way with every request?

    Link to comment
    Share on other sites

    Guest kallecux

    Yes, i am using Port 1880 by default.

     

    When i shutdown Node-Red i get this:

    Please login or register to see this code.

    thats OK. When Node-Red is running i get this in the Node-Red logfile:

     

    Please login or register to see this code.

     

    401 means unauthorized?

     

    My Node-Red config is like this:

     

    Please login or register to see this code.

    Sorry for the "Node-Red questions".....

    Edited by kallecux
    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, kallecux said:

    Yes, i am using Port 1880 by default.

     

    When i shutdown Node-Red i get this:

    Please login or register to see this code.

    thats OK. When Nord-Red is running i get this in the Node-Red logfile:

     

    Please login or register to see this code.

     

    401 means unauthorized?

     

    My Node-Red config is like this:

     

    Please login or register to see this code.

    Sorry for the "Node-Red questions".....

     

    No, problem. 

    Ok, it seems like you run with ssl (requiring https) which ER is not using (only unauthorised http)

    The HC2 is in general doesn't support https so that's why https is not done from ER.

    We could support some basic authentication but there had been no need for it so far as most run their nodered on the home network close to the HC2.

    Can you try to turn off ssl for nodered and see if it works.

    Link to comment
    Share on other sites

    Guest kallecux

    No better result :-(

     

    I think it's a problem with my Node-Red instance or my environment. 

    I try a fdisk and format C:/ and make an new Node-Red installation ;-)

    Thank you for your help.

    Greetings

    Karl Heinz 

    Link to comment
    Share on other sites

  • Topic Author
  • 20 hours ago, kallecux said:

    No better result :-(

     

    I think it's a problem with my Node-Red instance or my environment. 

    I try a fdisk and format C:/ and make an new Node-Red installation ;-)

    Thank you for your help.

    Greetings

    Karl Heinz 

     

    I run node-red on a Raspberry-PI as an app started from the Raspberry desktop, I believe that @jompa68 may run it from a container on a PC server...

    Link to comment
    Share on other sites

  • Topic Author
  • Pushed v3, B49.

    It turns out that net.HTTPClient():request(...) in scenes, due to its asynchronous behaviour, can cause some issues.

    Code that sent many request to Hue, flooded the bridge and commands where ignored. 

    I solved that with a hack that queued  the Hue requests in B43. Queueing means we don't send a request before we get a call-back to our success (or error) handler...

    Well, it turns out you can DDos Telegram and Nodered also by sending requests too quick.

    The sense moral of this is that we should never send request to an external server quicker than we get responses back.

    So, I implemented a generic queuing replacement for net.HTTPClient():request(...) and is using that now for Hue, Telegram, and Nodered.

    I have made some initial testing and it works quite well (the throughput is still good).

     

    The other big change in B49 is that support for Event.postRemote(url, event) or Rule.eval("remote(<url>,<event>) is removed.

    Now postRemote/remote only accepts a numerical sceneID as the first argument and is only used to send events between scenes.

    It was possible to use postRemote/remote to send events to Nodered in the past but now that should be handled through Nodered.post(event)

     

    If you have some issues, including strange error messages from the services, let me know.

     

    Link to comment
    Share on other sites

    Good, was about to write a post regarding this. Did see that yesterday morning. Will update now and report back if still an problem

    Link to comment
    Share on other sites

  • Topic Author
  • Sorry,

    managed to introduce a bug in postRemote

    Pushed v3, B50.

    Link to comment
    Share on other sites

    Did get an question from @jgab today about "tradfri" devices and if i have tried to add them to a hue bridge. So was not the case, i did not know that was possible even.

    After few minutes of reading on google i did give it a try. 
    Firmware needs to be latest on your "tradfri" device, they need to be removed from their default gateway and reseted to factory default, then it is possible to add them to hue bridge.

     

    So now i can handle them easy like other hue devices in ER. How cool is that ?

    (an example how i use them, start or stop charging our phones during sleep time.)

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • 22 minutes ago, jompa68 said:

    Did get an question from @jgab today about "tradfri" devices and if i have tried to add them to a hue bridge. So was not the case, i did not know that was possible even.

    After few minutes of reading on google i did give it a try. 
    Firmware needs to be latest on your "tradfri" device, they need to be removed from their default gateway and reseted to factory default, then it is possible to add them to hue bridge.

     

    So now i can handle them easy like other hue devices in ER. How cool is that ?

    (an example how i use them, start or stop charging our phones during sleep time.)

    Please login or register to see this code.

     

    Cool!

    Btw,

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Just update to 3.0 B52

    And its something wrong with this version.

    Please login or register to see this image.

    /monthly_2019_08/image.png.5034118eb2ebb328d3f46bc4d2d27f5c.png" />

     

    Rolled back to 3.0 B51 and it works again.

    Edited by sonnyboy
    Link to comment
    Share on other sites

  • Topic Author
  • 19 minutes ago, sonnyboy said:

    Just update to 3.0 B52

    And its something wrong with this version.

    Please login or register to see this link.

     

    Sorry, pushed V3, B54 with a fix.

    Link to comment
    Share on other sites

  • Topic Author
  • Here is a list of the commands/constructions that are available in EventScript in ER v3 B58.

    I will come back to this post and add more documentation.

     

    Grammar

    Please login or register to see this code.

    Rules:

     

    Script rules comes in four main flavours, and always contain a '=>'

    Please login or register to see this code.

    Rules are expressed as Lua strings and are compiled and registered with the function Rule.eval(<rule string>)

    Later when matching conditions are met the rule is executed - conditions are on the left-hand side of the '=>' and actions on the right-hand side

    Expression given to Rule.eval without an '=>' is evaluated immediatly.

    Please login or register to see this code.

    @time -- always part of a rule. Run action at time of day

    Please login or register to see this code.

    @{t1,...tn} -- always part of a rule. Run action at times of day

    Please login or register to see this code.

    @{catch,t1,...} -- if the first argument in the time parameter list is the constant 'catch' the framework tries to catchup actions that have already passed when the framework starts up

    Please login or register to see this code.

    @@intervall -- always part of a rule. repeat action at specified interval

    Please login or register to see this code.

    #event -- event triggering rule.

    '#foo' is a short for {type='foo'}

    '#foo{bar=9}' is a short for {type='foo', bar=9}

    Please login or register to see this code.

    Matching with constraints are allowed in event values and start with '$..'. Variables bound in matching expression available as local vars in rest of rule.

    Please login or register to see this code.

    'env' -- script variable that is bound the the environment the script is executing in. Specifically env.event is the event (sourceTrigger) that triggered the rule.

    Please login or register to see this code.

     

    User functions:

    • Time constants
      Time constants are converted to seconds.
      This allows for arithmetics like Rule.eval("11:20 == 10:30+00:50")
      • HH:MM[:SS], 10:20 == 3600*10+60*20
      • +/HH:MM[:SS],  Add time to current time. +/10:20 == os.time()+3600*10+60*20
      • t/HH:MM[:SS],  Epoc of time today. t/10:20 == midnight+3600*10+60*20
      • n/HH:MM[:SS], Epoc of next 10:20. Today if it's before 10:20 and 10:20 tomorrow if it's after 10:20
      • YYYY/MM/DD/HH:MM[:SS], Long form for Epoc. Ex. 2020/03/01/10:20
    • Arithmetic operators
      • %,*,+,-,/ - Normal operator precedence is used and parentheses is also allowed 
      • Please login or register to see this code.

      • '+=','-=','*=' - increment and assign. works with variables only
      • Please login or register to see this code.

    • Comparison operators
      • <,<=,==,>,>=,~=
      • Please login or register to see this code.

         

    • Logical operators
      • &,|,!
      • Please login or register to see this code.

         

    • Date and day related
      • HM(<time), converts a time to string  "HH:MM"

        Please login or register to see this code.

         

      • HMS(<time), converts a time to string  "HH:MM:SS"

        Please login or register to see this code.

         

      • now, seconds since midnight

        Please login or register to see this code.

         

      • midnight, epoc for last midnight

        Please login or register to see this code.

         

      • dawn, seconds from midnight to dawn
      • dusk, seconds from midnight to dusk
      • sunrise, seconds from midnight to sunrise
      • sunset, seconds from midnight to sunset
      • wnum, week number
      • date(<string>), cron test
      • day(<string>)

        Please login or register to see this code.

         

      • month(<string>)
      • wday(<string>)
      • osdate(<string>)
      • ostime(), current time in epoc (midnight+now)
      • time(<string>), converts time string to seconds
    • Table operations
      • add(<table>,<element>)
      • remove(<table>,<index>)
      • size(<table>)
    • Mathematical functions
      • rnd(<n1>,<n2>)
      • round(<number>)
      • sign(<number>)
      • average(<table>)
      • max(<table>)
      • min(<table>)
      • sum(<table>)
      • sort(<table>)
    • Type and name functions
      • num(<element>)
      • idname(<deviceID>)
      • str(<element>)
      • type(<element>)
    • Log and formatting
      • log(<string>,...)
      • fmt(<string>,...)
      • fjson(<string>)
      • tjson(<table>)
    • Rule and event functions
      • post(<event>,<time>)
      • cancel(<post ref>)
      • remote(<sceneID>,<event>)
      • publish(<event>)
      • subscribe(<event pattern>)
    • Managing fibaro globals
      • global(<string>)
      • listglobals()
      • deleteglobal(<string>)
    • VD functions (only HC2)
      • label(<deviceID>,<tag>)
      • label(<deviceID>,<tag>)=<string>
      • slider(<deviceID>,<tag>)
      • slider(<deviceID>,<tag>)=<string>
      • VDev.define(<name>,<tag>,<version>,<rows>)
      • VDev.remove(<tag>)
      • VDev.clearCache()

    • EventScript  functions
      • env - variable that contains the event that has triggered the rule

        Please login or register to see this code.

         

      • eval(<string>)
      • disable(<rule>)
      • enable(<rule>)
      • trueFor(<time>,<expression>)
      • again(<n>)
      • once(<expression>) -- Expression needs to turn false before it will be true again.

        Please login or register to see this code.

        The rule will rigger the first time the temp > 10, then it needs to go below 10 and above again for it to trigger the next time.

        Please login or register to see this code.

        Plays good morning message only once when sensor breached between 6-7

      • wait(<time>)
      • trace(<boolean>)
      • match
      • pack(<function call>)
    • Control structures
      • if <expr> then <statments> elseif <expr> then <statments> else <statments> end
      • while <expr> do <statments> end
      • repeat <statments> until <expr>
      • for i=<expr>,<expr>[,<expr>] do <statments> end
      • for k,v in ipairs(<table>) do <statments> end
      • for k,v in pairs(<table>) do <statments> end
      • || <test> >> <statments> ...
    • Rule constructs
      • @<time> [& <additional tests>] => <statements>
        Schedule rule at <time>  every day
      • @@<time> [& <additional tests>] => <statements>
        Schedule rule at repeating <time> intervals
      • <trigger expression> => <statements>
        <trigger expression> contains triggers (deviceID, fibaro globals), and rule will be called every time they change status
      • #<event> [& <additional tests>] => <statements>
        Rule will be called every time #<event> is posted
    • Integration with other systems
      • Nodered.connect(<url>)
      • Nodered.post(<event>)
      • Hue.connect(<user>,<ip>) (only HC2)
      • Hue.define(<name>,<deviceID>) (only HC2)
      • Hue.monitor(<deviceID>,<ms>) (only HC2)
      • Hue.dump() (only HC2)
      • Telegram.bot(<token>) (only HC2)
      • Telegram.msg(<id>,<string>) (only HC2)

     

    Property functions:

    • <ID>:value - returns value property of device. fibaro.getValue(id,"value")
    • <ID>:value=..  - set value property of device. fibaro.call(id,"setValue",...)
    • <ID>:isOff. -- returns true if device value is false or 0
    • <ID>:isOn -- returns true if device value is true or > 0
    • <ID>:isAllOn
    • <ID>:isAnyOff
    • <ID>:off -- turns off device. fibaro.call(id,"turnOff")
    • <ID>:on - turns on device. fibaro.call(id,"turnOn")
    • <ID>:toggle
    • <ID>:dim={<time>[,'up'|'down',<step>,<curve>,<start,<stop>}
    • <ID>:breached,   synonym for :isOn but more appropriate for motion/door/window sensors
    • <ID>:safe,  synonym for :isOff but more appropriate for motion/door/window sensors
    • <ID>:isClosed
    • <ID>:isOpen
    • <ID>:close
    • <ID>:open
    • <ID>:stop
    • <ID>:bat
    • <ID>:power
    • <ID>:power=..
    • <ID>:lux,  synonym for :value but more appropriate for lux sensors
    • <ID>:temp,  synonym for :value but more appropriate for temperature sensors
    • <ID>:last
    • <ID>:trigger
    • <ID>:secure
    • <ID>:unsecure
    • <ID>:lock, synonym for :secure
    • <ID>:unlock, synonym for :unsecure
    • <ID>:isSecure
    • <ID>:isUnsecure
    • <ID>:isLocked, synonym for :isSecure
    • <ID>:isUnlocked, synonym for :isUnsecure
    • <ID>:manual
    • <ID>:wake
    • <ID>:name
    • <ID>:HTname
    • <ID>:roomName
    • <ID>:start
    • <ID>:start=..
    • <ID>:kill
    • <ID>:scene
    • <ID>:access
    • <ID>:central
    • <ID>:armed, fibaro:getValue(<ID>,"armed")=='1'
    • <ID>:armed=<expr>, fibaro:call(<ID>,"setArmed",<expr> and '1' or '0')
    • <ID>:btn=..
    • <ID>:dID
    • <ID>:defemail=..
    • <ID>:email=..
    • <ID>:msg=..
    • <ID>:defaultPartyTime=..
    • <ID>:removeSchedule
    • <ID>:retryScheduleSynchronization
    • <ID>:interval=..
    • <ID>:schedule=..
    • <ID>:scheduleState=..
    • <ID>:setAllSchedules
    • <ID>:setpointMode=..
    • <ID>:targetLevel=..
    • <ID>:thermostatSetpoint=..
    • <ID>:mode
    • <ID>:mode=..
    • <ID>:time
    • <ID>:time=..
    • <ID>:B=<expr>, fibaro:call(<ID>,"setB",<expr>)
    • <ID>:G=<expr>, fibaro:call(<ID>,"setG",<expr>)
    • <ID>:R=<expr>, fibaro:call(<ID>,"setR",<expr>)
    • <ID>:W=<expr>, fibaro:call(<ID>,"setW",<expr>)
    • <ID>:B, fibaro:getValue(<ID>,"B")
    • <ID>:G, fibaro:getValue(<ID>,"G")
    • <ID>:R, fibaro:getValue(<ID>,"R")
    • <ID>:W, fibaro:getValue(<ID>,"W")
    • <ID>:color
    • <ID>:color=..
    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • 7 minutes ago, sonnyboy said:

    It would be nice if "isSecure" and "isUnsecure" would be supported :)

     

    That's probably easy to add but I don't have a lock so you need to help me.

    <ID>:secure translates to fibaro:call(<ID>,"secure") and locks the lock I assume.

    <ID>:unsecure translates to fibaro:call(<ID>,"unsecure") and unlocks the lock I assume.

    (Btw, should we change name of these to <ID>:lock resp. <ID>:unlock  ?)

    How do you get the status of the lock?

    fibaro:getValue(<ID>,"value") or fibaro:getValue(<ID>,"secured") or ? and what does it return?

    Edited by jgab
    Link to comment
    Share on other sites

    7 minutes ago, jgab said:

    That's probably easy to add but I don't have a lock so you need to help me.

    <ID>:secure translates to fibaro:call(<ID>,"secure") and locks the lock I assume.

    <ID>:unsecure translates to fibaro:call(<ID>,"unsecure") and unlocks the lock I assume.

    (Btw, should we change name of these to <ID>:lock resp. <ID>:unlock  ?)

    How do you get the status of the lock?

    fibaro:getValue(<ID>,"value") or fibaro:getValue(<ID>,"secured") or ? and what does it return?

    Change name to lock and unluck would be nice, it sounds more up to date.

     

    This below is the lock status when i run this code

    Please login or register to see this code.

    When the lock is Unsecure (unlocked) [DEBUG] 11:00:50: Value danalock : 0
    When the lock is Secure (locked) [DEBUG] 11:01:43: Value danalock : 1

     

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, sonnyboy said:

    Change name to lock and unluck would be nice, it sounds more up to date.

     

    This below is the lock status when i run this code

    Please login or register to see this code.

    When the lock is Unsecure (unlocked) [DEBUG] 11:00:50: Value danalock : 0
    When the lock is Secure (locked) [DEBUG] 11:01:43: Value danalock : 1

     

    Can you try

    Please login or register to see this code.

    because it seems like some other "lock" devices has that property.

    I wonder if all "locks" respond to the "value" property or "secured".

    It makes a difference because you need to declare the triggers as

    <ID> value

    or

    <ID> secured

    in the scene header.

    Edited by jgab
    Link to comment
    Share on other sites

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...