Position estimator for shutters

Hi @konehead ,
In my case my shutters are controlled via tasmota. In that way I used the “backlog” functionality to close the relay, wait some time and open the relay again. The time I have to delay I calculated in advance according to the actual position to the target position.
→ the observer and the controller are decoupled. So like @rossko57 wrote above you must ensure to set autoupdate=false

1 Like

I had a similar problem where Somfy roller shutters remotes have been replaced by openhab. I used a RFXCom to send the actual commands to the shutters and the position was estimated using some JSR233 automation rules, allowing absolute positon control.

Only one additional item is needed for each shutter, everything is managed by a JS class instantiated for each shutter…

You can find the JS code and the associated items definition in the following VASRollershutter.js gist. This is performed on an openhab 2.5 instance but I guess only minor adaptations should be needed for OH3.

1 Like

@ Rossko57 Both thanks for steering me into this direction.

Wow, this looks like a full sollution for my position issue! Will try to implement it next week into my configuration. My end goal is/was to connect it with Homekit. So use the WindowCovering option, and allign the WindowCovering postion in Homekit with the actual postion of the roller shutters. I’ll keep you posted!

Merci!

I updated the gist to work with OH3.

To use it, one must first follow precisely the instructions inIvan’s Helper Libraries - OH3, Python, JavaScript to install the JS helper libraries, particularly to use the files according the the right pull request (by downloading this link for example https://github.com/CrazyIvan359/openhab-helper-libraries/archive/5a452ef2367176654fa408c18917947c1502697b.zip )

The VASRollerShutter.js file should be installed in automation/jsr223/javascript/personal and the js-timeout-polyfill.js in automation/lib/javascript/personal.

Then in openhab.log you should see (a restart might be needed):

2021-04-30 07:48:55.457 [INFO ] [ab.core.service.AbstractWatchService] - Loading script '/etc/openhab/automation/jsr223/javascript/personal/VASRollerShutter.js'                                                                                            │
2021-04-30 07:48:55.589 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'js' with identifier: file:/etc/openhab/automation/jsr223/javascript/personal/VASRollerShutter.js                                                  │
2021-04-30 07:48:55.997 [INFO ] [javascript.NOCONFIG.vasrollershutter] - VASRollershutter (re)loaded!                                                                                                                                                       │
2021-04-30 07:48:56.426 [DEBUG] [sr223.javascript.NOCONFIG.core.rules] - Added rule [VASRollerShutter] 

In order to test you can add the items as defined, without the rfxcom channel, and create roller shutter cells in webui for the ...VAL items. If you use the commands, you should see in the `events.log` the positions updated and the actual commands sent back to the ...CMD items.

@tarag
Today, finaly I found time to install your solution. Unfortantly I do get an error from VAL which I don’t understand. Please can you help me?

I get back:
2021-05-07 20:23:50.517 [ERROR] [javascript.NOCONFIG.VASRollerShutter] - Error during the evaluation of ‘rule: VASRollerShutter’ at line 212 at column -1 in JavaScript traceback (most recent call first):TypeError: Cannot read property “processCommand” from undefinedat VASRollershutterExecute (:212)2021-05-07 20:23:50.519 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule ‘8d78c9a2-e34e-40fb-91f4-2a33fda718a2’: Fail to execute action: 12021-05-07 20:23:50.520 [DEBUG] [e.automation.internal.RuleEngineImpl] - java.lang.RuntimeException: Fail to execute action: 1
What I did:
A) I changed your script (VASRollershutter.js), deleted 3 of the 4 shutters. Since I have one shutter
Added the timing: new VASRollershutter(“F0_Zonnescherm_achtertuin_RS_VAL”, 56000, 53500);
B) Didn’t change: js-timeout-polyfill.js
C) I uploaded the scripts to the locations according your instruction
D) I created an virtual item: Rollershutter F0_Zonnescherm_achtertuin_RS_VAL “Zonnescherm achtertuin” [ “WindowCovering” ] { autoupdate=“false” }
E) Updated the physical item =>: Rollershutter F0_Zonnescherm_achtertuin_RS_CMD “Zonnescherm achtertuin”
F) Restarted the Openhab service

Logfile after service stop/start:

Logfile after running UP or Down from: F0_Zonnescherm_achtertuin_RS_VAL

You should correct the line

new VASRollershutter(“F0_Zonnescherm_achtertuin_RS_VAL”, 56000, 53500);

To:

new VASRollershutter(“F0_Zonnescherm_achtertuin”, 56000, 53500);

Only the prefix of the items’ name should be used in this line.

Whoppaa! Works! Really thanks for your help and solution! Happy as a child in a candy shop!

@tarag
Hi one other question (maybe off topic for your script_: Do you use homekit to control your rollershutter? In homekit I do see the rollershutter (as WindowCovering). But the values are opposite. In OH the status is: 0 (= closed), in homekit it is fully Open. 98% open in Homekit is 2 in OH.

Glad that you made it work.

I am not using this anymore so I don’t know if it is inverted or not in HomeKit, but a quick search on the forum should give your the answer as I see some posts on this issue.

Yes will do! Have added a slider to my OH panel, so funny: if I put the slide from 0 > 50, after this commando the dot of the slider moves automatically in line with the position of the roller shutter. It Is next level!

je vous remercie beaucoup!

Hi Tarag,

I used the whole summer your solution. After the implementation in April, there were no changes required. Again many thanks for this.

Since OH 3.1 I have a issues with my total OH installation, meaning: every 7 day’s a full system crash. I learned that my Java “heap” volume is increasing and increasing, that casues a system crash. Today I have stopped all my things and will monitor over the weekend the Heap volume. The only thing what I couldn’t stop is the positon estimator for shutthers script.

  1. Do you have issues with the heap volume? (are you using OH3?)
  2. Do you think there is a relation between increasing heap volume and the position shutter solution?

Best, Wilko

I don’t use this version of the script as the installation is still running on OH2.5. I have no idea if it may leak and be the cause of your issue under OH3.

You can disable it by moving the VASRollershutter.js file outside of the automation folder and restart openHAB.

Thanks for your advice. I have renamed the script and will monitor the heap usage

Hi all -

I’ve developed a “profile” function which will add absolute position commands to blinds (i.e. Somfy and others) which do not natively support. The logic is leveraged from Tarag Gautier’s js scripts - but should be simpler to setup and use since it can be added as a profile to your Rollershutter item. To use:

Rollershutter KitchenShade	"Kitchen Shade"	{channel="somfymylink:shade:a56d1a8581:CC10915D-1:shadelevel" [profile="rollershutter:rollershutter-position", uptime=9.5, downtime=9.5] }

I will submit this to the openhab repository when/if some testing can be done by folks.

Thanks,
Jeff

3 Likes

I installed the code from post 24, but I have an error. Any ideas where it could come from and how I could resolve it?

[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab/automation/jsr223/javascript/personal/VASRollershutter.js': java.lang.ClassNotFoundException: org.eclipse.smarthome.model.script.actions.ScriptExecution cannot be found by org.openhab.core.automation.module.script_3.4.1

Also tried the addon from post 35, but the value is either 0 or 100.