genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
392 stars 155 forks source link

statistics.history array is broken #228

Closed bkenobi closed 8 years ago

bkenobi commented 8 years ago

As reported in this thread: http://www.homegenie.it/forum/index.php?topic=1101.0

The history array only holds the first element and all others seem to be invalid. HistoryLimit is not set other than by default.

bkenobi commented 8 years ago

It looks like there was a recent change to how the historyValues array is defined. I don't know that this is the issue for sure, but it certainly is suspicious to me.

https://github.com/genielabs/HomeGenie/commit/e34249b24333d6517af148d488c08d347da5084c#diff-d92ebc3e06276c231a9e2cfbb19fb07cL47

I see that the initialization is performed a few lines down, but for some reason historyValues array only contains one value for me.

bkenobi commented 8 years ago

I built a test program to see if timers work at all using DateTime.Now and TimeSpan functions with a simple 1 minute offset. That still functions. The Advanced Smart Lights code doesn't do anything more complicated other than storing the timestamp in a module parameter and utilizing the HistoryValue array. Since I've looked at the parameter value and can confirm that it's set to a value that seems appropriate and I have seen that the values within HistoryValue above element 0 do not exist, I believe I have narrowed this down. However, I have no way to fix it. I guess I'll just migrate back to r493 or earlier so that I can get my system working. It looks like there are a number of people using my APP as well, so I'll recommend in that thread that they migrate back/don't update until a resolution is found.

dansantee commented 8 years ago

I'm having a similar problem which may be related - LastOn and LastOff values do not seem to work correctly. For example, if I turn a device on, then off, then on again (in code or interface), the values for LastOn and LastOff do not update correctly, and instead give old values.

genemars commented 8 years ago

please try r497 hope it is fixed now!

genemars commented 8 years ago

oh-oh... it still needs a little fix... gonna do now

genemars commented 8 years ago

it's fixed now. for testing you can try calling the new API command

/api/HomeAutomation.HomeGenie/Config/Modules.StatisticsGet/<domain>/<address>/<parameter>

eg. http://10.10.5.7/api/HomeAutomation.HomeGenie/Config/Modules.StatisticsGet/HomeAutomation.PhilipsHue/1/Status.Level

{
  "HistoryLimit": 1440,
  "History": [
    {
      "Value": 0.8,
      "Timestamp": "2015-10-10T16:04:21.187622Z",
      "UnixTimestamp": 1444493061187.6221
    },
    {
      "Value": 0.0,
      "Timestamp": "2015-10-10T15:39:09.578046Z",
      "UnixTimestamp": 1444491549578.0461
    },
    {
      "Value": 0.8,
      "Timestamp": "2015-10-10T15:38:38.088862Z",
      "UnixTimestamp": 1444491518088.8621
    },
    {
      "Value": 0.0,
      "Timestamp": "2015-10-10T15:37:41.017358Z",
      "UnixTimestamp": 1444491461017.3582
    },
    {
      "Value": 0.0,
      "Timestamp": "2015-10-10T15:37:41.01737Z",
      "UnixTimestamp": 1444491461017.37
    }
  ],
  "Current": {
    "Value": 0.8,
    "Timestamp": "2015-10-10T16:04:21.187622Z",
    "UnixTimestamp": 1444493061187.6221
  },
  "Last": {
    "Value": 0.0,
    "Timestamp": "2015-10-10T15:39:09.578046Z",
    "UnixTimestamp": 1444491549578.0461
  },
  "LastOn": {
    "Value": 0.8,
    "Timestamp": "2015-10-10T16:04:21.187622Z",
    "UnixTimestamp": 1444493061187.6221
  },
  "LastOff": {
    "Value": 0.0,
    "Timestamp": "2015-10-10T15:39:09.578046Z",
    "UnixTimestamp": 1444491549578.0461
  }
}
bkenobi commented 8 years ago

I'm away from my system but will update tomorrow or Monday. If a web update were released, I could try this afternoon.

genemars commented 8 years ago

a web update will be available as soon as the latest release can be considered stable (almost :)).

noliono commented 8 years ago

It work fine on my side on 1.1 r497. Thanks Gene.

bkenobi commented 8 years ago

My house lost power and the IP must have changed. My IP change notification APP doesn't email anymore, so I'll have to update when I get home and find the new IP.

bkenobi commented 8 years ago

Looks like the fix worked for the Advanced Smart Lights APP.

genemars commented 8 years ago

good, close the issue if your testing is complete and positive.

bkenobi commented 8 years ago

I have an issue with severe lag on my setup that is likely unrelated. I will do some testing to verify that it is unrelated to the HG update. I believe it is related to a power failure that may have caused a module or other electronic to go bad. I will close the issue when I confirm it is not related to HG.

bkenobi commented 8 years ago

I confirmed that the code works.

My issue with large delays seems to be unrelated. Issue closed.