New Clean Install of OH3 what text files can be moved over?

My Linux version was too old to do a in place upgrade so I purchased a new SD card and installed the latest version of openHABian seen here.

I’ve been attempting to follow the getting started documentation and install all my things and items from scratch.
But after today I’m starting to think OH3 can use many of the textual config files I’ve spent years working on. Is there a list of config files from OH3 that can be moved straight over to OH3? I’ve seen the list of changes and things it could break but that lead me down a path that I now discovered isn’t true.

If there’s an equivalent folder in OH3 (e.g. items, rules, etc.), then you can move your OH2 config files into it. As you noted, beware of the breaking changes (particularly for rules).

1 Like

The main breaking changes from a text file perspective have to do with time and date. The underlying libraries changed. The other change is that expire is now a core feature but the text file syntax should function.

3 Likes

That’s great to hear @rpwong
I think that just leaves me with 1 more question.

Should I move the files before I configure Things and set up the Model?

The Model is a mixture of Item Groups and tags. I believe it needs to be configured in the text files.

I actually haven’t used the model. I might try it when I have more time, but I mostly interact with OH through voice, so I don’t have a lot of need for graphical UIs. As a result, my old sitemap is good enough.

The Semantic Model was design to give context semantics for voice control, initially with HABot.

I did my migration entirely with text files and it worked fine.
You’ll need to reconfigure anything that was using a v1 binding (assuming there’s an OH3 version).

If you’ve configured your bindings, transformations, UIs etc in /services/addons.conf then it’s even easier.

So far the biggest problem seems to be getting OpenHAB Cloud working on my phone again.
I made sure to move the UID and secret from my OH2.

2021-04-01 22:56:18.232 [WARN ] [io.openhabcloud.internal.CloudClient] - Unsupported request method HEAD
2021-04-01 22:56:36.747 [WARN ] [io.openhabcloud.internal.CloudClient] - Unsupported request method HEAD
2021-04-01 22:57:36.747 [WARN ] [io.openhabcloud.internal.CloudClient] - Unsupported request method HEAD
2021-04-01 23:08:53.129 [WARN ] [ore.io.rest.auth.internal.AuthFilter] - Unauthorized API request: Invalid Basic authentication credentials
2021-04-01 23:09:09.036 [WARN ] [ore.io.rest.auth.internal.AuthFilter] - Unauthorized API request: Invalid Basic authentication credentials
2021-04-01 23:09:39.181 [WARN ] [ore.io.rest.auth.internal.AuthFilter] - Unauthorized API request: Invalid Basic authentication credentials
2021-04-01 23:10:09.448 [WARN ] [ore.io.rest.auth.internal.AuthFilter] - Unauthorized API request: Invalid Basic authentication credentials

When I login to myopenhab.org it does show like it’s Online

I’ve not tried reusing the old UID and secret. When I’ve reinstalled, I’ve copied the new UID and secret to OpenHAB cloud but in that case it does take a while to become active.

Well I spoke too soon.

Many of my items were using http commands but they don’t work. I have the HTTP add on installed but I can’t figure out how to pass the command like this in OH3.
Here is my item from OH2

Switch  ESP_2856D8   "Basement Floor Lamp [%s]"    <poweroutlet_us> (SmartLights,BasementLights,Basement)  {http=">[ON:POST:http://192.168.2.61/control?cmd=GPIO,12,1:on] >[OFF:POST:http://192.168.2.61/control?cmd=GPIO,12,0:off]", alexa="Switchable"}

Within the 2.5.x the http binding did change.

There was never an official release of a HTTP binding for OH2, just test candidates linked from a forum thread, which then turned into the OH3 binding.

@rmhoutz you were using the OH1 binding in OH2, as your syntax shows. You will need to convert all you HTTP Items to use the Thing-Channel-Item model that the OH3 binding supports, as the OH1 binding no longer works.

The HTTP Binding documentation page unfortunately does not provide any text configuration examples, but there are a few threads in the forum with examples. I would suggest using the UI first to get used to all the options, then transferring to text files afterwards.

Hi @hafniumzinc
Thanks for all the info. I never thought I’d say this because I’m a PC tech but I’m starting to miss text configuration files. If I’m not mistaken the OH1 HTTP Item as shown in my example now needs the following in OH3
1 Item
2 Things
3 Channels

