Can't get it to work. Ask you for help

Hello everybody. Ask you for help.

I have configured OH (2.5), partially via Paper UI, partially via configs, and it worked almost fine.
MQTT Binding, MQTT Things and its Channels, and Items were configured by Paper UI.
Sitemap, Persistence and Items were made in text configs (Items in config were duplicated from PaperUI).

Now I try to configure everything with configs only, and can’t get it to work, at the same time I do not get errors in logs. Tried this way and that, but cant get it up running.

I have added MQTT bridge definition and Things definition to config files and removed them in PaperUI.
Now it is configured as follows:

/etc/openhab2/things/default.things

Bridge mqtt:broker:pibroker [ host="192.168.0.99", secure=false, username="pi", password="mySuperSecurePasswordEver"]
{
Thing topic main_pi "Main Pi (Thing)" @ "Room" {
Channels:
String : uptime_channel [stateTopic="/home/pi/uptime"]
String : load_channel [stateTopic="/home/pi/loadaverage"]
String : cputemp_channel [stateTopic="/home/pi/temp"]
}

Thing topic kitchen_controller2 "Kitchen controller #2 (Thing)" @ "Kitchen" {
Channels:
Number : humidity_channel [stateTopic="/home/kitchen/hum"]
Number : temperature_channel [stateTopic="/home/kitchen/temp"]
Number : pressure_channel [stateTopic="/home/kitchen/pres"]
Switch : led_channel [stateTopic="/home/kitchen/led_info", commandTopic="/home/kitchen/led", on="1", off="0"]
String : msg_channel [stateTopic="/home/kitchen/msg"]
String : ip_channel [stateTopic="/home/kitchen/ip_address"]
String : firmware_channel [stateTopic="/home/kitchen/firmware_version"]
}
}

/etc/openhab2/items/room.items

String pi_uptime "Uptime" {channel="mqtt:topic:pibroker:main_pi:uptime_channel"}
String pi_load "Load average" {channel="mqtt:topic:pibroker:main_pi:load_channel"}
String pi_cputemp "CPU Temp" <temperature>{channel="mqtt:topic:pibroker:main_pi:cputemp_channel"}

/etc/openhab2/items/kitchen.items

String kitchen2_msg "Msg" { channel="mqtt:topic:pibroker:kitchen_controller2:msg_channel" }
String kitchen2_ip "Ip" { channel="mqtt:topic:pibroker:kitchen_controller2:ip_channel" }
String kitchen2_firmware "Firmware" { channel="mqtt:topic:pibroker:kitchen_controller2:firmware_channel" }
Number kitchen2_temperature "Temperature [%.1f °C]" <temperature> { channel="mqtt:topic:pibroker:kitchen_controller2:temperature_channel" }
Number kitchen2_humidity "Humidity [%.1f %%]" <humidity> { channel="mqtt:topic:pibroker:kitchen_controller2:humidity_channel" }
Switch  kitchen2_led "LED" <light> ["Lighting", "Switchable", "Kitchen"]    { channel="mqtt:topic:pibroker:kitchen_controller2:led_channel" }
Number  kitchen2_pressure "Атмосферное давление [%.1f hPa]" <pressure>  { channel="mqtt:topic:pibroker:kitchen_controller2:pressure_channel" }

/etc/openhab2/sitemaps/flat.sitemap

sitemap flat label="SmartestEverFlat" {
Frame label="Kitchen" {
Text item=kitchen2_msg label="Msg"
Text item=kitchen2_ip label="IP"
Text item=kitchen2_firmware label="Firmware"
Switch item=kitchen2_led icon="light"
Text item=kitchen2_temperature label="Temperature [%.1f °C]"
Chart item=kitchen2_temperature period=24h refresh=10000 service="jdbc"
Text item=kitchen2_humidity label="Humidity [%.1f %%]"
Chart  item=kitchen2_humidity period=24h refresh=10000 service="jdbc"
Text   item=kitchen2_pressure label="Pressure [%.1f hPa]"
}
Frame label="Main Pi" {
Text item=pi_cputemp label="CPU Temp"
Text item=pi_uptime label="Uptime"
Text item=pi_load label="Load average"
}
}

So I prepared configs, Logs looks well, no errors. But BasicUI shows nothing. I open PaperUI-> Configuration->Things->Main Pi (Thing) and I see there config-defined channels not linked to Items. I expected them to be already linked in .items config in {}. Well, I tap “linked Items +” href on each channel, and link Items manually (PaperUI show config-defined Items - its OK). Linked everything manually this way, blue circle changes (white dot inside) - connected ok. But BasicUI shows nothing.

