Volume Control Via Slider (Openhab)

I am currently using Habpanel for my project but got stucked with how I can control the volume using the slider/dimmer approach. Controlling the volume by pressing the icons 1 by 1 (working) is a bit slow and long process and I want to control it using a slider in an interval of either 5 or 10. I have tried the commands I saw here but none of it worked.

Item (these strings are saved as 1 item):

Switch 3F_BR_Remote_TV_VolumeUp “3F TV Volume [%s]” (Bedroom) [ “Switch” ] {channel = “broadlink: rm2: 78-0f-77-b9-xx-xx-xx:command”}
Switch 3F_BR_Remote_TV_VolumeDown “3F TV Volume [%s]” (Bedroom) [ “Switch” ] {channel = “broadlink: rm2: 78-0f-77-b9-xx-xx-xx:command”}

P.S I have used switch and dimmer on the item name part

Rules I’ve tried:

Rule#1
rule “Volume”
when Item 3F_BR_Remote_TV_Volume received command then var Number percent = 0

if(3F_BR_Remote_TV_Volume.state instanceof DecimalType) percent = 3F_BR_Remote_TV_Volume.state as DecimalType if(receivedCommand==INCREASE) percent = percent + 5 if(receivedCommand==DECREASE) percent = percent - 5

if(percent<0) percent =0 if(percent>100) percent= 100

postUpdate(3F_BR_Remote_TV_Volume,percent)

end

Rule #2
rule “3F_BR_Remote_TV_Volume”
when
Item 3F_BR_Remote_TV_Volume received command
then
3F_BR_Remote_TV_VolumeUp.sendCommand(receivedCommand)
3F_BR_Remote_TV_Volume.postupdate(receivedCommand)
end

I have linked the items in broadlink bindings and confirmed working if pressed in the HabPanel but no luck using the slider. On the slider widget, I’ve tried to add an item but I can only see the volumeDown item.

Please How to use code fences

Create a Number or Dimmer Item to represent the state of your volume. Put this on your sitemap using a Slider element.

Slider item=Volume_Proxy minValue=0 maxValue=100 step=5

When the number changes, you need to issue the appropraite number of VolumeUP and VolumeDown commands to the Items linked to the device.

However, where this is all going to break down is if you do not have any feedback from the device telling you what the actual volume is, you will likely end up getting out of sync between your proxy Item and the actual volume of the device, especially if it’s possible to control the volume outside of OH.

1 Like

Using these strings in one item (wherein 3F_BR_Remote_TV_Volume acts as proxy of the Volume Up and Down command):

Dimmer 3F_BR_Remote_TV_VolumeUp “3F TV Volume” (Bedroom) [ “Switch” ] {channel = “broadlink: rm2: 78-0f-77-xx-xx-xx-xx:command”}

Dimmer 3F_BR_Remote_TV_VolumeDown “3F TV Volume” (Bedroom) [ “Switch” ] {channel = “broadlink: rm2: 78-0f-77-xx-xx-xx-xx:command”}

Dimmer 3F_BR_Remote_TV_Volume “3F TV Volume”

=========

rule “3F_BR_Remote_TV_Volume”

when

Item 3F_BR_Remote_TV_Volume received command

then

3F_BR_Remote_TV_VolumeUp.sendCommand(receivedCommand)

3F_BR_Remote_TV_Volume.postupdate(receivedCommand)

End

Sitemap:

Slider item=3F_BR_Remote_TV_Volume label=“3F BR TV VolumeCombine[]” minValue=0 maxValue=100 step=5 (unable to see by the sitemap)

Slider item=3F_BR_Remote_TV_Volume label="3F BR TV VolumeCombine (seen by sitemap but not working)

Using the sitemap, below are the logs from tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log using the SITEMAP:

2019-11-02 10:54:56.417 [ome.event.ItemCommandEvent] - Item ‘3F_BR_Remote_TV_Volume’ received command 39

2019-11-02 10:54:56.426 [nt.ItemStatePredictedEvent] - 3F_BR_Remote_TV_Volume predicted to become 39

2019-11-02 10:54:56.449 [vent.ItemStateChangedEvent] - 3F_BR_Remote_TV_Volume changed from 80 to 39

Using the sitemap, below are the logs from tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log using the OPENHAB (with increments of 10):

==> /var/log/openhab2/events.log <==

2019-11-02 10:57:47.919 [ome.event.ItemCommandEvent] - Item ‘3F_BR_Remote_TV_Volume’ received command 30

2019-11-02 10:57:47.932 [nt.ItemStatePredictedEvent] - 3F_BR_Remote_TV_Volume predicted to become 30

2019-11-02 10:57:47.951 [vent.ItemStateChangedEvent] - 3F_BR_Remote_TV_Volume changed from 20 to 30

Sliding the slider shows no result on the television.
Apologies if I have too much questions with regards to the configuration as I am new to Openhab. I have tried my best to look for the rules throughout the internet but I cannot find an explanation to how I should execute the slider for volume. If I see one, it is not working.

  1. Please use code coffee fences

  2. What you did had nothing to do with what I suggested.

  3. This is probably a fool’s errand anyway as it’s never going to work well.

1 Like

Thank you for your assistance and replies. I will park the issue for the meantime as I will be moving to the other platform.