KODI Remote

Tags: #<Tag:0x00007f6173929858> #<Tag:0x00007f6173929768> #<Tag:0x00007f61739296a0>

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```
3 Likes

Hey @just_survive Good Work on the Remote, Yours is advanced than mine with all the icons and all but I have a slight dissatisfaction with the volume :confused: :

I see you went for a slightly different approach than Me :sweat_smile:

I use a slider widget that only sends one value each time I slide the slider, now this is a static and non-tactile way of changing the volume :broken_heart:

The question is: Is there a way of making a slider that continuously sends a value?

Thanks

Can you explain your question in a little bit more depth?
What do you mean by continous value?

To correct the statement: Continuously sends values

  • The values that are constantly changing or constantly being updated as I slide the slider.
    Instead of having one value send each time I slide the slider

Great example! Thanks. Do you know how to change general Volume?

sendCommand(myKodi_volume, percent);

I think it is possible but it would be some advanced java, you could just take the standard slider amd use a hunderd points, this should ‘appear’ as a constant updating slider. Or you could use buttons (as I did) and add a read only slider / disk. buttons are spamable so cou can get the volume up/ down easy and you can adjust the code (the ± 5) to your liking

This will only change kodi internal volume, not the general one. I would like to change volume which is transmitted further through for example HDMI-CEC. I guess kodi binding doesn’t support this.

i don’t know if it’s supported, but you can’t you fix this with some java?

wish I were java developer :slight_smile:

ask people on fora or copy something :slight_smile:
I aint a java dev so i wont be able to help you any further :cry: i wish i was.
have a nice day

1 Like