Love this implementation a lot
I am using node ha-entity
to create and update sensor value.
I can not figure out, how to handle updates if the sensor repeats the previous value. When checked in HA, it shows as not being updated since the last state change.
I guess somehow I’d need to touch last_changed…
Here is my flow:
[{"id":"e97b2a4b.ab2348","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"491fc415.621e9c","type":"change","z":"e97b2a4b.ab2348","name":"battery level, oregon_th_outside","rules":[{"t":"move","p":"payload.bat","pt":"msg","to":"oregon_th_outside","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":260,"wires":[[]]},{"id":"5f1fb3ee.6b80ac","type":"ha-entity","z":"e97b2a4b.ab2348","name":"Outside temp","server":"e447d17a.16a64","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Outside temp"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"hass:thermometer"},{"property":"unit_of_measurement","value":"°C"}],"state":"payload.temp","stateType":"msg","attributes":[{"property":"batery level","value":"oregon_th_outside","valueType":"flow"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":1220,"y":180,"wires":[[]]},{"id":"2f1374fd.cf772c","type":"function","z":"e97b2a4b.ab2348","name":"Oregon TempHygro, 128B7, outside","func":"if ( msg.payload.name==\"Oregon TempHygro\"\n && msg.payload.id==\"128B7\" )\n{\n return msg;\n}\nelse\n return null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":180,"wires":[["5f1fb3ee.6b80ac","491fc415.621e9c"]]},{"id":"92eb03c6.3d0eb","type":"function","z":"e97b2a4b.ab2348","name":"RFLink decode","func":"var the433 = {}; \nmsg.payload = msg.payload.replace(/(\\r\\n|\\n|\\r)/gm,\"\"); \n// node.warn(msg.payload);\nvar parts433 = msg.payload.split(\";\"); \nthe433.p1 = parts433[0];\nthe433.p2 = parts433[1]; \nthe433.name = parts433[2];\nvar a = 3; \nwhile (a < parts433.length)\n{\n\tvar bits433 = parts433[a].split(\"=\"); \n\tswitch (bits433[0]) \n\t{ \n\t\tcase \"ID\": the433.id = bits433[1]; break; \n\t\tcase \"SWITCH\": the433.switch = bits433[1]; break; \n\t\tcase \"CMD\": the433.cmd = bits433[1]; break; \n\t\tcase \"SET_LEVEL\":\n\t\tthe433.set_level = parseInt(bits433[1], 10); break; \n\t\tcase \"TEMP\":\n\t\tvar int=parseInt(bits433[1],16);\n\t\tif ((int & 0x8000) >0) {\n\t\t\tthe433.temp=-(int & 0x7fff) / 10;\n\t\t} else {\n\t\t\tthe433.temp = int / 10;\n\t\t}\n\t\tbreak; \n\t\tcase \"HUM\": the433.hum = parseInt(bits433[1], 10); break; \n\t\tcase \"BARO\": the433.baro = parseInt(bits433[1], 16); break; \n\t\tcase \"HSTATUS\": the433.hstatus = parseInt(bits433[1], 10); break; \n\t\tcase \"BFORECAST\": the433.bforecast = parseInt(bits433[1], 10); break; \n\t\tcase \"UV\": the433.uv = parseInt(bits433[1], 16); break; \n\t\tcase \"LUX\": the433.lux = parseInt(bits433[1], 16); break; \n\t\tcase \"BAT\": the433.bat = bits433[1]; break; case \"RAIN\":\n\t\tthe433.rain = parseInt(bits433[1], 16) / 10; break; \n\t\tcase \"RAIN\":\n\t\tthe433.rainrate = parseInt(bits433[1], 16) / 10; break; \n\t\tcase \"WINSP\":\n\t\tthe433.winsp = parseInt(bits433[1], 16) / 10; break; \n\t\tcase \"AWINSP\":\n\t\tthe433.awinsp = parseInt(bits433[1], 16) / 10; break; \n\t\tcase \"WINGS\": the433.wings = parseInt(bits433[1], 16); break; \n\t\tcase \"WINDIR\":\n\t\tthe433.windir = parseInt(bits433[1], 10); break; \n\t\tcase \"WINCHL\":\n\t\tthe433.winchl = parseInt(bits433[1], 16); break; \n\t\tcase \"WINTMP\":\n\t\tthe433.wintmp = parseInt(bits433[1], 16); break; \n\t\tcase \"CHIME\": the433.chime = parseInt(bits433[1], 10); break; \n\t\tcase \"SMOKEALERT\": the433.smokealert = bits433[1]; break; \n\t\tcase \"PIR\": the433.pir = bits433[1]; break; \n\t\tcase \"CO2\": the433.co2 = parseInt(bits433[1], 10); break; \n\t\tcase \"SOUND\": the433.sound = parseInt(bits433[1], 10); break; \n\t\tcase \"KWATT\": the433.kwatt = parseInt(bits433[1], 16); break; \n\t\tcase \"WATT\": the433.watt = parseInt(bits433[1], 16); break; \n\t\tcase \"CURRENT\":\n\t\tthe433.current = parseInt(bits433[1], 10); break; \n\t\tcase \"CURRENT2\":\n\t\tthe433.current2 = parseInt(bits433[1], 10); break; \n\t\tcase \"CURRENT3\":\n\t\tthe433.current3 = parseInt(bits433[1], 10); break; \n\t\tcase \"DIST\": the433.dist = parseInt(bits433[1], 10); break; \n\t\tcase \"METER\": the433.meter = parseInt(bits433[1], 10); break; \n\t\tcase \"VOLT\": the433.volt = parseInt(bits433[1], 10); break; \n\t\tcase \"RGBW\":\n\t\tthe433.rgbc = parseInt(bits433[1].substring(0, 2), 16); \n\t\tthe433.rgbw = parseInt(bits433[1].substring(2, 4), 16);\n\t\tbreak;\n\t} \n\ta++; \n}\n\nmsg1 = {};\nmsg1.payload=the433;\nreturn msg1;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":180,"wires":[["2f1374fd.cf772c"]]},{"id":"845c4873.c466d8","type":"serial in","z":"e97b2a4b.ab2348","name":"RFLink","serial":"f4d1890d.229258","x":290,"y":180,"wires":[["92eb03c6.3d0eb"]]},{"id":"e447d17a.16a64","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true},{"id":"f4d1890d.229258","type":"serial-port","serialport":"/dev/serial/by-id/usb-Arduino__www.arduino.cc__0042_559363430343517001B0-if00","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"}]
Is this correct approach, or should I do it differently?