Convert Hex to dec

Hi, i have an hex value in my sensor … how can i convert it to an decimal integer, so i can use it with a shell command?

thnx in advance

i want to change the state of an light (brightness) so from 0 … 255 , but i only have at the moment the HEX value coming from my domotica

{{ states(ENTITY_ID)|int(base=16) }}

thnx already

will the below command work? i use those curl scripts succesfull for normal lights where i need to set JUST the state to on or off, but now i also need for some dimmerlights the brightness
also i get a HEX value back from my system 00 to 64 (in hex) , thats from 0 to 100

so i need to recalculate it, so i can send a decimal value between 0 … 255 back for brightness …
is this the correct approach?

dimmer1_on: "curl -k POST -d '{\"state\": \"on\",\"attributes\": {\"brightness\": states.sensor.Prog.state|(int(base=16)/100)*255}}' https://127.0.0.1:8123/api/states/light.dimmer1?api_password=blabla"

ok, it doesnt work :slight_smile:

also this doesnt work :frowning:

(states('sensor.Prog.state[36:38]')|(int(base=16))/100*255

dimmer1_on: "curl -k POST -d '{\"state\": \"on\",\"attributes\": {\"brightness\": {{states.sensor.Prog.state|int(base=16)/100*255}}}}' https://127.0.0.1:8123/api/states/light.dimmer1?api_password=blabla"

damnit , forgot those ninja {{}} things :frowning:

got it to work now, thnx a lot!!!

1 Like

lol. I think you mean Jinja. :wink:

Glad you got it working!!

Yeah :wink:

Thnx