[ANSWERED]: Fast switches are not saved properly

Posted on
Mon Mar 02, 2015 4:54 pm
davinci offline

[ANSWERED]: Fast switches are not saved properly

If I switch on and off a light quick enough the state in SQLite does not match the real state. What can I do to avoid this? Is this a bug?

Posted on
Wed Mar 04, 2015 2:58 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Fast switches are not saved properly

As long as the Event Log is showing the commands are received, they should be logged in the SQLite database. If the Event Log doesn't show them, then the problem is there is too much traffic and the interface isn't able to capture all the commands (thus Indigo doesn't know about all of them).

Image

Posted on
Wed Mar 04, 2015 3:42 pm
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

Ok thanks, what would happen if the database is locked at the time of the event? Is there a timeout?

Posted on
Thu Mar 05, 2015 9:52 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: [ANSWERED]: Fast switches are not saved properly

Only Indigo should be writing to that database, so locking shouldn't be an issue.

Image

Posted on
Sun Jun 28, 2015 6:56 am
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

I still have the problem. If I switch on off a Fibaro switch the database shows it is on, but Indigo shows it is off (which is true).

So there IS an issue.

Posted on
Sun Jun 28, 2015 8:38 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]: Fast switches are not saved properly

davinci wrote:
I still have the problem. If I switch on off a Fibaro switch the database shows it is on, but Indigo shows it is off (which is true).

So there IS an issue.


How are you looking at the database? Maybe it's a caching issue with whatever you're using. Or Indigo has queued up a write to the database, but it hasn't actually happened yet.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Jun 28, 2015 12:11 pm
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

Last time I switched it was hours ago so Indigo should have plenty of time to write.

I use php to access it.
Code: Select all
$db = new SQLite3('indigo.sqlite');
$db->busyTimeout(5000);
$status = ($db->querySingle('SELECT value FROM variable_history_124430741 ORDER BY ts DESC LIMIT 1'));

Posted on
Sun Jun 28, 2015 12:12 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]: Fast switches are not saved properly

Try changing the limit on that query and see if they're possibly in the database in the wrong order. Print out the timestamp too.

Code: Select all
$db = new SQLite3('indigo.sqlite');
$db->busyTimeout(5000);
$status = ($db->querySingle('SELECT value, ts FROM variable_history_124430741 ORDER BY ts DESC LIMIT 2'));

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 29, 2015 10:54 am
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

I'm expecting exactly this. I simply read the last value with this code.

But somehow it writes first off, then on. So the timecode of the event or of the database is wrong. Since the switch stays off I expect the reporting to be ok. This happened with Fibaro switches as well as with Philio ones.

Posted on
Fri Dec 04, 2015 11:14 am
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

Problem still exists!

Often values are different to the states the devices really have!

What can I do?

Posted on
Mon Dec 07, 2015 2:35 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: [ANSWERED]: Fast switches are not saved properly

I've tried a few different ways, but I'm unable to reproduce this problem.

Can you reproduce it, then copy/paste the lines from the Event Log file, as well as run an SQL query to show exactly what is written to the database? I need to compare what the database shows with what the Event Log is showing to try to figure out how it can be getting off. When copy/pasting from the Event Log please do so from the Event Log file itself and not the Event Log window. The file will show precise time stamps for every line which I will need to try to piece together what is occurring.

Image

Posted on
Sat Dec 12, 2015 3:53 am
davinci offline

Re: [ANSWERED]: Fast switches are not saved properly

It looks like it is ok, both the log and the SQL have the exact same value. However when I access the database with this code it fails:
Code: Select all
($db->querySingle('SELECT onoffstate FROM device_history_1094248805 ORDER BY ts DESC LIMIT 1'));

It picks the wrong one, probably because it is only having a timestamp accuracy of a second. Therefore it takes the wrong value.

After changing ts to id it works.

Problem solved!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests

cron