Sorry for replying to such an old thread, but I found this on Google and was struggling to figure out why my sensor was returning “Unknown” after applying this. The problem was, that this forum automatically changes quotation marks if they are not inside a code block and directly copy-pasting the answer left me with “ and ” in the config instead of the normal quotation marks. The code below should work for anyone trying to directly copy-paste too.