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
On 3/10/2019 at 10:30 AM, jgab said:

We need a global 'myTimer' where we keep how many minutes left (we only count even minutes, but we could do %H.%M:%S)

Whenever the status of 893 change we reset the variable to 45min. However when it turns on we start a timer that counts it down every minute. 

rule(<...>).disable() starts a rule in disabled state.

So, when the scene restarts it will use whatever value is in 'myTimer' as a starting value.

Another trick, is that we at startup kick the 'for' rule, so that if 893:isOn we continue to run even if we don't get a new trigger.

Tested this and almost working

Please login or register to see this code.

If i let the timer count down little and restart scene it does not continue when scene start again. Even if only set Kok.kaffebryggaren:isOn at left side it does not start from timer stopped.

Posted
11 hours ago, jgab said:

 

There may have been a bug, pushed a new version of HC2.lua.

The idea is that you in the beginning of HC2.lua (in it's main()) will setup what resources are local and what resources are remote (I stupidly called them "global", will change)

Please login or register to see this code.

If they are remote/global It should access them remote, if they are local they are just keeping a local state.

What data you want to read? labels?

 

I need read almost all items from VDs (in my case of usage) but it still doesn't work ...

 

#[HC2]19:17:23, Mon Mar 11: Error in Scene:228 "HC2.lua:686: GET /virtualDevices/1282 not supported"[0m

 

 

 

  • Topic Author
  • Posted
    4 hours ago, FrankT said:

    Lua functions can return multiple results, works even in fibaros implementation. Is it possible to call a function like below?

     

    No, unfortunately not. Probably easy to implement in the ER vm, but some more work on the parser/compiler. At the moment I feel like there are many more things that need to be fixed first :-)

    However, you can make a wrapper and return it as a table.

    Please login or register to see this code.

    EventScript allows both <table>.<integer index>   and <table>[<integer index>] as a way to access value in a table (also allows symbol keys)

     

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

    I need read almost all items from VDs (in my case of usage) but it still doesn't work ...

    #[HC2]19:17:23, Mon Mar 11: Error in Scene:228 "HC2.lua:686: GET /virtualDevices/1282 not supported"[0m

    Ok, I hadn't implemented that resource (it's not in http://hc2/doc ). One approach could be that all resources the emulator doesn't  handle I send off to the HC2.

    I can do it for the next release but what is the difference from GET/device/1282 ? ( They also have type 'virtual_device')

  • Topic Author
  • Posted
    2 hours ago, jompa68 said:

    Tested this and almost working

    Please login or register to see this code.

    If i let the timer count down little and restart scene it does not continue when scene start again. Even if only set Kok.kaffebryggaren:isOn at left side it does not start from timer stopped.

     

    Are you running on the emulator or on the HC2? 

    The last rule that sets _kick=true should start the second to last 'for' rule and if kaffebryggare:isOn it should continue to run.

    However.... we forgot to enable the rule, it starts off as disabled... so the last rule also need to start enable the timer rule if the coffee machine is on so it continues to count.

    Please login or register to see this code.

     

    • Thanks 1
    Posted

    for GET it's similiar but difference is in PUT command (I can modify VD directly)

     

    I want to also read VDs directly from HC2 ie. this:

           tcp = fibaro:get(vdid, "TCPPort")

     

    but it doesn't work in new version too. I have tried different combination of parametres: 

     

    1. _REMOTE=true

    2. _REMOTE=false

    3. HC2.localDevices(true)

    4. HC2.localDevices(false)

    Posted
    On 2/22/2019 at 3:19 PM, jgab said:

    Assume we would like to make support for a Sonos device.

    Have you find any solution to set radio channel on Sonos with NR?

    Posted

    trying to set a value to a VD slider but nothing happens.

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2019_03/1105009113_Skrmavbild2019-03-12kl_05_53_06.png.5556fd3c932ede7d4c7b49f1aaa7a387.png" alt="1105009113_Skrmavbild2019-03-12kl_05_53_06.png.5556fd3c932ede7d4c7b49f1aaa7a387.png" />

  • Topic Author
  • Posted
    3 hours ago, jompa68 said:

    Have you find any solution to set radio channel on Sonos with NR?

    No not yet, haven’t checked if there is an update

  • Topic Author
  • Posted
    4 hours ago, jompa68 said:

    trying to set a value to a VD slider but nothing happens.

    Please login or register to see this code.

    Please login or register to see this link.

     

    In the emulator, HC2.lua's main(), make sure that you declare 713 remote.

    Please login or register to see this code.

    On on the HC2 it should be no problem, or?

     

    Just now, jgab said:

     

    In the emulator, HC2.lua's main(), make sure that you declare 713 remote.

    Please login or register to see this code.

    On on the HC2 it should be no problem, or?

     

     

    I have pushed a new version of H2.lua, test that also if the problem remains.

    Posted
    1 minute ago, jgab said:

    On on the HC2 it should be no problem, or?

    The issue is on the HC2, nothing happens when rule is running.

  • Topic Author
  • Posted
    1 minute ago, jompa68 said:

    The issue is on the HC2, nothing happens when rule is running.

    That's strange - will check tonight when I'm home.

  • Topic Author
  • Posted (edited)
    12 hours ago, petrkl12 said:

    for GET it's similiar but difference is in PUT command (I can modify VD directly)

     

    I want to also read VDs directly from HC2 ie. this:

           tcp = fibaro:get(vdid, "TCPPort")

     

    but it doesn't work in new version too. I have tried different combination of parametres: 

     

    1. _REMOTE=true

    2. _REMOTE=false

    3. HC2.localDevices(true)

    4. HC2.localDevices(false)

     

    Have you tried HC2.remoteDevices(vdid) in the last push of HC2.lua ?

    I will try to fix PUT

    Edited by jgab
  • Topic Author
  • Posted

    I've just pushed a new version of HC2.lua

    When the emulator runs you can also open the web browser at 

    Please login or register to see this link.

     and there is a simple GUI to list scenes and devices and set off some triggers. The GUI will be developed with more features.

    Someone better at CSS can help with the layout - pages inline at the end of HC2.lua at the moment, but will probably move out to a subdirectory soon.

    • Like 1
    Posted

    simple gui is working,

    remote access for virtual devices is not working (via api or direct  reading via fibaro:* )

  • Topic Author
  • Posted (edited)
    7 hours ago, petrkl12 said:

    simple gui is working,

    remote access for virtual devices is not working (via api or direct  reading via fibaro:* )

     

    It's interesting. The "TCPPort" is actually a property of the device with the name "port".

    Normally when you do fibaro:get(id,<property>) you access the property filed name <property>, easy.

    However for virtual devices the "TCPPort" and similar for the ip adress it is handled differently. Some strange exceptions by fibaro...

    I have pushed a version of HC2.lua (fix8) that remaps tcpport and ipaddres for VDs which makes fibaro:get(vd,"TCPPort") work.

    To do PUT/POST on VDs will come soon.

    Btw, start/stop scenes work from the GUI now so it's easier to start scenes that don't have %% autostart

    Btw2, with a working web server in the emulator it should be possible to simulate VDs too...

     

     

    Edited by jgab
  • Topic Author
  • Posted
    On 3/12/2019 at 5:53 AM, jompa68 said:

    trying to set a value to a VD slider but nothing happens.

    Please login or register to see this code.

    Please login or register to see this link.

    On 3/12/2019 at 10:28 AM, jompa68 said:

    The issue is on the HC2, nothing happens when rule is running.

    Is this still a problem? I have tested and have no problem on the HC2.  If I in the emulator set "Hc2.remoteDevices(713)" it works from the emulator too.

    On the HC2 does its log the "fibaro:call(713,"setProperty",...)" ?

     

    Posted
    12 hours ago, jgab said:

     

    It's interesting. The "TCPPort" is actually a property of the device with the name "port".

    Normally when you do fibaro:get(id,<property>) you access the property filed name <property>, easy.

    However for virtual devices the "TCPPort" and similar for the ip adress it is handled differently. Some strange exceptions by fibaro...

    I have pushed a version of HC2.lua (fix8) that remaps tcpport and ipaddres for VDs which makes fibaro:get(vd,"TCPPort") work.

    To do PUT/POST on VDs will come soon.

    Btw, start/stop scenes work from the GUI now so it's easier to start scenes that don't have %% autostart

    Btw2, with a working web server in the emulator it should be possible to simulate VDs too...

     

     

    There is progress. VDs are working :) Thanks

     

    Still need to be corrected :

    - fibaro:getRoomNameByDeviceID  - it doesn't work

    - api.get('/virtualDevices/[id]')

    - api.put('/virtualDevices/[id], [data]')

     

    Thanks

  • Topic Author
  • Posted
    2 hours ago, petrkl12 said:

    Still need to be corrected :

    - fibaro:getRoomNameByDeviceID  - it doesn't work

    - api.get('/virtualDevices/[id]')

    - api.put('/virtualDevices/[id], [data]')

     

    Thanks

     

    Pushed new version of HC2.lua (v0.5)

    -Fixed fibaro:getRoomNameByDeviceID

    -put/get virtual device still to come...

    -Restructuring the web server - I'm relearning a lot about the HTTP protocol that I had forgot and hoped I never had to learn again...  and reinventing lua server pages...

    -Smarter handling of internal timer scheduler - running _SPEEDTIME made the ZBS consume 98% of the cpu processor on my Mac... now it's down to 5-7%

     

    When you start writing a HC2 emulator you think it's all about implementing the fibaro:* calls... in reality it's all about re-implementing the http api calls...

  • Topic Author
  • Posted (edited)
    On 2/11/2019 at 3:43 PM, petrkl12 said:

    @jgab

     

    Thanks for your detail analysis :-) Any improvements are welcome!

     

    Could you send me your latest version of experimental code?

    I will do my own test - different result will be probably thanks to my load of consumer...

    Today evening I will send you my scene via PM.

     

    I think we have a new winner! I will try it with  ER tonight. (small drawback with "blank" lines in the log :-) )

    Please login or register to see this code.

     

    Edited by jgab

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