My new openHAB project at home as a total newbie during COVID-19

Good afternoon guys,

Located in Spain, we have been at home for a long time now due to quarantine. Positive point of view is I had some time to google and ivestigate and ended up on the OpenHAB project.
I have to say I always loved apps that are connected to things, but always as a regular user and of course with the inconvinients of having to use differents apps.

After reading and watching all the videos I found I decided to start my small project knowing already was gonna be hard as hell.

I decided to go for the easy way, Windows version on a NUC. I did try some Ubuntu on a virtual machine on a old rack server I have at home but I gave up after 2 days, I have to say I learned a lot in order to make it happen on the Windows version.

Current Status:

  • OpenHAB installed and running properly

  • Visual Studio Code as an editor

  • Bindings installed and running thru the Paper UI

     Fronius Binding: I have a 9.2 Solar Panel Instalation (best thing i every did)
     MELCloud Binding: 3 Mitsubishi AC machines
     TP-Link Smart Home Binding: 10 Tplink HS100 Smart Switch 
     VolvoOnCall Binding: 1 car

All the information that I selected on the Paper UI Control Section is visible.
Manage to create a .items, .sitemap and paste them thru the Visual Studio Editor and a DASHBOARD example thru the “confi page” of the HABpanel

That was a real happy moment for me.

Now is when I start the brainstorming and see how limited is my knowledge and how insane is the power of openHAB (will work on it)

My idea is to be able to “code” a rule where I can say to my Fornius Solar Inversor to turn ON/OFF AC machines depending of the AC Power generated and obviosuly giving the AC machines some kind or priority.

As a future idea I would love to add a electric water boiler and the pumps from the pool even the garden water irrigation and a bunch of SONOFF (did i say I love to manage a tone of different apps? :rofl: :rofl: :rofl:)

HABpanel will be another challege thats for sure, but not the right time for the moment.

But know Im completly stuck, a member from the forum @shorty707 helped me very quickly apporting a item he has but even with that… Is too hard.

So here I am! asking any member to show me he light or the door/thread/ to open in order to be able to do it and hopefully keep writting this thread


Hi @Andreu_Ferret, so if I understand right, what you want to do is turn on/off some AC spliters depending on the state of the solar inverter?

That’s not too complicated. I can share here a rule I’ve set in order to turn off the heating radiator on my living room depending on the state of the lights (if the light is off it means I’m already sleeping, so the heating should be turned off)