I tried to get items value via REST API. API sends NULL in Item value. eg:
http://rpi162:8080/rest/items/kitchen2_temperature

Response Body
{
  "link": "http://rpi162:8080/rest/items/kitchen2_temperature",
  "state": "NULL",
  "stateDescription": {
    "pattern": "%.1f °C",
    "readOnly": false,
    "options": []
  },
  "editable": false,
  "type": "Number",
  "name": "kitchen2_temperature",
  "label": "Temperature",
  "category": "temperature",
  "tags": [],
  "groupNames": []
}
Response Code
200

(The same NULL for any Item in .items)

Mosquitto works well. I have checked:
└─[$] git:(master*) mosquitto_sub -v -t “/home/kitchen/#”
/home/kitchen/led_info 0
/home/kitchen/led 0
/home/kitchen/ip_address 192.168.0.103
/home/kitchen/msg mDNS responder started
/home/kitchen/firmware_version 2020-01-12/v0.2.2.4
/home/kitchen/temp 23
/home/kitchen/pres 1009
/home/kitchen/hum 41

What am I doing wrong, where is the error?
At least what is the normal way of debugging such cases in OH?
(Raspberry Pi, Openhab 2.5 upgraded from 2.4 installed via APT.)
Thanks for your help

Why?

There you go…
It was working before. Why break it?

You can’t make syntax errors in things files in the PaperUI
Very easy to make errors in things files and the errors don’t show in log.

As a very experienced user, ALL my thing (Except one) are defined in the PaperUI
All the bindings and add-ons and general config in done in the paperUI

Only items, rules, sitemaps, tranformations… are in the text files

2 Likes

Look very carefully at the channel UID ( something like mqtt:topic:pibroker:kitchen_controller2:msg_channel )
and see that it matches exactly your Item channel= definition

Don’t use PaperUI to link file defined Items, you create a conflict with what the file says.
Never ever expect changes made in PaperUI to be reflected back into your files.

1 Like

Well, I don’t like the way PaperUI functions, in general.
It stores “something” “somewhere” and I can’t normally edit and organize it.
eg:

  1. All Items in PaperUI in flat list - lots of items, no groups, no trees, full chaos.
  2. Can’t fully edit an Item. If I misnamed it upon creation, its name cannot be changed in PaperUI. Only its label and category is editable. I must delete it and re-create.
  3. Some Items, created by me during configuration in PaperUI, is undeletable for unknown for me reason. Just dont have trashbin icon. Some items does not delete with strange (for me) popup numeric error code.
  4. The same issue as (2) for Things. Cant rename anything.
    That is enough for me to prefer manual configuration

I prefer to have more control. Better break everything at the beginning, learn things right and make them right way, than redo everything when all is done in bad way

I was sure logs are made for debugging. Aren’t they? It goes that I cant rely on logs - they wont show me trouble places? I thought, I just don’t know how to normally use logs yet

Its for sure. It matches exactly.
Anyway it could not be mistake in every line for two things/10 items.

I was hoping the text configuration would work, but it didnt. So then I opened the PaperUI and discovered that Things, described in my text configs, exists there. Channels exists too. But Channels had no links to Items (Items themselves existed too). Thats why I linked them manually in PaperUI. I hoped it would help. But it didn’t.

Remember it works for other people.

That’s good.

That’s bad. Now you introduced conflict between what your Items file defined and what PaperUI defined.
I suggest to reboot now, and inspect what PaperUI thinks is linked (if anything) afterwards.
I’m not sure what else may need to be done to clear up.

There’s nothing wrong with using files - but you must be precise, and it is unforgiving.
There’s nothing wrong with using PaperUI.
There is everything wrong with using both for the same purpose. (linking, here)

JSON

/var/lib/openhab2/jsondb

Which is why the official recommendation in the docs is to use .items files for Items. But not for Things.

You could edit it in the JSONDB but ultimately, the Item name is it’s UUID which cannot be changed. But again, this is why the official recommendation is to manage Items in .items files.

You can rename Things, even in PaperUI. You cannot change the Things UID. But the UID for a Thing and Channel is proscribed. It’s not like you have a lot of options there in the first place.

If you want to use just .items files, stop openHAB, go to /var/lib/openhab2/jsondb and delete org.eclipse.smarthome.core.thing.ItemChannelLink.json and org.eclipse.smarthome.core.items.Item.json and if it exists org.eclipse.smarthome.core.items.Metadata.json.

This will delete everything Item related that was created through PaperUI, the Karaf Console, or PaperUI.

If you decide to use .items files, use it for everything. Don’t mix and match between PaperUI and .items files. The .items files will always take precedence except if you delete/rename an Item but don’t remove the link from the JSONDB, OH will think this Item still exists.