Here is the Item

I need 2 Things configured one for the http relay command and one to receive the MQTT relay state.
My device running ESPEasy sends it’s state via MQTT.

And my HTTP Thing needs 2 Channels because they the UI only allows for 1 URL Extension.
In this image I attempted to use 1 channel leaving the 1 off the command URL extension hoping the On and Off value would fill in but it didn’t work that way.

And lastly I need to create a channel for my MQTT status message.

Please correct me if I’m wrong but all that is needed to replace this one line in my Items file?

Switch  ESP_EAB977 "Basement LED Strip [%s]" <poweroutlet_us> (SmartLights,BasementLights,Basement) {http=">[ON:POST:http://192.168.2.60/control?cmd=GPIO,12,1:on] >[OFF:POST:http://192.168.2.60/control?cmd=GPIO,12,0:off]", alexa="Switchable"}

So this single Item also took care of the MQTT stuff?! I’m not sure it does, so no, you don’t need everything you’ve described to replace your old Item.

You can definitely do it with a single Channel. Check the very end of the HTTP Binding documentation on how to forward commands in the URL.

No I did have to create a MQTT thing in OH2 to receive the MQTT State message.

I think I’m getting closer to figuring out the HTTP thing in OH3 but I have another question.
When I put this URL in a Web Browser
http://192.168.2.60/control?cmd=GPIO,12,1
the device will turn on and return this info.
image
Is that a json response?

When setting up a new thing in OH3 If advanced is selected I have the option to select Command Method and Content Type. Should I select application/json or text/html or text/plain? I’m assuming Post is the correct command method because it was in my old HTTP command.

Thanks again for all your help in info.
I do apologize I realize many of these questions are a no brainer to a programmer but I have no programming background.

Neither do I - blind leading the blind!

Based on this it sounds like you can use a more simple GET rather than a POST? If so, I’ve tried to guess at what might work for you - see if the following traditional configurations work:

Things file:

Thing http:url:BasementLEDs "Basement LEDs" [
	baseURL = "http://192.168.2.60/control?",
	refresh = "30",
	timeout ="3000",
	ignoreSSLErrors = "true"
]
{
	Channels:
		Type switch : switch "Basement LEDs Switch" [
			commandExtension = "cmd=GPIO,12,%2$s",
			stateTransformation = "JSONPATH:$.state",
			onValue = "1",
			offValue = "0",
			mode = "READWRITE"
		]
}

Items file

Switch sBasementLED "Basement LED switch" { channel="http:url:BasementLEDs:switch" }

This Thing, in theory, should be able to both command and capture the state (from the JSON response) after you have sent the command, though this might not be ideal depending on how quickly the device updates. Also, I have no idea how to prevent the binding from polling periodically, so if you have a URL that you can send to the device which only gets the device’s state (rather than sends a command), you could use that in the stateExtension parameter so that the polling is actually useful.

Question: if you have MQTT already setup for this ESP device, why not use MQTT to command it too?

I could probably write a book on how my system ended up being configured the way it is. :slight_smile: But the short answer is everything responds much faster to commands when I use HTTP commands and MQTT for status updates.
I have configured the devices to use MQTT commands in the past and tested it more recently but the delay was such that I would hit the button again thinking something went wrong.

I’ll have to get back to you on trying the thing and item configured like that but I’ll keep you posted.

Well it works a little. The lights do turn on and off when I click the switch in the UI sometimes.
And I see the on off command in the log but I’m getting lots of warning in the log too and the items don’t always update.

2021-04-04 21:09:51.319 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in 'Unknown or restricted command!'
2021-04-04 21:09:59.911 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Splitting header '' failed. No '=' was found. Ignoring
2021-04-04 21:10:00.020 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in '
Failed'
2021-04-04 21:10:21.233 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in 'Unknown or restricted command!'
2021-04-04 21:10:29.916 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Splitting header '' failed. No '=' was found. Ignoring
2021-04-04 21:10:30.023 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in '
Failed'
2021-04-04 21:10:51.326 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in 'Unknown or restricted command!'
2021-04-04 21:10:59.920 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Splitting header '' failed. No '=' was found. Ignoring
2021-04-04 21:10:59.950 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.state', serviceName='JSONPATH'} failed: Invalid path '$.state' in '