I’m relatively new to OpenHAB and I’ve Googled all over the place for this. Maybe I just don’t get it. Anyways, I have some zwave door sensors hooked up to my Wink hub. When the door opens, the Wink hub sends an MQTT message saying “OPEN”, and when it’s closed, it says “CLOSED”. I’m storing this in a String item, and it’s displayed in my sitemap.
My problem is, that when my browser is opened up to OpenHAB, it gets the updates and it works great. If I hit F5 and reload it, the values disappear and the Strings go blank. If I open it up in a new tab, same thing: blank Strings.
I set up MySQL for persistence, but it doesn’t seem to immediately solve my problem. Still blank when I load it up. I opened up the database, and it is indeed getting every update logged into it.
How the heck do I make it load the last value in the database when I load the page for every item? Can someone give me an example please? I feel like this is stupid-easy, but I just don’t get it. I saw that there is an .previousState(), but I don’t know how to use it.
In fact, there should be no need to do extra work. openHAB does an update to items only if it receives an update or command through a binding or through the UI.
Which version do you use? What is your item definition? Your Sitemap? Any rules belonging to the item?
Weird. Okay, I’ll give you my confs (there isn’t too much) I’m running Openhab 2.0 Beta 3. The other thing to note is that I’m also running my.openhab on there. On the my.openhab website, everything is mirrored perfectly, but same problem. When I reload, the String/Text items disappear. As I’m typing this, I’m realizing that they’re not just String/Text items, they’re also being populated through MQTT. I wonder if that has something to do with it?
I should note that the switch and the dimmer states all persist, just not the String/Text/MQTT items.
Thanks again!
Rules
default.rules
rule "Milk Dash Button"
when
Item milk received update
then
publish ("pi","home/ac","power")
end
rule "Chunky Dash Button"
when
Item chunky changed
then
publish("pi","home/receiver","power")
Thread::sleep(300)
publish("pi","home/receiver","direct")
Thread::sleep(300)
publish("pi","home/projector","powerscript")
end
I don’t think so It looks like that is just the items losing their formatting, rather than the value itself. Do you know how I would force a poll from mysql on page load? Or maybe every 2 seconds or something like that?
I don’t think constant polling of your persistence backend is going to solve your problem. As Udo mentioned, item values in OH should not be changing unless they are updated by the device. You should be able to see in the logs when an item changes.
What browser are you using? Have you tried a different one? Is the behaviour consistent in both Classic UI and Basic UI?
Yeah, I checked the events log and everything looks good. Here is a snippet:
2016-08-22 08:12:14.076 [ItemStateChangedEvent ] - Kitchen changed from TRUE to FALSE
2016-08-22 08:28:18.059 [ItemStateChangedEvent ] - Kitchen changed from FALSE to TRUE
2016-08-22 08:31:27.979 [ItemStateChangedEvent ] - Kitchen changed from TRUE to FALSE
2016-08-22 09:34:49.721 [ItemCommandEvent ] - Item 'AC' received command ON
2016-08-22 09:34:49.774 [ItemStateChangedEvent ] - AC changed from OFF to ON
2016-08-22 09:35:35.719 [ItemCommandEvent ] - Item 'AC' received command OFF
2016-08-22 09:35:35.758 [ItemStateChangedEvent ] - AC changed from ON to OFF
2016-08-22 09:35:42.137 [ItemCommandEvent ] - Item 'LinkLight_Kitchen1' received command 0
2016-08-22 09:35:42.178 [ItemStateChangedEvent ] - LinkLight_Kitchen1 changed from 59 to 0
2016-08-22 09:35:42.543 [ItemCommandEvent ] - Item 'LinkLight_Kitchen1' received command 0
But when I open up a browser, all of the text fields are blank. Like I said before, all the sliders and switches values persist, and all of the data is in MySQL. One of the big things I need is to be able to open up OpenHAB and see the values of my sensors, ie: if I left a door open. I can’t wait until a new MQTT command is sent to find that out (since that will be when I come back home and close the door).
Behavior is consistent in Classic and Basic UI. I’ve been using Chrome, but I just tried Safari and it is exhibiting the same behavior. The reason I suggested the constant polling is because although ghetto and resource intensive, at least I’d be able to see them.
I’ve been thinking about having my Wink hub broadcast all of the MQTT values once every 10 seconds or so, but it’s not too powerful and I don’t want to put a strain on it.