That is true. So maybe only store it until the config parameters are changed (better: only delete configuration for the parameters that got changed, keep the others)? Most times only the code will get changed, so that will still be a big benefit.
However that will need some more work to implement.
Edit: I just thought what happens to the already used widgets on dashboards after config parameters are changed? Is this also a point that is currently dangerous? Otherwise the preview widget could just be treated like a normal one, right?
@tailor See here, section “Reuse built-in widgets”:
In all theory you can spawn a chart with <widget-chart ng-model="..."></widget-chart> and extracting the model from an existing chart with the “Edit the local panel configuration” technique as described, however the charts are one of those widgets types like the knob which adjust their size automatically, so it’s more difficult to have it positioned correctly, you may have to tinker a bit.
I want to create a simpler custom color picker based on this widget - I’d like it to be a button that has the current set color, and clicking the button pulls up the picker (kind of like a combo-box) to select from some pre-set colors.
But… I don’t know where to start. Can the lazy-load approach be used to pull in the js definition of the widget? Does anyone have an example of creating a widget that’s completely unlike the internal widgets from a separate js file?
You can probably do all of those things with CSS. Can’t check now but the basic idea is to use the “Inspect” feature of your browser to figure out CSS classes and add CSS rules like display: none to hide the element or font-size to change the text size.
Hey Yannick,
thank you very much for this trick.
I tried to exchange the hardcoded item with a {{config.item}} but i think OH cant take user-created Variables or sth. like this.
You know any way to realise this?
Greetings Till
I try to build my own widget so I can use it for all my lights.
I have created a placeholder for an item under Settings. When I later assign an item to the widget, the name is displayed instead of the value of the item.
Actually the value ON or OFF should be in the widget?
If I use the standard widget “Switch” then it works.
I’m trying to create a combined power, dimmer & color picker for my lights. I’d like the power, label, and color picker to be on one “line” (from left to right in that order) and the slider to be underneath all that on the next “line”. But when I try to do this, I get everything on it’s own line, so all 4 controls are stacked rather than being 3 on the top with the slider underneath. I thought enclosing the first 3 items in their own “div” might help this, but no luck. Here is my code:
i would create a custom widget an call this custom widget from another customer widget.
So I tried to setup a directive but the tpl html will be not loaded ? Can someone help ?
directive:
(function () {
'use strict';
angular
.module('app.widgets')
.directive('shutter', function () {
return {
restrict: 'AE',
scope: {
ngModel: '='
},
templateUrl: '/static/matrix-theme/shutter.html',
controller: ['$controller', '$scope', function ($controller, $scope) {
debugger;
var myCtrl = $scope.ngModel;
return myCtrl;
}],
controllerAs: 'myCtrl',
};
})
.config(function (WidgetsProvider) {
debugger;
WidgetsProvider.$get().registerType({
type: 'shutter',
displayName: 'Shutter',
icon: 'download-alt',
description: 'A button performing a certain action, like sending a command to an openHAB item'
});
});
});
I’m about to create a custom widget and im wondering if the following is possible, and if so… how?
If someone could help me or maybe find another way to get this working, that would be very much apprecciated.
I have the following code
<div>{{itemValue('Item_Name_1')}}</div>
and i have a config value named count as number
now i want to replace the 1 in the first code block with the config.count value.
this has been asked probably multiple times but i couldn’t find an answer… so i’ll give it a try:
are the codes for the “standard” widgets to be found somewhere? i’d like to modify the standard switch lightly but i don’t know where to begin…