Closed bazhip closed 8 years ago
Oh I forgot to add - I'm on 2.66 firmware, and I did modify the IP address of the broker to be correct.
Haven't tested on 2.66 yet, will give it a shot and get back to you. They may have moved around somethings with the new version. If you can get me more debug information from the log saved at /var/log/mqtt.log
On Tue, Aug 2, 2016 at 10:52 AM bazhip notifications@github.com wrote:
Oh I forgot to add - I'm on 2.66 firmware, and I did modify the IP address of the broker to be correct.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danielolson13/wink-mqtt/issues/9#issuecomment-236929292, or mute the thread https://github.com/notifications/unsubscribe-auth/AEs5GKZP-ibLaKjcnPdR83SYKP8JOuW8ks5qb1mYgaJpZM4JasI0 .
Okay, so I'm an idiot partially. Turns out it is running (doh) and trying to spawn it again gave the "Aborted". I didn't see it in 'top' so I thought it wasn't. Double checked with ps and there it is.
I was rather brief in my initial post. What lead me to not thinking it was running and trying to start it again was that no messages are getting published on state changes. I had this up and running nicely on 2.49, but long story short I wasn't using it for quite some time, I upgraded and reinstalled today to get it going again.
I've done some more digging and here is what I found:
On the initial boot, it is publishing out the initial states (although uncorrectly. Some things that are off are publishing as on, and some that are on are publishing as off)
Your program is correctly tailing the log file and checking the database when it reads there is a state change. What's interesting though is that it is not getting the correct results back from the query (I believe). I uncommented the console.log where it prints out the values from the query, and they are all the same as the initial publish. Since they are always the same, it is never publishing out the values.
When I publish TO it ( mosquitto_pub -t 'home/4/1/set' -m 'ON'
) it fires everything off and the database query comes back as:
runApron() -u,-m,4,-t,1,-v,ON PUBLISHING: home/4/1v: ON Publish status home 4 1 state change checkdb() home/4/1:ON:OFF different############################################# PUBLISHING: home/4/1v: OFF home/4/2:254:254 home/5/1:OFF:OFF home/5/2:254:254
(I added some extra debugging)
Then when I turn a DIFFERENT light off, it goes back to OFF state change checkdb() home/4/1:OFF:OFF home/4/2:254:254 home/5/1:OFF:OFF home/5/2:254:254
So the status is only changing when I push an update to it through MQTT, and it is only like that temporarily. It never changes the values when I do it through the app.
I wonder if something changed in the database? Maybe it's just something with my hub? It is reading correctly in the wink app though.
Thanks for digging into this deeper. My solution is by no means perfect. If I remember right the database stores a GET and SET value for each attribute value. The program may be using the wrong value from the database, i.e. GET when it should be SET. Can you see the values in the database change when you turn a device on and off with the app?
Now that 2.66 has "local control" it may be better to look at how Wink is implementing that and add MQTT support on top of that.
The reason I originally wrote this (and probably why you're trying to get it to work) is because I was looking for faster readings from sensors and lights to be more responsive. The API based HomeAssistant solution is getting better, but not quite instantaneous like local control with the wink app.
Yeah, I might just have to sit down and learn node myself :( Unfortunately I'm running OpenHAB2 rather than HomeAssistant. I might give that a try though.
Anywho, no I can't see it updating. I noticed that the database file /var/lib/databases/apron.db
hadn't been modified in about an hour as well. I'm assuming that was the last time your program had touched it.
I did a find -name *.db
on the filesystem and I found a /tmp/database/apron-2.db
that does update when I make changes.
I pointed your program at the other database and it is correctly updating now, but I feel like using the tmp database is not the correct solution...
Interesting, good investigative work. They may have changed the database location again, it changed from 2.19 to 2.49. I think they were trying to reduce the writes to the flash memory. Storing the database in tmp or RAM would extend the life of the flash memory. Just looked at my /tmp/database directory and I have apron-14.db, apron-15.db and apron-16.db. After a reboot I only have apron-2.db. Once that database grows it must create a new file.
Need to write some code to reference the most recent or highest number database file for 2.66 firmware
I don't really know node either, but I know enough javascript and google-fu to be dangerous.
On Tue, Aug 2, 2016 at 1:30 PM bazhip notifications@github.com wrote:
Yeah, I might just have to sit down and learn node myself :( Unfortunately I'm running OpenHAB2 rather than HomeAssistant. I might give that a try though.
Anywho, no I can't see it updating. I noticed that the database file /var/lib/databases/apron.db hadn't been modified in about an hour as well. I'm assuming that was the last time your program had touched it.
I did a find -name *.db on the filesystem and I found a /tmp/database/apron-2.db that does update when I make changes.
I pointed your program at the other database and it is correctly updating now, but I feel like using the tmp database is not the correct solution...
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/danielolson13/wink-mqtt/issues/9#issuecomment-236979304, or mute the thread https://github.com/notifications/unsubscribe-auth/AEs5GNEuqhNLW-ehJqDrQtvBIq5CXJODks5qb37BgaJpZM4JasI0 .
Are you saying you had 14, 15, and 16 on 2.66 or are they also there on 2.49?
Same issue here; upgraded to 2.66 today and wink-mqtt stopped working. After troubleshooting for several hours, have decided to give it a rest for a bit. Daniel, any help would be appreciated.
FYI, below are my databases:
Yeah, follow the comment thread. Modify the script and point the database path at the one in /tmp/ They moved it again in 2.66. looks like they auto increment as well once it gets too big. The script needs to be modified to look for the database with the largest number, or do what I do and when a new database is created, just reboot lol
Yep, that works. Did that after my previous post. the one in /tmp (currently apron-2.db) is working. I may create a timer to reboot the hub every day or so (not sure if that is enough). How often are you rebooting?
Iunno, maybe once a week? If you do it daily at some freakish hour of the night, you should be fine. I just don't have time to learn node right now to modify the script.
edit: removed
Issue fixed
So I ran npm install, copied all the files over, and modified the init. I noticed it wasn't running after the reboot so I manually started it with the script. Still wasn't running after that. I manually started it with "node wink-mqtt.js" while I was in the directory and it said 'Aborted' and quit out. I threw some console prints in there and it's executing them. I have zero experience with Node unfortunately, so I can't do much debugging. Any ideas?