[SOLVED] Send Hex values from MAP file

Hello dear openhab community,

I’m trying to send a variable hex value (00-FF) to a bash file - it should be possible to control it with a slider.

The slider only outputs a value between 0-100, so I created a MAP (dectohex.map) to get hex values from it.

During my attempts I could not manage that the dectohex.map value is sent, only the slider value (0-100) was sent.

I have tried everything possible - but unfortunately I can’t find a working solution.

Here is my current (not working) solution:

home.rules :

rule "Send_Hex_value"
    when
        Item Hex_value changed
    then
    {executeCommandLine("bash /etc/openhab2/scripts/UDPsend.sh 1A0000000000000000000000140000002E010003EF030100"+ Hex_value.state +"00")}
end

home.items :

String Hex_value "Status: [MAP(dectohex.map):%s]"

home.sitemap :

sitemap home label="Building controll" {

    Frame label="Blind_control" {
        Slider item=Hex_value label="[%s]"
        Default item=Hex_value icon="blinds"
	 }
}

dectohex.map :

-=00
NULL=00
0=00
1=03
2=05
3=08
4=0A
5=0D
6=0F
7=12
8=14
9=17
10=1A
11=1C
12=1F
13=21
14=24
15=26
16=29
17=2B
18=2E
19=30
20=33
21=36
22=38
23=3B
24=3D
25=40
26=42
27=45
28=47
29=4A
30=4D
31=4F
32=52
33=54
34=57
35=59
36=5C
37=5E
38=61
39=63
40=66
41=69
42=6B
43=6E
44=70
45=73
46=75
47=78
48=7A
49=7D
50=80
51=82
52=85
53=87
54=8A
55=8C
56=8F
57=91
58=94
59=96
60=99
61=9C
62=9E
63=A1
64=A3
65=A6
66=A8
67=AB
68=AD
69=B0
70=B3
71=B5
72=B8
73=BA
74=BD
75=BF
76=C2
77=C4
78=C7
79=C9
80=CC
81=CF
82=D1
83=D4
84=D6
85=D9
86=DB
87=DE
88=E0
89=E3
90=E6
91=E8
92=EB
93=ED
94=F0
95=F2
96=F5
97=F7
98=FA
99=FC
100=FF

Has anyone already had the same problem or a tip for me?

When you use a MAP in an Item label, it only maps for display purposes. The Item value is still 0-100.

You’ll want to apply the map in your rule

1 Like

Thank you so much! I finally made it!

changed the rules to:
home.rules :

rule "Send_Hex_value"
    when
        Item Hex_value changed
    then
    {executeCommandLine("bash /etc/openhab2/scripts/UDPsend.sh 1A0000000000000000000000140000002E010003EF030100"+ transform("MAP","dectohex.map",Hex_value.state.toString) +"00")}
end

and now it does exactly what it should :slight_smile:
Thanks for your quick help!