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

Hi Guys,

I am currently using a Veralite, I have the Vera setup to work in conjunction with my old HomeVision automation controller. The HomeVision controller can send http commands to the Veralite controller to switch z-wave modules on and off. The Vera will also send out http commands to my HomeVision controller and update the web server lighting table (with the current light level etc.) the web server is sat on the HomeVision controller whenever a module/node status changes the table gets updated to keep both controllers in sync.

My question is, can I do the same with the HC2? i.e. I would want the HC2 to work in tandem with my old HomeVision controller until the day comes when I can be wined off it?

Below is a typical http command I use to set light ID3 to 75% on

Please login or register to see this link.

Below is the code written by one of the Vera forum members to update the HomeVision web server table by writting to two variables and execution an HomeVision update macro -

-- HomeVision web server needs to be running with these IP and Port details used below

-- Var 251 is HomeVision variable Node ID address

-- Var 252 is HomeVision variable Light Level

-- Macro 251 is HomeVision macro to put light level into custom Lighting Tablevariable Light Level

local http = require("socket.http")

http.TIMEOUT = 5

local url = "http://192.168.0.23:3005"

-- called when a device is switched on or off - from a variable_watch

function my_function_to_handle_dimming_level_change(dev_id,service, variable, old_val, new_val)

http.request(url, "Var 251 : " .. dev_id .. "==&Var 252 : " .. new_val .. "==&Macro 251=Run")

end

luup.variable_watch("my_function_to_handle_dimming_level_change", "urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", YOUR_DEV_ID_HERE)

-- called when a device is switched on or off - from a variable_watch

function my_function_to_handle_power_state_change(dev_id,service, variable, old_val, new_val)

http.request(url, "Var 251 : " .. dev_id .. "==&Var 252 : " .. new_val .. "==&Macro 251=Run")

end

luup.variable_watch("my_function_to_handle_power_state_change", "urn:upnp-org:serviceId:SwitchPower1","Status", YOUR_DEV_ID_HERE)

Unfortunately I'm not a programmer, so if I am to make the jump I would need some help/advise on getting this to work?

Any help or advise would be appreciated.

Many thanks

Steve

Posted

Can you please state what you want to accomplish instead? Set the light to 75% from an external server? Why? Purpose?