And if it helps you have a sense of control, everything done in PaperUI, the Karaf Console, and the REST API get’s saved to these files. If you really need the ability to change the UIDs of Things after they are created, you can do so by editing these files.

I see post after post after post with those who “want to have control” struggling with Thing syntax. I should start keeping a tally of all the time spent.

Thank you very much! :+1: Your whole reply was very useful for me!

I am sorry if my question looks or feels like as if I criticize the system (OH), while not understanding it. Absolutely not. On the contrary, I feel that OH is what I need and can be configured very well, but I just don’t understand how to do it right. In no case did not want to offend anyone.

At this point I finally understand what’s going on in my configuration, it is not a black box anymore.

And life were brilliant now, if this clear and simple configuration would run.
But it still does not :sweat:.

Stopped OH, made text config files and double (no, triple) checked its content, removed all from jsondb, including backups, dropped all persistence tables from database, started OH. Started normally. Logs without errors. Look into PaperUI - everything is created and linked as expected. All channels active. Everything looks good, except that it does not work.

All Items are NULL. Pressing “led button” off and on brings logs to life with this:

==> /var/log/openhab2/events.log <==
2020-01-15 00:26:44.164 [ome.event.ItemCommandEvent] - Item 'kitchen2_led' received command OFF
2020-01-15 00:26:44.198 [nt.ItemStatePredictedEvent] - kitchen2_led predicted to become OFF
2020-01-15 00:26:44.233 [vent.ItemStateChangedEvent] - kitchen2_led changed from ON to OFF
2020-01-15 00:26:51.191 [ome.event.ItemCommandEvent] - Item 'kitchen2_led' received command ON
2020-01-15 00:26:51.212 [nt.ItemStatePredictedEvent] - kitchen2_led predicted to become ON
2020-01-15 00:26:51.341 [vent.ItemStateChangedEvent] - kitchen2_led changed from OFF to ON

But mqtt topic remains unchanged.
It feels to me as if configured Bridge (Bridge mqtt:broker:pibroker [ host=“192.168.0.99”, secure=false, username=“pi”, password=“mySuperSecurePasswordEver”]) for some reason does not interact with Mosquitto (mosquitto itself is running and working nice)

That is what Items initialize to. That’s not unexpected or unsual.

Pressing it where? In the OH UI or on the device?

What does the Broker Thing say it’s state is in PaperUI?

When OH starts, Mosquitto will show the connection in it’s log IIRC. Do you see anything in it’s log when OH connects?

You have a username and password, you created these on Mosquitto? These are not your Linux username and password. You have to create them using Mosquitto tools in a special way. Look to a Mosquitto tutorial for details. It uses mosquitto_passwd to generate a passwd file.

1 Like

You should also look in your openhab.log file.
In particular, I’d look for your xxx.things file loading message.
And your xxx.items file loading message.

And the MQTT broker connection message.

It’s unexpected to me, because Items are linked through its channels to MQTT Things, and corresponding topics are are either retained or updated once per second, so I expect data there, not NULLs.

In BasicUI

Status: online

Stopped OH. Started tails -f for mosquitto and OH logs, started OH. When OH initializes mqtt:

==> /var/log/openhab2/events.log <==
2020-01-15 14:06:35.434 [hingStatusInfoChangedEvent] - 'mqtt:broker:pibroker' changed from UNINITIALIZED to INITIALIZING
2020-01-15 14:06:35.924 [hingStatusInfoChangedEvent] - 'mqtt:broker:pibroker' changed from INITIALIZING to OFFLINE

==> /var/log/openhab2/openhab.log <==
2020-01-15 14:06:39.931 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.0.99' with clientid 089e3ad0-aa9b-463a-8997-0fb097963dbd

==> /var/log/openhab2/events.log <==
2020-01-15 14:06:41.745 [hingStatusInfoChangedEvent] - 'mqtt:broker:pibroker' changed from OFFLINE to ONLINE
2020-01-15 14:06:41.807 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:pibroker' has been updated.

Mosquitto log says (/var/log/mosquitto/mosquitto.log):

1579086400: New connection from 192.168.0.99 on port 1883.
1579086400: New client connected from 192.168.0.99 as 089e3ad0-aa9b-463a-8997-0fb097963dbd (p2, c1, k60, u'pi'). 

Yes, sure.

Uhhm logs looks nice :slight_smile:
No errors. No warnings, and PaperUI shows all Things in online status.

Sorry for late reply, understood, thank you!

OK, both OH and Mosquitto are showing evidence that there is a valid connection. So your Broker Thing is probably OK. Since I don’t use and don’t encourage the use of .things files I’m not going to be much more help. From all appearances there is something wrong with your .things files.