Template widget - tutorial & examples - make your own widget!

thanks again - it works!:relaxed:

You can also define key/value pairs (similar to transformations) with a JSON object, example here:

Hello @amsd

I don’t know if you have everything working already, but you may want to look at the Custom Widget: Music Control thread. It has examples for controlling the Onkyo receivers, with drop down menus, etc.

Hello!
I’m total beginner in OpenHAB and HABpanel and I’m trying step by step to check if they suit my requirements.
I’m trying to create my first template widget - it is really very very simple: it should show just a number value taken from variable. Unfortunetelly it always shows N/A value. Where is an error? Here is my configuration:

Can anybody help me?

The variable in the custom widget editor are called “config.id” where id is the id name
Therefore you should replace ItemValue(‘field1’) with config.field1

2 Likes

Can anyone tell me how to increase and send back a decimal properly? I don’t get how casting should be handled:

ng-click=“sendCmd(‘EGWZHZThermostat_4_SetTemperature’, 1.0*itemValue(‘EGWZHZThermostat_4_ActualTemperature’) + 0.5)”

doesn’t seem to work…

For the temperature setpoint I use {{+itemValue(‘myItem’) + 0,5}} and it works.

with comma? are you sure that works?

Sorry typing mistake. This is my code :ng-click=“sendCmd(‘SetTemp_Taverna’, +itemValue(‘SetTemp_Taverna’)-0.5)”

it’s working now meanwhile - I had a different problem. Thanks for the reply!

I just want to create a button to increase (or decrease) a DateTime by 30 min.

something like ng-click=“sendCmd(‘Sveglia’, +itemValue(‘Sveglia’)+ ?? )”

Any Idea?

Hi all,

I am using kubawolanin widget below with some alterations to suit my own needs, and I was wondering how I would go about calling a url string to provide an icon instead of the ones kubawolanin uses.

I know how to configure the settings I just don’t know the code to call the url. This is an example of the url I am provided:

And I know that the line of code I need to change is the bottom line, I’m just unsure of what to change it to…:

<div class="weather-content">
  <div class="weather-row">
    <div class="weather-icon" ng-class="(ngModel.sizeX === ngModel.sizeY) ? 'col-md-12' : 'col-md-10'">
		<img style="filter: invert(60%) sepia(100%) hue-rotate(185deg) saturate(1000%);"
		src="/icon/climacon?iconset=climacons&format=svg&state={{itemValue(config.weather_condition)}}" />

https://community.openhab.org/t/custom-widget-current-weather/18216

I appreciate anyones help on this.

Try something like

<img style="filter: invert(60%) sepia(100%) hue-rotate(185deg) saturate(1000%);"
		src="{{itemValue('Your_Weather_Icon_Url_Item')}}" />

@kubawolanin

That’s great! Worked a treat! I now have:

I just need to play about with it a bit now to get original colours.

Thanks a lot!

Just remove this line and you should be ready to go :wink:

1 Like

Thanks! All done!

Yannick,

recently moved from OH1.7 to OH2 and discovered the HABPANEL and started playing around with the widgets. Thanks to your input on this forum, I was able to start to build some custom widgets.
I have a number of Webcams where I use the std widget to display an image which I refresh once a second.
Now, when I saw your example of the Angular based Carrousel, I planned to use this to rotate the Webcam images to preserve dashboard space … This works, but the images are not refreshed …only when I manually refresh my browser, it will display a fresh image …
Is there

hit enter to fast …
Is there an option have the image refresh every time ?

thx

@chris_van_aalst nothing prevents you from putting a HABPanel image widget as the content of the slides, initializing it with a model with the “refresh” property set to an amount in seconds (from https://github.com/openhab/org.openhab.ui.habpanel/blob/master/web/app/widgets/image/image.widget.js#L87 - a proper documentation of these is underway):

  <div uib-carousel active="0" interval="5000" no-wrap="false">
    <div uib-slide index="0" ng-init="model1 = { 'url':'<your_first_image_url>', 'refresh': 5 }">
      <widget-image ng-model="model1" style="margin:auto;"/>
    </div>
    <div uib-slide index="1" ng-init="model2 = { 'url':'<your_second_image_url>', 'refresh': 5 }">
      <widget-image ng-model="model2" style="margin:auto;"/>
    </div>
    and so on...

I didn’t test it too much though, there might be issues to sort out…

2 Likes

Yannick,

this works: a snapshot of my Webcam - refreshes every 1 second and changes Webcam every 5 seconds !

Thanks very much !

Chris

<div style="height: 610px">
  <div uib-carousel active="0" interval="5000" no-wrap="false">
    <div uib-slide index="0" ng-init="model1 = { 'url':'http://192.168.0.118/snap.jpeg', 'refresh': 1 }">
      <widget-image ng-model="model1" style="margin:auto;"/>
    </div>
    <div uib-slide index="1" ng-init="model2 = { 'url':'http://192.168.0.121/snap.jpeg', 'refresh': 1 }">
      <widget-image ng-model="model2" style="margin:auto;"/>
    </div>
    <div uib-slide index="2" ng-init="model3 = { 'url':'http://192.168.0.122/snap.jpeg', 'refresh': 1 }">
      <widget-image ng-model="model3" style="margin:auto;"/>
    </div>
    <div uib-slide index="3" ng-init="model4 = { 'url':'http://192.168.0.123/snap.jpeg', 'refresh': 1 }">
      <widget-image ng-model="model4" style="margin:auto;"/>
    </div>
  </div>
</div>

6 Likes