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

Posted (edited)
10 minutes ago, Neo Andersson said:

Please login or register to see this code.

 

I cant get it..I am using this code years, without a problem..How is this possible

Attaching the part of the flow. Dont focus on mp3, it is fed from other flow, but this is the main part that must be working for single text. hostAddress is the nodered acces IP /raspberrey or whetever one running nodered on. msg.ip is the speaker IP address, that the message shuold be played on.

Please login or register to see this attachment.

Edited by Neo Andersson
  • Topic Author
  • Posted
    9 minutes ago, Neo Andersson said:

    Attaching the part of the flow. Dont focus on mp3, it is fed from other flow, but this is the main part that must be working for single text. hostAddress is the nodered acces IP /raspberrey or whetever one running nodered on. msg.ip is the speaker IP address, that the message shuold be played on.

    Please login or register to see this attachment.

     

    Sorry, too complicated for me to debug. Put debug statements and see if it is the 

    var p = JSON.parse(msg.payload);

    that complains, and if so how the payload looks like?

     

    Are you saying that if you run the Lua http:request it works and the rule does not?

    The only diff I see is that you don't set any headers and http.post sets Content-type=applications/json per default.

    That would be correct unless your Nodered endpoint has another opinion on what it's expecting?

     

    Posted
    2 minutes ago, jgab said:

    Are you saying that if you run the Lua http:request it works and the rule does not?

    yes exactly

    Posted (edited)
    32 minutes ago, jgab said:

    var p = JSON.parse(msg.payload);

    This is from LUA call - succesfull

    Please login or register to see this image.

    /monthly_2024_01/image.png.6896a99d0f2058e1f4bbe60bc4ca9af9.png" />

    when expanding the firs req object

    Please login or register to see this attachment.

     

     

    this is from rule unsuccesfull

     

    image.png.296fc612a64dc6269031375208450a47.png

    i can see that there are object missing when calling from rule

    Edited by Neo Andersson
  • Topic Author
  • Posted
    7 minutes ago, Neo Andersson said:

    yes exactly

    Why do you have text/html as accept-header when you sen json?

    The only difference is that the rule has the header set

    Content-type=applications/json

     

    Posted (edited)
    4 minutes ago, jgab said:

    Why do you have text/html as accept-header when you sen json?

    The only difference is that the rule has the header set

    Content-type=applications/json

     

    Jan i never ever set any header, nowhere..

    This must be set by default in the fibaro http, i have never ever touched it.

    Edited by Neo Andersson
  • Topic Author
  • Posted
    6 minutes ago, Neo Andersson said:

    Jan i never ever set any header, nowhere..

    Sorry, looked at the wrong header.

     

    So what I'm I looking at? - a successful call with Lua or an unsuccessful call with rule?

     

    I don't recognize the user agent avhttp:2.9.9 

    Sure you send it from HC3? 

     

    What if in your Lua code set the header?

     

    Please login or register to see this code.

    do you get an error then too? 

    Posted
    8 minutes ago, jgab said:

    Sorry, looked at the wrong header.

     

    So what I'm I looking at? - a successful call with Lua or an unsuccessful call with rule?

     

    I don't recognize the user agent avhttp:2.9.9 

    Sure you send it from HC3? 

     

    What if in your Lua code set the header?

     

    Please login or register to see this code.

    do you get an error then too? 

    yes

    Just now, Neo Andersson said:

    So what I'm I looking at? - a successful call with Lua or an unsuccessful call with rule?

    first is a succesfull call from LUA, second is unsucessfull from ER

    There are notes above pictures, to tell which is which

  • Topic Author
  • Posted

    But for the rule you are getting everything from requestStr table except mp3name that is nil 

    Posted (edited)

    @jgab Jan thanks for all the efforts..This is a fight against all the elements..

    I think the problem is that the requestTringToJSON below is not recognized in Nodered as a regualr Json object..Thats why when I dont specify the header, it works..I dont know the reason, but it is not worth any more minutes to fitgh with. I will work with the old solution, outside of the rules. So many thanks...

    Please login or register to see this code.

     

    3 minutes ago, jgab said:

    But for the rule you are getting everything from requestStr table except mp3name that is nil 

    Correct, but I was also thinking about this, and this is not the problem. I tried it with non nil mp3name, and still the same result.

    Edited by Neo Andersson
  • Topic Author
  • Posted
    4 minutes ago, Neo Andersson said:

    @jgab Jan thanks for all the efforts..This is a fight against all the elements..

    I think the problem is that the requestTringToJSON below is not recognized in Nodered as a regualr Json object..Thats why when I dont specify the header, it works..I dont know the reason, but it is not worth any more minutes to fitgh with. I will work with the old solution, outside of the rules. So many thanks...

    Please login or register to see this code.

     

    Correct, but I was also thinking about this, and this is not the problem. I tried it with non nil mp3name, and still the same result.

    Yes, I'm saying it's as it should be.

    The problem is that you don't set any headers in your Lua function so the payload arrives as a string and you do 

    Please login or register to see this code.

     

    when you use rules the default is content-type:application/json so you payload arrives as a json struct (actually javascript dict) 

    ...and the your JSON.parse barfs.

     

    Do right and set content-type also in your Lua function and remove JSON.parse in your nodered function

    Posted
    6 minutes ago, Neo Andersson said:

    @jgab Jan thanks for all the efforts..This is a fight against all the elements..

    I think the problem is that the requestTringToJSON below is not recognized in Nodered as a regualr Json object..Thats why when I dont specify the header, it works..I dont know the reason, but it is not worth any more minutes to fitgh with. I will work with the old solution, outside of the rules. So many thanks...

    Please login or register to see this code.

     

    Correct, but I was also thinking about this, and this is not the problem. I tried it with non nil mp3name, and still the same result.

    Just to be more precise, here is what the node does when POST request is sent. Quoting from documentatioin.

     

    For requests that include a body, such as a POST or PUT, the contents of the request is made available as msg.payload.

    If the content type of the request can be determined, the body will be parsed to any appropriate type. For example, application/json will be parsed to its JavaScript object representation.

  • Topic Author
  • Posted

    Yes, what I said. Always set content-type and remove the JSON.parse...

    • Like 1
    Posted
    4 minutes ago, jgab said:

    Yes, I'm saying it's as it should be.

    The problem is that you don't set any headers in your Lua function so the payload arrives as a string and you do 

    Please login or register to see this code.

     

    when you use rules the default is content-type:application/json so you payload arrives as a json struct (actually javascript dict) 

    ...and the your JSON.parse barfs.

     

    Do right and set content-type also in your Lua function and remove JSON.parse in your nodered function

    Working!!!

    Owe you a Whiskey!!!!!!!!!! or rather a truck full of whiskey

    OMG

     

    • Like 1
    Posted

    Hi Jan
    I know how to do the childs in Ev5. But can you show me how i can connect to a MQTT broker in Ev5 and subscribe to a Sensor and put currentValue to a EV5 Child ?
    perhaps also send a msg if burst is true
     /watermeter/mydatajson 
    {"currentValue":1028.543,"monthStartValue":402915.897,"WaterTemp":225,"RoomTemp": 0,"Dry":"false","Reverse":"false","Leak":"false","Burst":"false"}

  • Topic Author
  • Posted (edited)

    At the moment I don't have a working mqtt installation, so you have to try this out and see if you get any response. The <Child> is the uid/name of your child.

    Please login or register to see this code.

     

    Edited by jgab
    self wrongly used
    • Thanks 1
    Posted
    26 minutes ago, jgab said:

    At the moment I don't have a working mqtt installation, so you have to try this out and see if you get any response. The <Child> is the uid/name of your child.

    Please login or register to see this code.

     

    What if the MQTT has username password :-) ?

  • Topic Author
  • Posted
    3 minutes ago, ChristianSogaard said:

    What if the MQTT has username password :-) ?

    I'm unsure but I think it is

    Please login or register to see this code.

    Posted

    I noticed for a longer period that the memory usage in my HC3 is very high.

    So a restart everyday is't the solution.

    If HC3 restart it takes very long and the memory usage is directly very high!

    I did a download of my ER5 QA's and created a backup of my HC3

    After restart I deleted all my ER5 QA"s

    Restarted HC3 and add the ER5 Qa's

    Restart

    Result a lower memory usage and a faster restart.

    I never noticed anything about a ghost, nothing wied in log orso

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Posted (edited)
    On 1/23/2024 at 9:24 AM, jgab said:

    I'm unsure but I think it is

    Please login or register to see this code.

    Hi Jan

     

    The whole MQTT receiver works fine

    Please login or register to see this code.

     

    The Child is created successful with

    Please login or register to see this code.

     

    But the Child dosent get updated., - The POST is there in the logs but this rule never triggers.

     

    Please login or register to see this code.

    [24.01.2024] [22:09:59] [DEBUG] [QUICKAPP2136]: message: {"qos":0,"topic":"\/watermeter\/mydatajson","retain":false,"payload":"{\"currentValue\":1029.261,\"monthStartValue\":2701306.683,\"WaterTemp\": 4,\"RoomTemp\":231,\"Dry\":\"false\",\"Reverse\":\"false\",\"Leak\":\"false\",\"Burst\":\"false\"}","dup":false}
    [24.01.2024] [22:09:59] [TRACE] [QUICKAPP2136]: Posting #watermeter{dup=false,payload="{"currentValue":1029.261,"monthStartValue":2701306.683,"WaterTemp": 4,"RoomTemp":231,"Dry":"false","Reverse":"false","Leak":"false","Burst":"false"}",qos=0,retain=false,topic="/watermeter/mydatajson"} at Wed Jan 24 22:09:59 2024

     

    This triggers but value is NIL

    Please login or register to see this code.

    This dosent triggers

    Please login or register to see this code.

     

    Edited by ChristianSogaard
    Typo

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