(cannot)clean the mess in items

Hi me again (sorry…)

I don’t know how it did happen. But I have a situation here with a thing and its Items in openhab2 : Could you please help me delete it and ALL items linked, so I can re-create it cleanly ? (and not, AGAIN delete the whole “userdata” folder … :sleepy: )

explanation :

In paperUI, I CANNOT unlink one channel, it causes a 404 error (but nothing in the logs) :

In Habmin2, this is all upside down : habmin2 thinks there a linked items, but does not show them. If I create a new item, then suddenly I get a line with the “ghost” item, but I cannot delete it … again, nothing in the logs :

And finally, if I go to Items, I have an item here that I cannot delete too (I think that it is the one I created in a previous test to reveal the ghost item, then I deleted the whole thing and re-added it …) : if I try to delete it from here, I get this line in logs :

2016-06-04 17:49:20.783 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP DELETE request at ‘items/zwave_device_FGSD002_node3_RDC_alarm_smoke’ for the unknown item ‘zwave_device_FGSD002_node3_RDC_alarm_smoke’.

I have tried to remove the thing, from paperui or habmin2, but when I re-add it, the problems remain

you might want to try

smarthome:links clear

on the console - this will remove all links in the database.

1 Like

thannnnks (it did delete all “mapdb” (i suppose) items and links, including the ghost ones) ! You’re becoming my hero …

are those commands documented somewhere ? Do you have an Idea of what could have happened ? it’s seems to me that the data (items / things / links) removal via UIs is not “clean”

EDIT : I found myself AGAIN having a mess, this time with duplicate entries when browsing my sitemap (items appearing 2 times).

To recover, I did a “smarthome:items clear” (I am moving my items to text files, more robust, but it appears that openhab tend to duplicate items somehow in the cache, maybe when changing groups names)

Very good question! WIthin the IDE, it is still possible to simply type “smarthome” in the console to get a list of all commands:

osgi> smarthome
---SmartHome commands---
	smarthome firmware list <thingTypeUID> - lists the available firmwares for a thing type
	smarthome firmware status <thingUID> - lists the firmware status for a thing
	smarthome firmware update <thingUID> <firmware version> - updates the firmware for a thing
	smarthome interpret <command> - interprets the human language command
	smarthome update <item> <state> - sends a status update for an item
	smarthome send <item> <command> - sends a command for an item
	smarthome inbox - lists all current inbox entries
	smarthome inbox listignored - lists all ignored inbox entries
	smarthome inbox approve <thingUID> <label> - creates a thing for an inbox entry
	smarthome inbox clear - clears all current inbox entries
	smarthome inbox ignore <thingUID> - ignores an inbox entry permanently
	smarthome things list - lists all things
	smarthome things clear - removes all managed things
	smarthome things remove <thingUID> - removes a thing
	smarthome items list [<pattern>] - lists names and types of all items (matching the pattern, if given)
	smarthome items clear - removes all items
	smarthome items remove <itemName> - removes the given item
	smarthome links list - lists all links
	smarthome links addChannelLink <itemName> <channelUID> - links an item with a channel
	smarthome links removeChannelLink <itemName> <thingUID> - unlinks an item with a channel
	smarthome links clear - removes all managed links
	smarthome status <item> - shows the current status of an item
	smarthome > <script to execute> - Executes a script
	smarthome discovery start <thingTypeUID|bindingID> - runs a discovery on a given thing type or binding
	smarthome discovery enableBackgroundDiscovery <PID> - enables background discovery for the discovery service with the given PID
	smarthome discovery disableBackgroundDiscovery <PID> - disables background discovery for the discovery service with the given PID
	smarthome say <text> - speaks a text

On Karaf, we can at least see the main commands through

openhab> help | grep smarthome
smarthome                         Enter the subshell
smarthome:>                       Execute scripts
smarthome:discovery               Control the discovery mechanism.
smarthome:firmware                Manage your things' firmwares.
smarthome:inbox                   Manage your inbox.
smarthome:interpret               Interpret a command by a human language interpreter.
smarthome:items                   Access the item registry.
smarthome:links                   Manage your links.
smarthome:say                     Speak text by a text-to-speech service (TTS).
smarthome:send                    Send a command to an item.
smarthome:status                  Get the current status of an item.
smarthome:things                  Access your thing registry.
smarthome:update                  Send a state update to an item.
openhab> 

