Thank you @daabm! You could also use a persistence provider to restore the presets at startup, that is what I do.
Did that - thanks for putting me on the right track Never thought about persistence before
Firstly: Thank you to DrRSatzteil; this is very handy!
I am stuck on thisā¦ sorry
Hereās how I understood to create the string item for 4:
I am pretty sure, I did not put the ā||ā¦ with Num1/2/3ā¦ being a number between 0 and 100ā correctly, but after trying and trying I canāt figure it out.
When I click on āPresetsā in the widget, nothing happens.
Or if the presets wonāt work: How could I remove the part with the presets from the widget?
(My config: Windows 10 computer; Openhab 4.0.4)
Hi,
the string item can have any label you want so you can give it a meaningful name. I admit that this is pretty misleading in my description, you donāt have to care about the format at all as it is all taken care of by the rules.
Donāt give up just yet though. Iām pretty sure we can get you there. Could you show you widget configuration and also confirm that you also installed the second widget from the original post?
Wow, now thatās instant support. Thank you!
I did indeed completely overread the 2nd widget. The popover opens now!
Now, it looks like in Post 9/44:
However, I canāt change it (click on add does nothing - swipe and delete for the wrong entry does nothing).
EDIT (I had a log posted but it was due to wrong ECMA version): I figured out how to set the scripting setting to ECMA 5.1 (needed to install Nashorn).
Now it does not do anything, but the log also shows nothing.
Oh this looks good so far. Just to make sure that it really isnāt working yet:
If you change the blinds position to letās say 40% (or any other value) and the click on the āAddā button the list should be updated with a value of 40%.
If you swipe the initial NULL entry to the left you should see a button that allows you to delete this preset.
If these things are not working there is still something wrong with the scripts or with the widget configuration.
Hereās my setup:
The three items for 4, 5 and 6:
The rule āadd Presetsā
configuration: {}
triggers:
- id: "2"
configuration:
itemName: Storen_Preset_add_preset
type: core.ItemCommandTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
type: application/javascript;version=ECMAScript-5.1
script: >-
var currentPresets =
ir.getItem('Storen_Preset_add_preset').state.toString()
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("|")
events.sendCommand(ir.getItem('Storen_Preset_add_preset'), newPresets)
}
type: script.ScriptAction
The rule ādelete Presetsā
configuration: {}
triggers:
- id: "2"
configuration:
itemName: Storen_Preset_delete_preset
type: core.ItemCommandTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
type: application/javascript;version=ECMAScript-5.1
script: >-
var currentPresets =
ir.getItem('Storen_Preset_delete_preset').state.toString();
var presetsArray = currentPresets.split('|');
var index = presetsArray.indexOf(command.toString().split(".")[0]);
if (index > -1) {
presetsArray.splice(index, 1);
var newPresets = presetsArray.join("|");
events.postUpdate(ir.getItem('Storen_Preset_delete_preset'), newPresets);
}
type: script.ScriptAction
Problem:
When I click āaddā in the presets popover, nothing happens.
When I swipe the āNULL%ā and click delete, nothing happens.
No log entry that seems to be associated with this widget.
Please change the following:
In the add rule change the name of the item in the first and the second to last line to āStoren_Presetā. The item referenced there should be the item that stores all your presets as an array. Iām only talking about the script code, leave the trigger as it is now.
The same applies to the delete rule. Also use Storen_Preset there and you should be good.
Oooh, I was stupid/not reading correctly. Sorry!
It really works now! And I learned something about ECMA-versions. Thereās still so much to learn. Since I am not a programmer and wonāt ever be (but still appreciate to be able to customize stuff), I am very grateful for developers like you who put their products out in the world for free for the crowd and then indulge with our stupid questions.
Thank you very much for the widget and the support and have a great sunday!