This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Official

[BETA Release] HomeyDash a Dashboard app for homey

1356742

Comments

  • Video of the working device switches: (to bad you just can't see the device switching...but it works;) )

  • That's looking pretty awesome @swttt! I tried to run this on my Windows 10 pc to see what it looks like but I get the following error in the console window of my browser after putting my IP and API (Homey cloud id???) into the config.json:

    angular.js:11630 XMLHttpRequest cannot load file:///C:/Users/Robert/Desktop/HomeyDash-master/config.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

    The page is just showing the blue background color, that's it.

    Do you know how to solve this? Also I found in the index.html 2 hardcoded IP addresses, presumably from your Homey? 192.168.2.72 ....Modified these to match my Homeys IP but still no luck.

    Keep up the good work :)
  • @RobertLijkendijk ;
    Oh ye, need to fix those hardcoded ip's :dizzy: 

    The api key is the bearer token. If you go to my.athom.com and login it blinks in the adress bar. you can find it in the cookies or sniff the rest api as well.

    Not sure if it runs ok without a webserver tho, haven't tried that :smile: (it might work to test quickly, but in a live environment you want to access the dashboard on your local network)
    You might need something like xampp to run it on. 
  • Thanks for the quick feedback @swttt! I got it to work using the bearer token instead of the Athom Cloud ID. It was pretty easy to get the bearer token. I logged in to my.athom.com and then right clicked the big "Homey" button and choose: copy link address. Then pasted the result to notepad and then copied the bearer token from there. Perhaps a good idea to add it to the readme.cmd ? :smile:

    I think I should indead set it up on a webserver but I wanted to test it first. In Microsoft Edge, Internet Explorer and Google Chrome the page was just empty. Opened the index.html in Mozilla Firefox and the page loads and I can control my devices, although they do not show device icons.

    Also I would like to say the performance seems to be really good. When I click on one of my Hue lights on your page the devices switches on or off instantly, really really cool! Thumbs up! :sunglasses:  Keep up the good work!
  • Thanks for the quick feedback @swttt! I got it to work using the bearer token instead of the Athom Cloud ID. It was pretty easy to get the bearer token. I logged in to my.athom.com and then right clicked the big "Homey" button and choose: copy link address. Then pasted the result to notepad and then copied the bearer token from there. Perhaps a good idea to add it to the readme.cmd ? :smile:

    I think I should indead set it up on a webserver but I wanted to test it first. In Microsoft Edge, Internet Explorer and Google Chrome the page was just empty. Opened the index.html in Mozilla Firefox and the page loads and I can control my devices, although they do not show device icons.

    Also I would like to say the performance seems to be really good. When I click on one of my Hue lights on your page the devices switches on or off instantly, really really cool! Thumbs up! :sunglasses:  Keep up the good work!
    Creative find! I would have looked in the source :expressionless: 
    Currently i am testing it in chrome, so if you run it on a web server it should work in chrome as well. (since its working for me as well) The device icons are the ones hardcode in the index.html you should change the ip there, and they should work.

    Currently working on the dim function :) Will share when i commit it to github.
  • Created a webserver on my Raspberry PI running Domoticz, and moved your files over there. The page now works in EDGE / IE / CHROME / FIREFOX. I still didn't see Icons though... Then I noticed I made a mistake editing your hardcoded IP addresses. After changing the IP I do get icons in Chrome. :smile:   Still no icons though in the other browsers.
  • @RobertLijkendijk ;
    Not sure why, but might have something to do with css styling. But i am only testing in Chrome at the moment :)

    Good that it works tho! 
  • swtttswttt Member
    edited August 2016
    Updated the code on github.

    Dimming now works, had to change the "steps" to 10% instead of 1%. Otherwise it where to many api calls (every 1% one call).

    To dim long press the device and drag left to decrease and right to increase.
    On/off swithing is a single tap on the device.


  • how to get my homey api?
  • TarikFaik said:
    how to get my homey api?
    It is in the readme ;)
  • supericesuperice Member
    edited August 2016
    swttt said:
    Updated the code on github.

    Dimming now works, had to change the "steps" to 10% instead of 1%. Otherwise it where to many api calls (every 1% one call).

    To dim long press the device and drag left to decrease and right to increase.
    On/off swithing is a single tap on the device.


    You don't want to use 10% steps; 1% steps are just fine, as long as you use a debouncer ;)

    A debouncer delays the call a few hundred milliseconds. If in the meantime another call is scheduled, the original get's cancelled. Some example code:

    var debouncer = null;
    function updateValue(val) {
      if (debouncer) clearTimeout(debouncer);
      setTimeout(function() {
        actualUpdateValue(val);
      }, 300);
    }

    This code would delay the call to the API until there hasn't been an update for 300ms.

    Alternatively; if you do want to update the value whilst the user is sliding the dimmer, but want to limit the amount of API requests within a given time, you could implement the debouncer like this:

    var lastValue = null;
    var nextCall = null;
    function updateValue(val) {
      lastValue = val;
      if (nextCall) return;
      setTimeout(function() {
        nextCall = null;
        actualUpdateValue(val);
      }, 300);
    }

    This makes sure the API is called, but it leaves at least 300ms between the calls. (This makes sure that when the user is sliding the dimmer, the user does see the target device change even though he/she doesn't take his/her finger of the screen).

    Please note that the 300ms is just an example, you could try to use other values. In my personal experience 300ms works just fine for generic applications, but YMMV.
  • @superice ;
    Thanks for the suggestion, going to try it out.
    Not sure if the api couldn't handle it (on the desktop i had (almost) no issues with the 1%) or that it was the fact i was testing it on a touch device (that the device couldn't handle so much api requests).

    Would u advise to use timeout or interval? I noticed that timeout triggerd really late on slow devices (since it builds up the requests). But interval gave me some disco lights so now and then :smiley: 

  • TarikFaik said:
    how to get my homey api?
    Im sorry, just noticed i didn't comitted to my github yet.. LOL
    So it's not in the readme, you should read above comments.
  • Looks nice, thanks for your work so far! Only the device placement in the zones is not correct. For example my living room lights is suddenly in the bathroom (where I have no devices yet)
  • Looks nice, thanks for your work so far! Only the device placement in the zones is not correct. For example my living room lights is suddenly in the bathroom (where I have no devices yet)
    Thats weird, that shouldn't and in theory can't happen.
    I query the api for every zone. On first start you need to select a zone, and it saves it to the localstorage.
    Every time you change to a zone, this setting gets updated to the new zone id.

    Then i get a list of all the devices, and filter them based on the parent zone id.

    What browser are you using? And did you check if you didn't move the device by accident? :wink: 

  • Created a webserver on my Raspberry PI running Domoticz, and moved your files over there. The page now works in EDGE / IE / CHROME / FIREFOX. I still didn't see Icons though... Then I noticed I made a mistake editing your hardcoded IP addresses. After changing the IP I do get icons in Chrome. :smile:   Still no icons though in the other browsers.
    Can you give me some tips how you did this.
    thanks in advance.
  • Just updated Github (thought i did that yesterday lol).

    @HansieNL I guess there are allot of tutorials on how to get a simple webserver running. The most common way for testing would be to install xampp or something similar. Then clone the git or download the zip and add it to the htdocs folder.

    How to get the api key is in the readme.

    Will have a look tonight to fix the hardcoded ip's in the html.
  • @HansieNL are you running a Raspberry PI with Domoticz? It propably has nginx webserver preinstalled. You can check this by going to http://<raspberry pi ip here> and see if you get a nginx welcome page. If you do you can create a new directory (for example: homey) in the following path: /usr/share/nginx/www/ and upload the files posted on github there with for example WinSCP.

    If you just have raspberry pi without a webserver you can install Apache using the command:
    sudo su
    apt-get install apache2

    Files can be placed in /var/www

    This is just to get a simple webserver up and running to try out the nice work @swttt is doing. I would not recommend making it accessible from the internet without doing some more configuration.

    @swttt nice update with sliding to control the dimming level. It does work, although the actual dimming seems to have some delay after adjusting the dim level using the web interface. Perhaps this is due to my webserver which runs on a low performance raspberry pi 1.... :smile:
  • @RobertLijkendijk ;
    Not sure, happend to me when controlling trough my iphone 6s and cheap tablet.
    Going to edit the code as suggested by Superice, might improve the speed :smile: 

  • @HansieNL are you running a Raspberry PI with Domoticz? 
    I running Domoticz on RPi. If I got to RPi webadress I get Domoticz interface. Do I have to install a 2nd webserver or can I use Domoticz internal one and just put files in a sub folder of the www folder?
  • @HansieNL I think so, don't think that is gonna break anything :smile:
  • Create a sd card backup before you go with Win32DiskImager (https://sourceforge.net/projects/win32diskimager/)

  • swttt said:
    @superice ;
    Thanks for the suggestion, going to try it out.
    Not sure if the api couldn't handle it (on the desktop i had (almost) no issues with the 1%) or that it was the fact i was testing it on a touch device (that the device couldn't handle so much api requests).

    Would u advise to use timeout or interval? I noticed that timeout triggerd really late on slow devices (since it builds up the requests). But interval gave me some disco lights so now and then :smiley: 

    Since you'd want to schedule it manually, I'd say setTimeout is a better candidate. Interval will execute the function multiple times, every x milliseconds, so you'd have to remember to cancel it in every possible path of the code, which is tricky to get right. I think they have pretty much the same implementation, so it's almost impossible that setInterval works, but setTimeout doesn't.

    Also, setTimeout and setInterval are by design specified wait AT LEAST the time you give it. Because JavaScript is single threaded, and has an event loop to handle asynchronous code, it'll never break a running piece of code to execute something asynchronous. Everything that does not happen right now (e.g. asynchronous) is scheduled in the event loop. Only if the engine is idle (every function has returned, but there are still HTTP requests running) then it'll run all other stuff from the event loop. So if you do a computationally expensive operation while the timeout is supposed to fire, it'll first finish the action you're doing and fire the setTimeout whenever the JS engine becomes idle. Normally this is close enough, but if you're doing expensive computations (lots of DOM updates, heavy algorithms etc.) it might fire later than expected. (This should be seen as a red flag, there are almost no cases where it's acceptable to compute heavy stuff without breaking it into tiny pieces so the event loop doesn't get blocked.)

    Perhaps you're doing a lot of DOM operations when the user selects a percentage? Ideally, for 60fps silky smooth performance, you should allocate as little memory and do as few DOM operations as possible while the user is interacting with the page, or animations are playing. Garbage collection (when JS looks for old unused data in memory and throws it away, because it needs more space) may block code execution for tens or even hundreds of milliseconds on slow devices, which causes frames to drop, setTimeouts to fire later, and the UI to feel stuttery. Desktops don't suffer from this as much because they're much faster, but especially older mobile devices tend to freeze up when you're not careful. Writing high performance mobile UIs in a garbage collected languages is hard ;)
  • So.....

    Didn't had allot of time last week, so no progress.
    Since z-wave is working, it took some time to add everything to the homey. And set up everything.
    I also bought a cheap 7 inch tablet and noticed the current UI is too small for the tablet.

    In chrome i checked with the "mobile device view", had it on 100% but still that isn't the true size. (might had something to do with pixels per inch or something)

    Will look at the code posted above to get the dimmer more fluent and will investigate if there are alternative ways to control the dimmers. 7 inc is really smaller as expected, so the panning on the "device card" is really precies/small.
  • swttt said:
    ..and will investigate if there are alternative ways to control the dimmers. 7 inc is really smaller as expected, so the panning on the "device card" is really precies/small.
    Just reconsider my previous post :wink: I still think it makes sense... 
  • jovink said:
    Great idea!
    maybe you can look at this for inspiration http://carmelarad.com/homey.html
    This looks very great. 
    Is this an actual (work-in-progress) dashboard for homey? Or just some general design mockup idea?
    It looks amazing!

  • @omriamos: As far as i can tell it's a mock-up from an UI and UX designer. It would be kind off hard to create something equal, since that dashboard mock up is really compact, and the homey has lots of possibilities. Some people don't have an alarm system, door sensors or camera's. 

  • Michael said:
    swttt said:
    ..and will investigate if there are alternative ways to control the dimmers. 7 inc is really smaller as expected, so the panning on the "device card" is really precies/small.
    Just reconsider my previous post :wink: I still think it makes sense... 
    I am ;) working on the new UI first, as i can re-use the api code written before. Works allot better to test on a real device then using the chrome mobile preview function.
  • I Love the dashboard. definitely going to do a test run.
  • @nklerk Then at least wait on the next version ;) Makes it more usefull on 7 inch devices.
Sign In or Register to comment.