@maggu2810 Is there any way to get the usage displayed for the individual commands?

it appears that openhab tend to duplicate items somehow in the cache, maybe when changing groups names)

I have also seen this when editing and saving item files. A restart usually solves this.

2 Likes

Using https://github.com/eclipse/smarthome/pull/1627 we can support stuff like help smarthome:firmware or smarthome:firmware --help.

This has been a really helpful thread. I am sure a lot of people moving from OH1 will benefit from reading this. Thanks all.

1 Like

A command like:
smarthome:items remove
does not seem to affect the database for my.openhab.
E.g. smarthome:status zwave_device_48766d53_node2
Error: Item ‘zwave_device_48766d53_node2’ does not exist.
but still shows in my.openhab

Is there another way to update this DB?

Anyone have any clues on how to clean up the my.openhab items database?

Login into your my.openhab account, go to “Account”, find button “Delete Items and Events” and they are gone.

Thanks for the reply. Before I do this what happens next? Does the Items list get updated from OH on the next login with a refreshed list of Items?

If you have set the persistence for my.openhab: yes.

What exactly does this do? I have problem with that items belong to the wrong group after updating the item with new group names, they still show up in the old group. So how can I fix this? Thats the only change I would like to do to my setup! I do not want to reconfigure things etc…

I’m getting errors in my log which says there are duplicate items.

This command removed all the links except the ones causing problems:

smarthome:links clear

This is the one that I cannot remove:

Playroom_window_State -> HM-Sec-SCo:c3b1c9f9:NEQ1650195:1#STATE

This is the correct one which does get removed with the links clear command.

Playroom_window_State -> homematic:HM-Sec-SCo:c3b1c9f9:NEQ1650195:1#STATE

I’ve got several like this.

This is the log warning:

[WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘CLOSED’ for item ‘Playroom_window_State’ to handler for channel ‘HM-Sec-SCo:c3b1c9f9:NEQ1650195:1#STATE’, because no thing with the UID ‘HM-Sec-SCo:c3b1c9f9:NEQ1650195’ could be found.

Is there another way to clear out these weird duplicates?

Thanks.

You haven’t got some .items etc. files lurking somewhere have you. If the clear command doesn’t work and your sure there are no manual definitions you do at least have the option now of editing the jsondb to tidy things up… at your own peril of course.

I check for any ‘other’ item files. There do not appear to be any. This was a clean install a week ago but I did add the item files from my previous system.

Is there a good thread on editing the jsondb?

And no .things ??

I’m not aware of any threads re editing jsondb, its relatively intuitive based on the file names and the structures….

The MOST important thing to note though is the files are only read once at start up… they must not be edited dynamically whilst OH2 is running…

The number of things is correct and the ‘names’ are correct.

I’ve also got these warnings in my log which may be connected as the map transformation service works fine with other items:

[.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type Map
2017-04-09 10:24:46.060 [WARN ] [.core.transform.TransformationHelper] - couldn’t transform value because transformationService of type ‘Map’ is unavailable
2017-04-09 10:24:48.933 [WARN ]

I don’t get any other errors or warnings apart from the duplicate items mentioned above.

Has anyone else seen this?

I’ve fixed this. I had some Homematic items with a mix of openHab 1 and 2 item definitions within the same item!

I’ve looked at ThomDietrich’'s fantastically well organised Homematic item file and tidied up mine accordingly.

I had similar issues and first reverted to the Karaf console to remove the items using

smarthome:items remove

Still, items popped up in habmin and in paper UI. When deleting in paper UI, I had error 404 in bottom right of the screen. When deleting from habmin, nothing happened. In both cases, I had an entry in the log:

Received HTTP DELETE request at 'items/xyz' for the unknown item 'xyz'.

Which is similar to what was reported earlier in this thread.

I finally ended up editing the jsondb. There I noticed that, indeed, the items were not there any more, but the ChannelLinks still existed. After deleting the channel links, the items were no longer visible in the UIs.

Before openhab service restart, I also deleted the tmp and cache directories, just to be sure.

I cannot tell which of my attempts caused the inconsistency in the database (itemchannellink entries still exist for nonexistent items): one of the GUIs or the removal via the Karaf console.

But now I have a clean system again.