rule "Apagar el brasero por la noche"
    Time cron "0 0 2-6 ? * * *"
  if (LR_Radiator.state == ON && LR_GinLights == OFF && LR_CeilingLight == OFF) {

As you can see there, the rule is cron based, so it will only be launched several hours during the night. Besides that, it has a conditional on the lights and on the state of the heating, and send a command accordingly.

So imho if you want to turn on/off the AC depending on the inverter, you can use the inverter state as a WHEN in the rule, to detect a change on the state, and then use conditionals to decide if you want to turn on or off the AC.

Anyways, this is just one way to do it, but there are many other ways. Also that’s how I would do it, and I’m not definitely an expert on this, I’ve been running openhab only for a couple of years with just 7 or 8 devices as some kind of “sandbox” in order to learn before deploy a “production” environment in my new house, so don’t take my advice as an absolute truth :sweat_smile:

1 Like

Good morning @simeonruiz

Thanks for your reply, I can see we share country! (Gracias por la respuesta)

Is it any way to do this rule thru the Rule Engine (Experimental) Graphic is always less scary :rofl: :rofl:

Thanks to all the community in advance

To be honest, I never used the GUI for that stuff. I prefer to do it everything via config files, since for me is easier to backup in this way.

That said, an easy way to do it graphically is using NodeRED instead of the rule engine, but although it can be done and there is a pluging for that, note that it is not the “official” way to do it.

Can OH communicate with these devices?

Here is a rule example, that checks power average and control a switch, that may help get you started.

rule "TurnOffCatGeniePower"

	Time cron "0 54 13 ? * *" or 
	Item CatGeniePower changed 
//    Add persistence to CatGeniePower item 
    if(CatGeniePower.averageSince(now.minusMinutes(3)) > 1){     // adjust time and watts as needed
        CatGenieTimer.sendCommand(ON)    	// turn on timer with expire binding for 20 min
//		Thread::sleep(1000)                 // add if needed to allow switch state to update
    else if(CatGenieTimer.state == OFF){
        CatGenieSwitch.sendCommand(OFF)   		// turn power off if no cleaning cycle

rule "TurnOnCatGeniePower"
	Time cron "0 0 9 ? * *"    				// power on at 9am every day

Thank you very much for your answer @H102
I can confirm than OH can communicate with all the items and I can controll them already from the Paper UI Control.

Fronius Binding and MELCloud are working perfectly, big thanks to the developers!!
After 24 hours of brainstorming I ended up with this simple conclusions: (feel free to have fun with my own just created way of coding :rofl: :rofl:)

Fronius + Mitsubishi Kitchen + Mitsubishi Masterbedroom + Mitsubishi Office + soon Pool

Rule should start everyday from 09:00H and end at 18:00H (lets forget about winter or summer for now)

IF Fronius AC Powery solar production is > 1500 W (Fronius Channel ID for that value is “inverterdatachannelpac” - Number)
Mitsubishi Kitchen should be ON (Switch power { channel=“melcloud:acdevice:c8d95999:182085:power” } )
IF AC Powery solar production is < 1500 W
Mitsubishi Kitchen should be OFF

IF Fronius AC Powery solar production is > 2500 W (Fronius Channel ID for that value is “inverterdatachannelpac” - Number)
Mitsubishi Masterbedroom should be ON (Switch power { channel=“melcloud:acdevice:c8d95999:180520:power” } )
IF AC Powery solar production is < 2500 W
Mitsubishi Masterbedroom should be OFF

IF Fronius AC Powery solar production is > 3500 W (Fronius Channel ID for that value is “inverterdatachannelpac” - Number)
Mitsubishi Office should be ON (Switch power { channel=“melcloud:acdevice:c8d95999:99049:power” } )
IF AC Powery solar production is < 3500 W
Mitsubishi Masterbedroom should be OFF

After 18:00H commands will be manual.

Step by step I see the light of the tunnel, Ill be more than happy if i manage to get there :slight_smile:

For starting and stopping rules at a certain time with cron see this link.

In the rule you only need the item name, not the channel. Use the forum search and look over some rule examples. Try creating the rule and if you get stuck post what you have and we can help.

Also, please use code fences when posting itmes, rule, etc… it’s the paper icon to the left of gear icon. :wink:

Thanks for the help @H102 Ill def do it in the future.

All the best!

Does this make any sense for you guys?

rule "TurnOffACKitchen"
    Time cron "0 0/1 8-19 ? * * *" or 
	Item AC_Powery changed
	if (AC_Powery.state>1500 && GF_Kitchen_AirCon.state == OFF )        { 		// AC Powery is > 1500 watts but AC Kitchen is OFF

					GF_Kitchen_AirCon.sendCommand(ON) 	// turn ON AC kitchen

	else if (AC_Powery.state<1500 && GF_Kitchen_AirCon.state == ON  )   { 		// AC Powery is < 1500 watts turn OFF AC Kitchen if its ON
					GF_Kitchen_AirCon.sendCommand(OFF)  // turn OFF AC kitchen


rule "TurnOnACKitchen"
	Time cron "0 0 8 ? * *"    				// power on AC Kitchen at 8am everyday

Looks good to me, does it work as expected?

This is what Im getting:

18:59:37.958 [WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'Aircoindition.rules' is either empty or cannot be parsed correctly!
18:59:39.888 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'Aircoindition.rules'
18:59:49.307 [INFO ] [smarthome.event.ItemStateChangedEvent] - fronius_powerinverter_79f1f9e4_inverterdatachannelpac changed from 673.0 to 668.0
18:59:49.427 [INFO ] [smarthome.event.ItemStateChangedEvent] - AC_Powery changed from 673.0 to 668.0
19:07:34.629 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'TurnOffACKitchen': The name 'AC_Powery' cannot be resolved to an item or type; line 7, column 6, leng

I understand the problem is with “AC_Powery”

Used that because i saw it on the Fronius Binding
I have to say I dont have any file with the fronius items configurated on a *.items file as I see the information on the Paper UI control.

Well I think I finally manage to make it.

rule "ACBredroom"
    Time cron "0 0/1 8-19 ? * * *" or 
	Item fronius_powerinverter_****_inverterdatachannelpac changed
	if (fronius_powerinverter_****_inverterdatachannelpac.state>3500 && melcloud_acdevice_****_****_power.state == OFF )        { 		// AC Powery is > 1500 watts but AC Kitchen is OFF

					melcloud_acdevice_****_****_power.sendCommand(ON) 	// turn ON AC Bedroom

	else if (fronius_powerinverter_****_inverterdatachannelpac.state<3000 && melcloud_acdevice_****_****_power.state == ON  )   { 		// AC Powery is < 1500 watts turn OFF AC Kitchen if its ON
					melcloud_acdevice_****_****_power.sendCommand(OFF)  // turn OFF AC Bedroom


The problem was with the items name and some problems on the writing, what i did was to start checking on the log the proper item names after sending the orders manually.

So now I have some questions:

  • If all the setup is done thru the graphic enviroment, Paper UI, and bidings too. Where do you check the items names created by default? My items folder are empty, only way to make it was thru the logs.

Such a shame is raining here today if the sun pops ups ill try it with the 3 AC machines at the same time

Thank you so much for the help @H102 this just opend a new world!!!

Most will setup the Thing using PaperUI and use files for items. Placing the item in files will give you more flexibility with names, tags, etc… The location for items file is /etc/openhab2/itmes To get the correct channel for each item just copy it from PaperUI Things channel. No need to link the item via PaperUI b/c that will be done automatically when you place the item in a file and save it.

Item example:

Switch CouchLight "Couch Light" <light>  ["Lighting"]  { channel="mqtt:topic:pibroker:sonoff2:power" }

Using this item in a rule I can simply use the name CouchLight. :wink:

Hope this helps.

Just to be clear, everything that is done in PaperUI get’s saved to a text file in /var/lib/openhab2/jsondb. All of the files in the directory get automatically backed up on every change to /var/lib/openhab2/jsondb/backups. openhab-cli backup includes that directory among many others in that userdata folder when it takes a backup. It’s a text file so it is very compatible with using with source control like git.

I know you didn’t necessarily mean to, but I feel compelled to respond when there is even a hint that PaperUI configs cannot be backed up, migrated to an new OH instance, or use with configuration control.

I’ll also add that if all you are including in your backups is /etc/openhab2 (i.e. conf) you are missing a whole lot of important stuff from the userdata folder.

I think cron triggers are broken in PaperUI so probably not.

1 Like

Thank you for the information @rlkoshak,
Where is the text file located in the Windows version?
I manage to create some mess in order to find out most of the things, but the log is more than amazing.

For some reason I can not loggin with visualstudio from localhost, but I can thru a VPN that I have between my office and my house. (there is always a way) almost always has the answers to such questions. In this case it’s userdata/jsondb. You will not be editing the JSONDB by hand so VSCode isn’t really relevant unless you just want to use it to look at the files.

If you write .rules files, see the same link above for where the conf folder is located.

Thank again @rlkoshak :wink:

Good morning all!

After messing a little bit I managed finally to connect properly the VSC to the OpenHAB server, for some reason I dont undertand I was only able to connect it remotely.
Im facing a small issue, this it the code I did:

rule "kitchen"
    Time cron "0 0/1 9-19 ? * * *" or 
	Item fronius_powerinverter_****_inverterdatachannelpac changed
	if (fronius_powerinverter_****_inverterdatachannelpac.state>1500 && GF_Kitchen_AirCon.state == OFF )        { 		// AC Powery is > 1500 watts but AC Kitchen is OFF

					GF_Kitchen_AirCon.sendCommand(ON) 	// turn ON AC kitchen

	else if (fronius_powerinverter_****_inverterdatachannelpac.state<500 && GF_Kitchen_AirCon.state == ON  )   { 		// AC Powery is < 1500 watts turn OFF AC Kitchen if its ON
					GF_Kitchen_AirCon.sendCommand(OFF)  // turn OFF AC kitchen


VSC is giving me this message as a a problem:

The type ACkitchenRules is already defined in ACkitchen.rules.

Im pretty sure is easy thing but i can not fix it.

What’s with the _****_? * is not a valid to use in an Item’s name. * is not a wild card in this context.

The error means you have ACkitchenRules defined twice. I don’t see ACkitchenRules in the code snippet above at all so I can’t tell you what the problem is.

Sorry @rlkoshak it was just a secure mesure, on the rule the input is correct.

I manage to find the problem. There was a mess on the sitemap I created.

Currently 3 diferent AC machines are working with 3 different rules. Im soooo dam happy, expecting a huge sonOff tasmota delivery this week, I have a plenty of crazy ideas.

Thank for the help to all the community