I have an Epson projector for which I would like to control volume. I’ve patched the epson projector binding and added VOL command support so now my item looks something like this:
Number HomeCinemaVolume "Home Cinema Volume" (HomeCinema) { epsonprojector="homecinema:Volume:ON,6000" }
Volume in the projector has values from 0 to 20 with 1 step increments. But in order to control it I must send i 12x or 13x increments, eg. :
Number to send -> actual epson volume
146 -> 12
134 -> 11
121 -> 10
109 -> 9
97 -> 8
I can transform data from the device with profile and transform:SCALE
or transform:JS
but what about data sent to device? One way I though about this is using a rule:
Number HomeCinemaVolumeInternal "Internal Volume" { epsonprojector="homecinema:Volume:ON,6000" }
Number HomeCinemaVolume "Home Cinema Volume" (HomeCinema)
rule "Map Home Cinema Volume From Device"
when
Item HomeCinemaVolumeInternal received update
then
HomeCinemaVolume.postUpdate(HomeCinemaVolumeInternal.state / 12.5 * 5)
end
rule "Map Home Cinema Volume to Device"
when
Item HomeCinemaVolume received update
then
HomeCinemaVolumeInternal.sendCommand(HomeCinemaVolume / 5 * 12.5)
end
But Can I do this without using the rule ? Ideally I would like the item have values from 0 to 100 and then somehow transform then