Hi, I have a sensor
- platform: template
sensors:
trasmettitore_rc_potenza:
friendly_name: "Potenza Trasmettitore RC"
unit_of_measurement: "W"
value_template: >
{{ state_attr('sensor.trasmettitore_rc', 'PARAM')[5] }}
The value is Base64. Is there a way to decode it directly on the value_template parameter?
E.g.
IDEwMDA= -> 1000
Thanks
123
(Taras)
2
Use base64_decode
.
Example:
Specifically for your sample value:
2 Likes
I was stumbiling over this solution while trying to decode a datapacket from a Lora-Node.
Unfortunately this today does not work (anymore?)
I get this errormessage:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte
123
(Taras)
5
Perhaps the problem might be that the supplied string isn’t encoded correctly.
Because decoding works with an encoded string.
The problem is that LoraWAN networks send raw byte payloads base64 encoded. So these can not be decoded into utf-8 character strings.
Keep an eye on Base64 decode encoding by paulusbrand · Pull Request #116603 · home-assistant/core · GitHub.
This pull request will enable the option to decode the base64 string into raw bytes, example: