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

  • Topic Author
  • Posted
    1 hour ago, FrankT said:

    @jgab I have never used Node Red, so I have followed your instructions to @Sjakie with great interest. Got Pollysonostts, alexa and echo working in your flow that you showed earlier. But i have problems with telegram. I did send 'turn on kitchen lamp' and received:

     

    Sat/May/25,14:58:35:[20:1] Rule:1:#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
    Sat/May/25,14:58:35:[20:1] 
    Sat/May/25,14:58:35:[20:1] Scene running
    Sat/May/25,14:58:35:[HC2 ] System trigger:{"type":"other"} to scene:20 at Sat May 25 14:58:35
    Sat/May/25,14:59:51:[20:1] Invoking:#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           
    Sat/May/25,14:59:51:[20:1] [{"type":"telegram","msg":"$msg"}]>>'#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           '
    Sat/May/25,14:59:51:[20:1] Telegram command:turn on
    Sat/May/25,14:59:51:[20:1] System trigger:{"type":"property","deviceID":401,"propertyName":"value"} at Sat May 25 14:59:51
    Sat/May/25,14:59:51:[20:1] fibaro:call(hjelpfunktioner.margarethas_keyfob,"turnOn")
    Sat/May/25,14:59:51:[20:1] Error in '#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           ': undefined fun 'telegram'
    Program stopped (pid: 32088).
    Debugging session completed (traced 0 instructions).
    Program completed in 79.92 seconds (pid: 32088).

     

    Where does deviceID 401 come from and what is   ': undefined fun 'telegram' ? Thanks for your help.

     

     

     

     

     

     

    In the post where the "chatbot" is described, the 'telegram' function os missing

    It's defined in the first post where I describe the telegram possibility, it's defined as

    Please login or register to see this code.

    Please login or register to see this code.

    What command did you give in telegram? It seems like you did "turn on keyfob" or something. A string that matched a variable in the HomeTable with deviceID 401.

    Posted

    Hello again,

    I was lost with Polly also because I had a test flow on >>that was giving sound to my Sonos speaker. With several Polly.config files.

    Hehe sorted that out and sorry to be a pain in the rear end because Frankt did it also with your guidance.

    Now I have stereo sound, hello from the laptop and a whistle with hello from Sonos, so I am a big step forwards.

    Dont have any clue why the sound is also send to my lappie 192.168.1.5

    In the NodeRed flow only ZBS is having 192.168.1.5:6872

    Please advice

    As par instruction:

    Please login or register to see this image.

    /monthly_2019_05/image.png.e50ec1e4eb11d68e70e3b92c3bfc9dad.png" alt="image.png.e50ec1e4eb11d68e70e3b92c3bfc9dad.png" />

     

    image.png.73512c558ccef11775641506de4b02cf.png

  • Topic Author
  • Posted
    1 hour ago, Sjakie said:

    Hello again,

     

    Ok, progress! :-)

     

    1 hour ago, Sjakie said:

    Dont have any clue why the sound is also send to my lappie 192.168.1.5

     

    Do you have a wire to the node named "Talk" located under the node "sonospollytts". The talk node speaks through the speaker on the laptop that has the node-red GUI open.

     

    Posted

    You are the best great it works!!!

    I noticed a difference in volume it is the same scene:

      Rule.eval("#speak{text='$text'} => remote(_myNodeRed,#speak{data=text,volume='75'})") -- create event handler
     (to add in every scene where you want to us Polly)
      Rule.eval("remote(_myNodeRed,#speak{data='Hallo, wat ben je aan het doen? '})")
     Volume as set in Node Red SonospollyTTS >>>>25 I should expect also 75
      Rule.eval("woonkamer.bewegingssensor:breached => log('TRIGGER:%s',tjson(env.event)) ; post(#speak{text='Hallo Arleta ben je al  gereed met je karweitje?!'})")
    Volume 75<<<<<<<<<<<<<<<<<<<

    Thanks for your support excellence!!!

    Posted

    @jgab my scene looks

     

    function findId(str)
        local path = split(str," ")
        path=table.concat(path,"%.").."$"
        for id,p in pairs(Util._reverseVarTable) do
          if p:match(path) then return tonumber(id) end
        end
        return false
      end
      cmd={
        turnOn = function(sid) 
          local id = findId(sid); 
          if id then fibaro:call(id,"turnOn"); return string.format("turning on %s",sid) 
          else return string.format("Couldn't find %s",sid) end end,
        turnOff = function(sid) 
          local id = findId(sid); 
          if id then fibaro:call(id,"turnOff"); return string.format("turning off %s",sid) 
          else return string.format("Couldn't find %s",sid) end end,
      }
      commands={
        ["[Tt]urn%s*([%A%a%s]+)%s*on$"]=cmd.turnOn,
        ["[Tt]urn%s*off%s*([%A%a%s]+)$"]=cmd.turnOff,
        ["[Tt]urn%s*on%s*([%A%a%s]+)$"]=cmd.turnOn,
        ["[Tt]urn%s*([%A%a%s]+)%s*off$"]=cmd.turnOff,
       }

      function matchCommand(cmd)
        for s,c in pairs(commands) do 
          local m = {cmd:match(s)}
          if #m>0 then return c(table.unpack(m)) end
        end
        return false
      end
      rule([[#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           ]])


         
    end -- main()
     

    and the command in telegram was "turn on kitchen lamp". I don't have a kitchen lamp, so I was expecting "Sorry, didn't understand". 

     

  • Topic Author
  • Posted
    7 minutes ago, FrankT said:

    and the command in telegram was "turn on kitchen lamp". I don't have a kitchen lamp, so I was expecting "Sorry, didn't understand". 

     

    It's the findId function that seems to make a mistake.

    Try to replace it with the above and see what it says...

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    18 minutes ago, Sjakie said:

    You are the best great it works!!!

    I noticed a difference in volume it is the same scene:

      Rule.eval("#speak{text='$text'} => remote(_myNodeRed,#speak{data=text,volume='75'})") -- create event handler
     (to add in every scene where you want to us Polly)
      Rule.eval("remote(_myNodeRed,#speak{data='Hallo, wat ben je aan het doen? '})")
     Volume as set in Node Red SonospollyTTS >>>>25 I should expect also 75
      Rule.eval("woonkamer.bewegingssensor:breached => log('TRIGGER:%s',tjson(env.event)) ; post(#speak{text='Hallo Arleta ben je al  gereed met je karweitje?!'})")
    Volume 75<<<<<<<<<<<<<<<<<<<

    Thanks for your support excellence!!!

     

    So the #speak handler sets the volume to 75

    If you just call  Rule.eval("remote(_myNodeRed,#speak{data='Hallo, wat ben je aan het doen? '})") I would expect the default 25 (that is set in the node-red config of the node. It could be that it uses the last set volume too, I'm a bit unsure.

    You can make the handler I provided a bit more flexible by accepting an optional volume parameter or default to, like 50

    Please login or register to see this code.

    Then you can do

    Please login or register to see this code.

     

    Posted

    Thanks,

    If you just call  Rule.eval("remote(_myNodeRed,#speak{data='Hallo, wat ben je aan het doen? '})") I would expect the default 25 (that is set in the node-red config of the node. It could be that it uses the last set volume too, I'm a bit unsure.

    Correct defaut volume setting in NodeRed.

    Have nice weekend

    Posted
    1 hour ago, jgab said:

     

    It's the findId function that seems to make a mistake.

    Try to replace it with the above and see what it says...

    Please login or register to see this code.

     

    Thanks but still error, but it's saturday evening and I believe you have a family to take care off.

     

    Sat/May/25,20:51:33:[20:1] Invoking:#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           
    Sat/May/25,20:51:33:[20:1] [{"type":"telegram","msg":"$msg"}]>>'#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           '
    Sat/May/25,20:51:33:[20:1] Telegram command:turn on kitchen lamp
    Sat/May/25,20:51:33:[20:1] Looking up reference 'kitchen lamp'
    Sat/May/25,20:51:33:[20:1] Error in '#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           ': undefined fun 'telegram'

     

    Posted
    4 minutes ago, FrankT said:
    1 hour ago, jgab said:

     

    It's the findId function that seems to make a mistake.

    Try to replace it with the above and see what it says...

    Please login or register to see this code.

     

    Thanks but still error, but it's saturday evening and I believe you have a family to take care off.

     

    Sat/May/25,20:51:33:[20:1] Invoking:#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           
    Sat/May/25,20:51:33:[20:1] [{"type":"telegram","msg":"$msg"}]>>'#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           '
    Sat/May/25,20:51:33:[20:1] Telegram command:turn on kitchen lamp
    Sat/May/25,20:51:33:[20:1] Looking up reference 'kitchen lamp'
    Sat/May/25,20:51:33:[20:1] Error in '#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           ': undefined fun 'telegram'

    Tried again with a device which is used, same error  ': undefined fun 'telegram'. A spelling error or something like that`?

     

    at/May/25,21:00:12:[20:1] Telegram command:turn on tvrum occiolampor
    Sat/May/25,21:00:12:[20:1] Looking up reference 'tvrum occiolampor'
    Sat/May/25,21:00:12:[20:1] Found reference 'tvrum.occiolampor' with pattern 'tvrum%.occiolampor$'
    Sat/May/25,21:00:12:[20:1] Returning reference ID:50
    Sat/May/25,21:00:12:[20:1] System trigger:{"type":"property","deviceID":50,"propertyName":"value"} at Sat May 25 21:00:12
    Sat/May/25,21:00:12:[20:1] fibaro:call(tvrum.occiolampor,"turnOn")
    Sat/May/25,21:00:12:[20:1] Error in '#telegram{msg='$msg'} => cmd=msg.content; log('Telegram command:%s',cmd); 
               || str=matchCommand(cmd) >> telegram(msg,str)
               || true >> telegram(msg,frm("Sorry, didn't understand '%s'",cmd))
           ': undefined fun 'telegram'

  • Topic Author
  • Posted (edited)

    @FrankT before findId add

    Please login or register to see this code.

     

    Edited by jgab
  • Topic Author
  • Posted

    New version of ER, "2.0","B47"  -- May 26, 2019  

    At startup it will make a http request to my GitHub and check the latest version of ER, and if a new version exists post an event

    Please login or register to see this code.

    There is also a rule in main()

    Please login or register to see this code.

    that logs if there is a new version. You could ofcourse make it a notification or something else.

    If you don't want it to make the check at startup, set _CHECKVERSION=false

    • Like 1
    Posted
    2 hours ago, jgab said:

    @FrankT before findId add

    Please login or register to see this code.

    YES, thank you Jan! 

  • Topic Author
  • Posted
    1 hour ago, jgab said:

    New version of ER, "2.0","B47"  -- May 26, 2019  

    At startup it will make a http request to my GitHub and check the latest version of ER, and if a new version exists post an event

    Please login or register to see this code.

    There is also a rule in main()

    Please login or register to see this code.

    that logs if there is a new version. You could ofcourse make it a notification or something else.

    If you don't want it to make the check at startup, set _CHECKVERSION=false

     

    I realised that version should be checked regularly and not only at startup.

    Pushed a new version B48.

    Now there are two rules in main()

    Please login or register to see this code.

    The first rule calls the version check every morning at 06:00. If there is a new version an event is posted that is picked up by the second rule.

    You are free to comment out the check if you don't want it or modify it to another time. Don't do it too often though, as it makes requests to my GitHub.

    Posted

    Excellent thanks

  • Topic Author
  • Posted (edited)

    New version of Supervisor.

    It subscribes to #ERLog messages; {type='ERLog', time=<epoc time>, from=<scene>, msg=<msg>}

    If 'time' is absent it defaults to os.time(). If 'from' is absent it defaults to the publishing scene's ID

    Ex.

    Please login or register to see this code.

    If you want to log some devices when they change values  you can do

    Please login or register to see this code.

    etc.

    Only write useful information and not too many entries too fast (Set Supervisor maxinstances to 10).

    The supervisor will write log entries to a Scene named "EventRunner Log", that is normally hidden. It will write 2000 entries and then prune to the last 1000 entries.

    It writes every minute to the log the last entries.

    Looks like:

    Please login or register to see this code.

    If you want it is easy to write code that emails the content of that scene every day or other.

    Edited by jgab
    • Like 1
  • Topic Author
  • Posted
    4 hours ago, jgab said:

     

    I realised that version should be checked regularly and not only at startup.

    Pushed a new version B48.

    Now there are two rules in main()

    Please login or register to see this code.

    The first rule calls the version check every morning at 06:00. If there is a new version an event is posted that is picked up by the second rule.

    You are free to comment out the check if you don't want it or modify it to another time. Don't do it too often though, as it makes requests to my GitHub.

     

    Pushed a new version B49 where I fixed a bug in Util.checkVersion() that gave an error on the HC2.

    The timeout for the http request to fetch the latest version info was too low and caused a "bad file descriptor" error. 

    I have upped the timeout value so it should work on the HC2 too.

    Posted
    38 minutes ago, jgab said:

     

    Pushed a new version B49 where I fixed a bug in Util.checkVersion() that gave an error on the HC2.

    The timeout for the http request to fetch the latest version info was too low and caused a "bad file descriptor" error. 

    I have upped the timeout value so it should work on the HC2 too. 

    Compilation error on line 871:
    C:\Users\F\Downloads\EventRunner-master\EventRunner.lua:871: ')' expected (to close '(' at line 868) near '='

  • Topic Author
  • Posted
    5 minutes ago, FrankT said:

    Compilation error on line 871:
    C:\Users\F\Downloads\EventRunner-master\EventRunner.lua:871: ')' expected (to close '(' at line 868) near '='

     

    Argh, too fast today. Pushed a new version with a fix. I did not bump the version...

    /J

  • Topic Author
  • Posted (edited)

    A new version of EventRunner (B52) and a new version of HC2.lua (fix4)

     

    New function available. Util.patchEventRunner()

    Still a bit experimental. I would advice that you have a backup of the scene rules, at least for now.

     

    It will fetch the latest version from GitHub and patch the running scene on HC2 and if running emulated offline the local scene file.

     

    It will update the line starting with "_version,_fix =" 

    and everything after "------------------- EventModel - Don't change! --------------------  "

     

    The scene on the HC2 will stop but if you have Supervisor it will be restarted.

    Or you just run it manually in the main() of the scene when you want to update.

    Please login or register to see this code.

     

    I'm testing this in my main lighting scene at the moment, and it seems to work... to make sure that I'm running my own latest version.

    A bit risky, and I will soon move over to a stable and beta model for the code.

    Please login or register to see this code.

     

    Edited by jgab
    • Like 2

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