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
    16 hours ago, Christb said:

    hi @jgab, just for your information new unknown events comming from the energy pannel (pricing parameters):

    Unknown event type:     {"createdMillis":1714161600078,"data":{"newTariff":"CREUSES","oldTariff":"PLEINES"},"type":"ActiveTariffChangedEvent","created":1714161600}
    Unknown event type:     {"createdMillis":1714168800107,"data":{"newTariff":"UNUSED","oldTariff":"CREUSES"},"type":"ActiveTariffChangedEvent","created":1714168800}
    Unknown event type:     {"createdMillis":1714190400190,"data":{"newTariff":"PLEINES","oldTariff":"UNUSED"},"type":"ActiveTariffChangedEvent","created":1714190400}

     

     

    Thanks,added the event to fibemu.

    • Like 1
    Posted

    @jgab

    interesting issue - I was using this source code for exporting fqa but in vscode emu there is problem I think with json because InitialProperties is exporting as { } but fibaro expect [ ]

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    On 4/29/2024 at 7:21 PM, petrkl12 said:

    @jgab

    interesting issue - I was using this source code for exporting fqa but in vscode emu there is problem I think with json because InitialProperties is exporting as { } but fibaro expect [ ]

     

    Please login or register to see this code.

     

    Yes, the encoder don't know if the empty table should be [] or {}

    Do

    Please login or register to see this code.

    It marks the value as being an array for future encoding...

    This will probably work in HC3 QAs too as they have the same encoder and json.util.*

     

    Posted
    On 5/2/2024 at 10:25 AM, jgab said:

    Please login or register to see this code.

    It marks the value as being an array for future encoding

    Dear @jgab do you confirm that now the json.util.InitArray(tableName) is now implemented in fibemu?☺️

     

    I have also a new issue with the code below in a QA which gives a "null" answer when, in a scene, the same code gives a table events for the period:

    allEventHistoryLastWeek = api.get("/events/history?from=" .. fromTime .. "&to=" ..ttoTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000")

    print("line 60 _ ",json.encode(allEventHistoryLastWeek))

     

    in the DEBUG CONSOLE, I get :

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: ------- QA - version v 0.1 , Limitation of Events History Id: 5000 --------

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: Query the HC3 history fromTime 10-05 00:00:00 toTime 17-05 23:59:59

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: line 60 _ null

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: allEventHistoryLastWeek is not a table

     

    Is it because this API request is not implemented in fibemu or do I have made a format error for QA implementation?

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

    Dear @jgab do you confirm that now the json.util.InitArray(tableName) is now implemented in fibemu?☺️

     

    I have also a new issue with the code below in a QA which gives a "null" answer when, in a scene, the same code gives a table events for the period:

    allEventHistoryLastWeek = api.get("/events/history?from=" .. fromTime .. "&to=" ..ttoTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000")

    print("line 60 _ ",json.encode(allEventHistoryLastWeek))

     

    in the DEBUG CONSOLE, I get :

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: ------- QA - version v 0.1 , Limitation of Events History Id: 5000 --------

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: Query the HC3 history fromTime 10-05 00:00:00 toTime 17-05 23:59:59

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: line 60 _ null

    [17.05.2024] [11:00:58] [DEBUG ] [QUICKAPP5000]: allEventHistoryLastWeek is not a table

     

    Is it because this API request is not implemented in fibemu or do I have made a format error for QA implementation?

    Yes, event history is not implemented in emulator, add "hc3" at the end of the api.get to get it from the hc3 direct. (like in the export example in the previous post)

     

    • Thanks 1
    Posted

    Hello,

    my VSC Fibaro emulator stopped working with the following info:

    Please login or register to see this code.

    It was working fine hour ago. All I did unusual was deleting browser cache...
    config.json contains proper address, login and password.
    I cannot bring it to life again.
    Can anyone help?

  • Topic Author
  • Posted (edited)
    15 hours ago, Łukasz997 said:

    Hello,

    my VSC Fibaro emulator stopped working with the following info:

    Please login or register to see this code.

    It was working fine hour ago. All I did unusual was deleting browser cache...
    config.json contains proper address, login and password.
    I cannot bring it to life again.
    Can anyone help?

    Can you add this to __init__.py around line 84 in .vscode and see if it solves your problem?

    Please login or register to see this code.

    It forces hostname to "" before calling socket.gethostbyname()

    If it is the problem I can add a workaround for it in the code...

    The problem you may have is that socket.gethostname returns nothing as it doesn't manage to resolve your hostname.

    Did you change connection from wifi to ethernet? or lost connection?

    It's usually good to have the entry

    Please login or register to see this code.

    in /etc/hosts - do you have that?

     

    Edit:

    The problem you have is that the dns resolvent don't report your pc name. So, something strange with your dns.

    Setting hostname to "" will report back the ip 0.0.0.0, which makes it kind of work but you can't make calls back from the HC3 to the emulator.

    I pushed a new version of __init__.py that logs your hostname and IP at startup. Try to configure your Mac so that you get a hostname back and the local IP address..

    Edited by jgab
    Posted (edited)

    Dear Jan,

    thank you for answer. I've pulled new __init__.py - unfortunately, no help...

    The hostname gives the following:

    Please login or register to see this code.

    /etc/hosts:

    Please login or register to see this code.

    IP and DNS addresses cames from DHCP server, but absolutely nothing has changed there.

    Prior the problem appears, I've also changed the iCloud password, but I think it has nothing to do with the problem...

    Everything other works on the computer.
     

    Does it prompt you the solution?
     

    Edited by Łukasz997
  • Topic Author
  • Posted
    6 minutes ago, Łukasz997 said:

    Dear Jan,

    thank you for answer. I've pulled new __init__.py - unfortunately, no help...

    The hostname gives the following:

    Please login or register to see this code.

    /etc/hosts:

    Please login or register to see this code.

    IP and DNS addresses cames from DHCP server, but absolutely nothing has changed there.

    Prior the problem appears, I've also changed the iCloud password, but I think it has nothing to do with the problem...

    Does it prompt you the solution?

    I pushed a new __init__.py that does a little bit better job trying to log- what does it report when the emu starts up?

    Googling it there seems to be a couple of solutions for macOS.

    1. If you have VPNs enabled there seems to be an issue - solution see 3.

    2. Enabling file sharing or some other network service in macOS will assign it an internal DNS entry. -- try that

    3. Adding 

    Please login or register to see this code.

    to your /etc/hosts

    • Thanks 1
    Posted
    8 minut temu, jgab napisał:

    I pushed a new __init__.py that does a little bit better job trying to log- what does it report when the emu starts up?

    Googling it there seems to be a couple of solutions for macOS.

    1. If you have VPNs enabled there seems to be an issue - solution see 3.

    2. Enabling file sharing or some other network service in macOS will assign it an internal DNS entry. -- try that

    3. Adding 

    Please login or register to see this code.

    to your /etc/hosts

    It is working again OK and I hope it remains working.

    I only pulled new __init__, nothing more.
    Thank you very much for help.

     

    A remark I would like to share is: how thin is the thread all this is hanging on...

  • Topic Author
  • Posted (edited)
    42 minutes ago, Łukasz997 said:

    It is working again OK and I hope it remains working.

    I only pulled new __init__, nothing more.
    Thank you very much for help.

     

    A remark I would like to share is: how thin is the thread all this is hanging on...

     

    What IP address does it log in the vscode console when the editor starts up? 0.0.0.0 ?

    Edited by jgab
    Posted

    When you start the lua code the address is:

    Please login or register to see this code.

    When editor (at VSC launch?) start - I don't know where to find it. Terminal shows nothing new at start.

  • Topic Author
  • Posted

    Ok, you get Host ip 127.0.0.1

    Are you connected to a local network and have a local ip address? like 192.168.x.x ?

    It would be better if it could get that address.

    If you are connected, try starting file sharing on your Mac - then I think you will get an address...

     

    You can do 

    Please login or register to see this code.

    to see what ip addresses you have assigned

     

    Posted

    Yes, I always have the local ip address: 192.168.2.125

    It was the same when VSC emu does not work - I've checked it.

    It's obtained from DHCP - which is Mikrotik firewall/router in my home. On Mikrotik it's set to be static for comp MAC address.

    On the way to mac there's a router (completely stupid) and a mesh (not stupid), but acting as a access point only.

    VPN - present, but not in use with local connections, only remote.

     

    So it is still something else, not IP. But it still works again :)

  • Topic Author
  • Posted

    For api.get,api.post,api.put, and api.delete we can add "hc3" as an extra last argument to pass the request to the hc3 instead of the emulator taking care of it.

    It is useful for api calls that the emulator hasn't implemented.

     

    However, it can be a bit annoying to condition the code with "if fibaro.fibemu then ..."

    So, now we can declare the APIs that should pass through to the HC3 with

    --%%passThrough=<api pattern>

    We can declare as many as we will (but one declaration per pattern)

    The pattern should be a valid lua string.match pattern

    Ex.

    Please login or register to see this code.

    This will pass alarm try arm to the hc3.

    Ex. api.get("/alarms/v1/partitions/777/?actions/tryArm

     

    We can also put them in config.json

    Please login or register to see this code.

    and they will be merged with patterns declared in the QA file

    • Like 2
    Posted
    1 hour ago, jgab said:

    --%%passThrough=<api pattern>

    Dear @jgab, just to confirm my understanding, instead of :

    allEventHistoryLastWeek,erreur = api.get("/events/history?from=" .. fromTime .. "&to=" .. toTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000","hc3")

    I need to add in initial declaration:

    -%%passThrough=/events/history?from=[%d]&to=[%e]&eventType=DevicePropertyUpdatedEvent&objectType=[%f]&numberOfRecords=[%g]

    and then in the code:

    api.get("/events/history?from=" .. fromTime .. "&to=" .. toTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000")

    OK?

  • Topic Author
  • Posted

    Yes, it’s enough to do

    --%%passThrough=/events/history

     

    and it will match all events/history commands

    Posted
    20 minutes ago, jgab said:

    Yes, it’s enough to do

    --%%passThrough=/events/history

    With the suffix ,"hc3" in the code below I got the table of the 1657 events:

    allEventHistoryLastWeek,erreur = api.get("/events/history?from=" .. fromTime .. "&to=" .. toTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000","hc3")

    DEBUG CONSOLE:

    [19.05.2024] [15:36:17] [DEBUG ] [QUICKAPP5000]:Query HC3 history from: 19/05/24 00:00:00 to 19/05/24 23:59:59

    [19.05.2024] [15:36:17] [DEBUG ] [QUICKAPP5000]: line 146 _ erreur: 200

    [19.05.2024] [15:36:17] [DEBUG ] [QUICKAPP5000]: Number of all events for this period: 1657

    When I add the --%%passThrough=/events/history and suppress the ,"hc3"  at the end I have an error:

    allEventHistoryLastWeek,erreur = api.get("/events/history?from=" .. fromTime .. "&to=" .. toTime.."&eventType=DevicePropertyUpdatedEvent&objectType=device&numberOfRecords=100000")

    DEBUG CONSOLE:

    [19.05.2024] [15:36:17] [DEBUG ] [QUICKAPP5000]:Query HC3 history from: 19/05/24 00:00:00 to 19/05/24 23:59:59

    [19.05.2024] [15:29:14] [DEBUG ] [QUICKAPP5000]: line 146 _ erreur: 500

    [19.05.2024] [15:29:14] [DEBUG ] [QUICKAPP5000]: allEventHistoryLastWeek is not a table

    Posted
    3 godziny temu, jgab napisał:

    Are you connected to a local network and have a local ip address? like 192.168.x.x ?

    It would be better if it could get that address.

    If you are connected, try starting file sharing on your Mac - then I think you will get an address...

    Just to inform - file sharing gives no change, still 127.0.0.1

    But emulator is working OK.

    Posted
    1 hour ago, Christb said:

    When I add the --%%passThrough=/events/history and suppress the ,"hc3"  at the end I have an error:

    I have forgotten to update fibemu first, now all working 😐

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