Please explain the details, it would help you more since i guess the conversion is not 1:1 related.

  • Topic Author
  • Posted
    Can you please state what you want to accomplish instead? Set the light to 75% from an external server? Why? Purpose?

    Please explain the details, it would help you more since i guess the conversion is not 1:1 related.

    Yes that's exactly what I want to achieve. I want to send light on/off/level commands from my external controller to HC2, also when node status is changed on the HC2 i.e. light ID2 is 55% it sends an update http string to my external controller to update the lighting table web server.

    I want to do this to enable me to have both controllers in sync until I can migrate away from my old external HomeVision controller.

    Thanks

    Steve

    Posted

    Stealth, you can do all things that interface is capable of with HTTP calls, you can also read the API directly, no need to send anything back from HC2.

  • Topic Author
  • Posted
    Stealth, you can do all things that interface is capable of with HTTP calls, you can also read the API directly, no need to send anything back from HC2.

    Thank you j.nowacki, That's good to hear. I would rather HC2 push the status out to my HomeVision controller, otherwise I would have to continuously poll the HC2 from HomeVision for status updates.

    Can you confirm this is possible and where I can find help on coding the watch for status change code? I'm hoping the code from my Vera isn't too dissimilar!

    Steve

    Posted

    Just some thoughts from a Vera Lite user.

    I made the switch from Vera Lite one year ago. In my opinion Fibaro-Lua is different but also easier.

    However Fibaro still lacks the possibility to add virtual devices that act like real devices. So until we finally get the possibility to add our own plugins to HC2 this might be something you should check wether you need it. I didn't realize this at first and was missing it over a year.

    However this feature should be added in "next versions". I hope next week...

  • Topic Author
  • Posted
    Just some thoughts from a Vera Lite user.

    I made the switch from Vera Lite one year ago. In my opinion Fibaro-Lua is different but also easier.

    However Fibaro still lacks the possibility to add virtual devices that act like real devices. So until we finally get the possibility to add our own plugins to HC2 this might be something you should check wether you need it. I didn't realize this at first and was missing it over a year.

    However this feature should be added in "next versions". I hope next week...

    Thank you for the heads up on this. I wrongly assumed the HC2 would have more capabilities than the Veralite. However as long as I can get the HC2 to talk with my old HomeVision controller I think that will be enough to allow me to switch for now.

    I will need to find some help on the code first though!

    [ Added: 2015-01-18, 09:28 ]

    To confirm, If I am to switch from the Veralite platform to the HC2 then I need to achieve these two tasks -

    Part 1

    Obtain http post string to switch light node on at a defined level. Here is a sample of the Veralite http command I use to turn light node ID3 on at 75% -

    Please login or register to see this code.

    Part 2

    In order for me to track the light node level/status with my external controller, I need to update two variables that sit on the controller and then execute the macro that updates the table.

    Var 251 is HomeVision variable Node ID address

    Var 252 is HomeVision variable Light Level

    Macro 251 is HomeVision macro to put light level into custom Lighting Table

    Below is the watch code that is sat on the Veralite and runs on startup to monitor for node level/status changes and then sends out the http update strings to the HomeVision controller on 192.168.0.23:3005.

    Please login or register to see this code.

    The first call sets the light level if its a dimming node, the second sets node on or off if its not a dimming module.

    I would appreciate it if someone could help me look to achieve the same with the HC2. If so I can and will invest in the HC2

    Thanks again.

    Steve

    Posted

    The HC2 won't push the updates. You will have to poll the HC2 every second or so. If you search the forum for "HomeUnifier" you can find a package I created for a web interface which displays how to do it.

  • Topic Author
  • Posted
    The HC2 won't push the updates. You will have to poll the HC2 every second or so.

    Thanks but that's not what I wanted to hear... This is a potential deal breaker for me, I will have to give it some thought.

    Can you point me in the right direction on where I can find the Fibaro http command alternative to the Veralite http command below?

    Please login or register to see this code.

    Thank you.

    Posted

    You can create a scene in HC2 which will be triggered on change of light. In this very scene you can call post or put method to update the state. Is is good for you?

    Posted
    hanks but that's not what I wanted to hear... This is a potential deal breaker for me, I will have to give it some thought.

    Well actually, it works rather well. the polling is quite simple and response is very fast (~70 ms). You simply send a get command to:

    Please login or register to see this code.

    This will give you all the data for all devices as a json table. You can then just pick out the data you need. There is also a command which mimics a push notification by giving the changes since last polling, but I have had serious issues with this command causing the HC2 to crash, so I avoid it.

    Can you point me in the right direction on where I can find the Fibaro http command alternative to the Veralite http command below?

    Please login or register to see this code.

    I am not familiar with the Vera API, but it looks like the command sets a certain dimming level. This would be the equivalent on the HC2:

    Please login or register to see this code.

    However, this is the HC2 V3 API call. Unfortunately, Fibaro has apparently gone against good development practices and changed the API for V4, so I don't know if the same code will work on that. I've kept well clear of the v4 firmware as it is laced with serious bugs, but eventually, I will have to upgrade, and I fear that my entire setup will have to be rewritten to fit the updated API.

  • Topic Author
  • Posted
    You can create a scene in HC2 which will be triggered on change of light. In this very scene you can call post or put method to update the state. Is is good for you?

    Yes that could work as long as I wouldn't have to create a scene for every light node. If it's possible to create a single scene that updates all light node status's that could defiantly be a good option.

    Posted

    Stealth, you can trigger a scene that triggers on change of any listed devices, then in the body you can check which id was a trigger and send only its state - so everything nice and clean, with one piece of code with id that vary. Or you can send all lights status, your choice.

    Posted
    Stealth, you can trigger a scene that triggers on change of any listed devices, then in the body you can check which id was a trigger and send only its state - so everything nice and clean, with one piece of code with id that vary. Or you can send all lights status, your choice.

    But wouldn't that make the same scene run over and over again? Thinking of the drain that some scenes put on the HC2, I would think a scene which runs whenever something changes will create a lot of load (not to mention traffic on the box). If you want the HC2 to send updates, then why not just send the entire json every second or so? Also, this is still not a true push notification. You still need a script on the receiving end to collect the data.

    The clean way is to let the receiver request the data. Push was never meant for repetitive data update but purely for notification purposes.

    • 3 weeks later...
  • Topic Author
  • Posted

    Here is an update for anyone else wanting to do a similar task to what I wanted to do.....

     

    I enlisted the help of the support guys over at Fibaro UK.  (I have to say how impressed I am with how they handled my request for help and gave me a solution.)

     

    Listed below is the final working code which sends device status updates via http to my old HA controller.  I hope it’s of use to some.

    Please login or register to see this code.

     

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