Read state of the items when openning the openHAB web page

I wonder how to trigger reading state of the items when I open the web page to have actual status at the begging. I have MQTT communication with arduino, it works well but I do not have the correct status at start .

You do not have the correct status at the start of OpenHAB or at the start of the UI?

Have you considered saving the state of your important items and setting them to restoreOnStartup ?

Assuming you do indeed mean the web page (if you mean OH start see @jflarente’s response) there is no way to do what you are asking. You should configure your Items so they are reasonably up-to-date anyway as you wouldn’t want your Rules to be operating on old data.

You could add a switch to poll the devices (i.e. send an MQTT message to have the devices report their current status) to your sitemap. I actually do something similar only from a system started rule so I pick up any changes that occurred while OH was down.

I was thinking about the same solution , something like refresh button which send a command to the devices to report current status. It would be nice if it could be done in automatic way when I open the openHAB web page and I can see current status.

There is no known mechanism for OH to do this. From OH’s perspective the UI is just a bunch of calls to the REST API.

And, lest my original point gets lost, if you are worried about the state of the Items when you load the UI, you should also be worried about the state of the Items in your Rules. So you should really be keeping the state up to date at all times, not just when the UI is opened.