Hello,
I have a problem with my mqtt sensor. I’d like to use ‘number’ as data type. But then the messagemap does not work. With data type ‘string’ it works. But unfortunately I cannot use the graph in this case.
So I’m not an expert at this point. Does anyone have an idea why it’s going wrong? Is there a bug in the function?
When I first put the indexes to the messagemap I see only “unknown” as value. And when I first put in the values I only see the original value as a number.
I found the location in the mqtt-sensor.coffee script. In the second case the line if attr.messageMap && attr.messageMap[message] is not true because of the condition attr.messageMap[message]. In the first case it steps over to the last else block. I think it’s quite logical, but why is the index not recognized. I send a value 2 and I have 2 in my messagemap. But it doesn’t work.
else
if attr.type == 'number'
if attr.division
payload = (Number(message) / attr.division)
@setValue(payload, name)
return
if attr.multiplier
payload = (Number(message) * attr.multiplier)
@setValue(payload, name)
return
if attr.messageMap && attr.messageMap[message]
payload = Number(attr.messageMap[message])
@setValue(payload, name)
return
else
payload = Number(message)
@setValue(payload, name)
return
Thank you very much