more G-Labs products

Author Topic: HomeGenie Plus for Android  (Read 33083 times)

November 09, 2015, 07:26:15 PM
Reply #75

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I think that the Fibaro RGB program needs to be fixed/updated. Because it's actually accept the Color.Hsb command but interprets it as rgb values. So a fix to the program could be changing the current Color.Hsb to Color.Rgb and add a properly implemented Color.Hsb command that converts values from hsb to rgb.

g.

I just checked it and you are correct, it's not a problem with HomeGenie Plus.

If Dani doesn't mind I'll have a go at changing the Fibaro RGBW APP (and widget). Although I had a lot of problems converting RGB to HSV previously.

November 09, 2015, 07:44:47 PM
Reply #76

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi mvdarend.

try this:

Code: [Select]
var ColorFromHSL = new Func<double,double,double,dynamic>((double hue, double saturation, double brightness) => {
  double red = 0, green = 0, blue = 0;
  if (saturation == 0)
  {
    red = green = blue = brightness;
  }
  else
  {
    // the color wheel consists of 6 sectors. Figure out which sector you're in.
    double sectorPos = hue / 60.0;
    int sectorNumber = (int)(Math.Floor(sectorPos));
    // get the fractional part of the sector
    double fractionalSector = sectorPos - sectorNumber;

    // calculate values for the three axes of the color.
    double p = brightness * (1.0 - saturation);
    double q = brightness * (1.0 - (saturation * fractionalSector));
    double t = brightness * (1.0 - (saturation * (1 - fractionalSector)));

    // assign the fractional colors to r, g, and b based on the sector the angle is in.
    switch (sectorNumber)
    {
      case 0:
        red = brightness;
        green = t;
        blue = p;
        break;
      case 1:
        red = q;
        green = brightness;
        blue = p;
        break;
      case 2:
        red = p;
        green = brightness;
        blue = t;
        break;
      case 3:
        red = p;
        green = q;
        blue = brightness;
        break;
      case 4:
        red = t;
        green = p;
        blue = brightness;
       break;
      case 5:
        red = brightness;
        green = p;
        blue = q;
        break;
    }
  }
  dynamic color = new ExpandoObject();
  color.Red = (int)(red*255d);
  color.Green = (int)(green*255d);
  color.Blue = (int)(blue*255d);
  return color;
});

and call it like:

Code: [Select]
// Example hsv values
double h = 0.28954248366013263 * 360; // <-- multiply first value by 360
double s = 0.8437499999999998;
double v = 0.7529411764705882;
// Get the RGB data
var colorRgb = ColorFromHSL(h, s, v);
Program.Notify("Coverted to RGB", String.Format("R={0},G={1},B={2}", colorRgb.Red, colorRgb.Green, colorRgb.Blue));

g.

EDIT: updated code with a better (and tested) version :)
« Last Edit: November 09, 2015, 09:17:45 PM by Gene »

November 10, 2015, 07:05:36 AM
Reply #77

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Thanks Gene, I'd implemented the code, but I didn't see your update until this morning. I was having problems with the colours not matching, I'll test it more this evening.

November 10, 2015, 01:32:11 PM
Reply #78

Michel

  • **
  • Information
  • Jr. Member
  • Posts: 42
Is the Weather Underground widget refresh has been fixed ? I still need to restart HG+ to update.

November 10, 2015, 01:39:05 PM
Reply #79

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Yes michel it's fixed, but did you update to HG r500? :)

g.

November 10, 2015, 02:55:06 PM
Reply #80

Michel

  • **
  • Information
  • Jr. Member
  • Posts: 42
I'm running HG v1.1 r500 on Raspberry Pi 2 and HG+ rev 12 on Samsung tablet and Nexus 5 phone. Same behaviour on both machines.

November 10, 2015, 04:25:55 PM
Reply #81

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Michel,

please open the weather underground program in the editor and look at line 102:

Code: [Select]
      Program.RaiseEvent("Program.UiRefresh", "Data Updated", "");

do you have that? If you see that, can you try recompiling the program? Perhaps missed to update the app properly in r500.


November 10, 2015, 06:35:23 PM
Reply #82

Michel

  • **
  • Information
  • Jr. Member
  • Posts: 42
Thanks Gene,

That did the trick. I'm using a custom Weather Underground program that I modified to add  some time expressions based on sunset time in WU.

Is there a way to know the last date and time a program being part of HG has been modified ? That would allow us to check this info against or custom programs.

November 10, 2015, 07:03:35 PM
Reply #83

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Thanks for the code example Gene, I've renamed the original ColorHsb to ColorRgb and used your code in the new ColorHsb, and now the Fibaro RGBW works with HomeGenie Plus

The web widget also works with the new code. I'll do some more testing and code cleanup. I'll submit a pull request within a few days.

November 10, 2015, 09:27:10 PM
Reply #84

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hi,
I found a bug on my tab but not on my phone in rev 12.

The app work fine on my tab in portrait mode, but when i launch the app in landscape mode, if i change the group, the app crash.
But on my phone no crash in the 2 mode ...

  • My tab on android 4.4.2 (no update available).
  • My phone on android 5.1.1

Update: that bug too on my phone each time I change or launch to landscape mode.
« Last Edit: November 11, 2015, 08:03:16 AM by nolio »

November 10, 2015, 09:28:53 PM
Reply #85

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Enhance the application by interacting with "android wear".
For example, arm/disarm alarm from a smart watch.

November 11, 2015, 10:34:04 AM
Reply #86

KaZe

  • ****
  • Information
  • Sr. Member
  • Posts: 219
Enhance the application by interacting with "android wear".
For example, arm/disarm alarm from a smart watch.
It's interests me too!  8) :D

November 13, 2015, 10:28:28 AM
Reply #87

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I've modified Dani's Fibaro RGBW app to be compatible with HomeGenie Plus. Would anyone be interested in testing it?

The first file is a modified .hgx, you can either import it as a new program or overwrite the existing 'Program code' with the contents.

The second file; DaniMail-Fibaro-RGBW.js is for the Widget.
- Go to Configure -> Widgets
- Open the DaniMail/fibaro/rgbw widget
- Go to the Tab 'Javascript'
- Replace the code with that in the file.

- Known issue. Changing the color from HomeGenie Plus will update the color in the Web interface, but updating from the web interface or from a program will not update the color in the HomeGenie Plus interface. (It will show on/off state though)

November 13, 2015, 02:23:55 PM
Reply #88

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
Hi Marcel,

I got HG Plus for my phone and Tablet few days ago, I will test your modifications end of afternoon.

Tests and Updated on 14 Nov. 11:30 :
I have tested with multicolor led strip, and your update dosn't work for change to fixed color. If I choice any color, the Led are shut off. With HG Plus under droid, Any action in the 4 default colors the led are shut off also. And I don't have access to a color wheel anymore.

Cheers
Dani
« Last Edit: November 14, 2015, 11:31:41 AM by dani »

November 13, 2015, 02:27:42 PM
Reply #89

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
Hi Gene,
I build some special widgets as Pilot Heater French system with some png button. Is it possible that those widgets pass through the screen of HG Plus ?
Cheers
Dani