I’m sending a notification to my phone from an mqtt message whichi payload is :
{ “id”:“1”,“action”:“open”,“vddaMV”:“3031” }
I can display the vddaMV field with this data: message: 'Your message goes here {{ trigger.payload_json.vddaMV }}mV'
This is a millivolt value and I want to display a volt value. I tried several things message: 'Your message goes here {{ trigger.payload_json.vddaMV /1000}}mV'
message: 'Your message goes here {{parseInt(trigger.payload_json.vddaMV)/1000}}V'
message: 'Your message goes here {parseInt({trigger.payload_json.vddaMV})/1000}V'
message: 'Your message goes here {{(parseInt(trigger.payload_json.vddaMV)/1000).toString()}}V'
message: 'Your message goes here {(parseInt({trigger.payload_json.vddaMV})/1000).toString()}V'
but none of them is working. How can I do that?
Thanks
the biggest things to remember are that states are always strings and templates always return strings. Even if it doesn’t look like a string (‘1’ =/= 1)
So any operation that you want to perform on a template result that requires anything other than strings you need to convert the data type.