Dear OpenHAB Forum
hereby my Kodi remote,
It’s simple so beginners can use it to start understanding the way HABPanel custom widgets work.
It looks like this:
Template:
<style>
table{
width: 100%;
margin: 0;
padding: 0;
}
td{
width: 33.3333333333%;
position: relative;
}
td:after {
content: '';
display: block;
margin-bottom: 100%;
}
button {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
color: white;
height: 100%;
border: 0;
color: white;
background: darkgrey;
font-size: 20px
}
</style>
<table>
<tr>
<td>
<button ng-click="sendCmd('myKodi_volumeMinus', 'ON')">
<i class="glyphicon glyphicon-volume-down"></i>
</button>
</td>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_input', 'Up')">
<i class="glyphicon glyphicon-menu-up"></i>
</button>
</td>
<td>
<button ng-click="sendCmd('myKodi_volumePlus', 'ON')">
<i class="glyphicon glyphicon-volume-up"></i>
</button>
</td>
</tr>
<tr>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_input', 'Left')">
<i class="glyphicon glyphicon-menu-left"></i>
</button>
</td>
<td>
<button ng-click="sendCmd('myKodi_input', 'Select')">
<i class="glyphicon glyphicon-screenshot"></i>
</button>
</td>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_input', 'right')">
<i class="glyphicon glyphicon-menu-right"></i>
</button>
</td>
</tr>
<tr>
<td>
<button ng-click="sendCmd('myKodi_input', 'Back')">
<i class="glyphicon glyphicon-arrow-left"></i>
</button>
</td>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_input', 'Down')">
<i class="glyphicon glyphicon-menu-down"></i>
</button>
</td>
<td>
<button ng-click="sendCmd('myKodi_informatie', 'ON')">
<i class="glyphicon glyphicon-menu-hamburger"></i>
</button>
</td>
</tr>
<tr>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_control', 'PREVIOUS')">
<i class="glyphicon glyphicon-step-backward"></i>
</button>
</td>
<td>
<button ng-click="sendCmd('myKodi_control', 'PAUSE')">
<i class="glyphicon glyphicon-pause"></i>
</button>
</td>
<td>
<button style="background: dimgrey;" ng-click="sendCmd('myKodi_control', 'NEXT')">
<i class="glyphicon glyphicon-step-forward"></i>
</button>
</td>
</tr>
</table>
Items
Switch myKodi_volumePlus
Switch myKodi_volumeMinus
Switch myKodi_informatie
Rules
rule "volumePlus"
when
Item myKodi_volumePlus received update
then
var Number percent = 0
if(myKodi_volume.state instanceof DecimalType){ percent = myKodi_volume.state as DecimalType
percent = percent + 5
if(percent>100) percent = 100
sendCommand(myKodi_volume, percent);
}
end
rule "volumeMinus"
when
Item myKodi_volumeMinus received update
then
var Number percent = 0
if(myKodi_volume.state instanceof DecimalType){ percent = myKodi_volume.state as DecimalType
percent = percent - 5
if(percent<0) percent = 0
sendCommand(myKodi_volume, percent);
}
end
rule "informationen"
when
Item myKodi_informatie received update
then
myKodi_input.sendCommand('ContextMenu');
myKodi_input.sendCommand('showOSD');
end```