Custom rollershutter widget with preset configuration

I also use a Shelly 2.5. I guess you used the Control channel for the position control. Alternatively you may use the Position channel offered by the Shelly for the slider, then there is no need to modify the widget.

Hi Thomas
I found the position channel under advanced.
But I have allready modify the widget. It is a great idea to have 2 controls for the shutter.
And the position control tells me the correct number. So I will use it
I use this numbers also in other rules, so this is more simple for me to use allways the same item
For example in a rule for sun protection or in the night (left side 55%, right side 100%) for the french windows. Make the life easier with the dogs :slight_smile:

Hey,

thanks a lot for this. I am using Homematic instead of Shelly and I don’t seem to have an alternative channel for the position. So this actually does the trick for me!

Hi Thomas

thank you for your widget which works pretty fine. I changed some things so that it looks similar to the cell cards. What doesn´t work are the presets. If I execute the preset I get the following log:

Script execution of rule with UID 'Rollershutter_preset' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "ir" is not defined

I have no clue what I have to change.

My guess is that you used a different scripting language. Make sure that you use ECMA Script 5.1:

that did the job - thank you.

Edit
Nvm found the typo… Working now :slight_smile:

Hi Thomas,
thank you for your great widget!

I followed your instructions, but i think i miss something. I cant add, nor delete presets.
Log file states, that the item does not exist…

2022-06-22 15:55:11.361 [WARN ] [e.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: undefined
2022-06-22 15:55:29.221 [WARN ] [e.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: undefined
2022-06-22 15:55:32.985 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'fd559c6629': Fail to execute action: 3



Do i miss some dependencies/persistence?

1 Like

Moin Dr. RSatzteil,

today i tried out ur widget and i must say it’s real nice.
Problem i always have, is that my Homematic Wired DRBL4 dont understand the “stop” command on the Level Channels. It has a seperate “stop” channel that i have to trigger with on and off… yes i know its silly from the manufactur but what can i do.
Now i am wondering if i can use ur widget and modifiy it, so the Stop button will trigger a different Item than the Level Item.

thanks again for ur contribute
Karlo

Hi Karlo,

I think you have two options here: you could modify the widget code (add another item to the config and change the action for the stop button). It’s not a lot of work but might be tricky when you’re dealing with the widget code for the first time. I could maybe create a new version with this feature but I don’t know when I will find the time.

The second option would be to use a proxy item in the widget and a rule that routes the up/down commands to one item and the stop command to a different item.

Hi,

thanks for the quick reply.
You got it right, me dealing with Widget code for the first time.
Failed :smiley:
But maybe my thoughts were at least right:

i Added in your widget a:

  • context: item
    description: Rollershutter control (STOP commands)
    label: Rollershutter control stop
    name: controlstop
    required: true
    type: TEXT

named it controlstop
and changed the Stop button to =props.controlstop with the Command “on” like:

                  - component: oh-link
                    config:
                      actionItem: =props.controlstop
                      actionCommand: on
                      action: command
                      iconF7: stop
                      iconSize: 20
                      style:
                        background-color: rgba(246, 158, 81, 0.2)
                        padding: 10px

maybe my thoughts are too easy :frowning:

That looks pretty good already however I guess the actionCommand should be something different: what do you need to send as command to the stop item to make it stop? Is this really „on“?

Yes after your write “on”. i remembered that it is caps sensitive so it needs to be “ON”…
BS
I put the Stop channel as a Switch Item in, so there is ON or OFF and a script that makes it a button (after 500ms switch back to OFF) cause i still didnt figure out how to trigger on OH as a Button and not switch… some day

But anyway YES IT WORKS now… thanks dude that helped alot :smiley:

1 Like

I think it would be possible to store the latest content of the preset-items via MapDB persistance. But after a openHAB-restart the items are always NULL.
My mapdb.persist looks like this

Strategies {
	everyMinute : "0 * * * * ?"
	everyHour   : "0 0 * * * ?"
	everyDay    : "0 0 0 * * ?"
	default = everyChange
}

Items {
  
  rollershutter_preset_* : strategy = everyUpdate, everyChange, restoreOnStartup  
  
}

What is going wrong, openHAB 3.3.0 Release Build, MapDB is 3.3.0 ?
Maybe there is a common problem ?

It is definitely possible and I do this without any problems. There is nothing special about the item so I guess this must be a problem not specific to the widget. Unfortunately I had only set up a persistence group once and never fiddled around with it after that so I cannot tell you why this is not working. However I’m pretty sure that there are other users out there who may be able to help you. I would suggest to open a new thread however to increase the visibility of your question!

Hi Thomas,
thx for your posts, it works fine with one problem: whats the code of your preset string items?
I can´t get them working.
I hope you can help me.
Yours
Fred

Hi Alfred,

you just create a string item. There is no need to do anything else with this item but to use it in the widget. If this does not solve your problem please describe (if possible with a screenshot) what does not work for you. Thank you!

Hi Thomas,
thanks for replying that fast.
I created now 3 string items, adapted the rules and it works fine now.
THX very much, yours
Alfred

Hi Thomas,

Just want to say thanks for the detailed description. Your combo widget is a good starting point on using space efficiently, and will serve well as inspiration for customizing/making my own thing for controlling the KNX venetian blinds (jalousien), which have multiple control channels for manual and absolute positioning both for lowering/raising the slats and for controlling their angle and amount of light they let through.

Hi,

Just want to thank you for this example.
Nice widget.

1 Like

Absolutely love this widget. One thing I added was to initialize the presets with my default values. Makes things easier upon OH restarts :slight_smile:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var currentPresets = ir.getItem('RSPreset_Stored').state.toString();
logger.info( 'Current presets: '+currentPresets);
try {
  var index = presetsArray.indexOf(command.toString().split(".")[0])
} catch ( e ) {
  currentPresets=NULL;
}
if (currentPresets==NULL) {
  presetsArray = [ 30, 50, 65, 80 ];
  var newPresets = presetsArray.join("|")
  logger.info( 'Setting new presets because current are empty:'+newPresets);
  events.sendCommand(ir.getItem('RSPreset_Stored'), newPresets);
} else {
  logger.info( 'Verifying new presets: '+currentPresets);
  var presetsArray = currentPresets.split('|')
  var index = presetsArray.indexOf(command.toString().split(".")[0])
  if (index < 0) {
    presetsArray.push(command.toString().split(".")[0]);
    presetsArray.sort(function(a, b) {
      return a - b;
    })
    var newPresets = presetsArray.join("|")
    logger.info('Updating current presets, new value: '+newPresets);
    events.sendCommand(ir.getItem('RSPreset_Stored'), newPresets);
  } else {
    logger.info( 'Nothing to do, new preset already in list...')
  }
}

Could have defined the presets as a string, obviously. But loved the idea of them being an array :smiley: And too much logging obviously.

In addition, I also had to reverse 0/100, and I added a scale to the slider which makes it look more neatly for me. Here’s only my additions to the slider component.

                        config:
                          max: 100
                          min: 0
                          releaseOnly: true
                          scale: true
                          scaleSteps: 2
                          scaleSubSteps: 5
                          step: 5
                          vertical-reversed: true

Anyway, great kudos to @DrRSatzteil for creating the widget :+1: