Announcement

Collapse
No announcement yet.

RFC: Parsing TEMP05 Sensor Readings into HS Device Values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    RFC: Parsing TEMP05 Sensor Readings into HS Device Values

    For those who don't remember the TEMP05 it is a 1-wire interface that sends device readings to HS via serial port. I have 5x temperature sensors around the house that report in every 5 minutes. Up until now I've been using a VB serial script but decided to re-implement this in Node-Red. The TEMP05 transmits ASCII messages terminated with a <CR><LF>. I'm only interested in the messages that start with "Sensor".

    Here is a sample of the messages:

    Code:
    Sensor #01[E40008001E1A0710]=72.15F
    Sensor #02[760008001E1A2810]=86.66F
    Sensor #03[FD0008002DDCCC10]=83.96F
    Sensor #04[3101186E1A7EFF28]=86.28F
    Sensor #05[EB0008002DF69010]=83.85F
    Here is the overall flow:
    Click image for larger version  Name:	Screen Shot 2022-04-08 at 12.55.10 PM.png Views:	0 Size:	58.0 KB ID:	1535798
    The "Get Sensor ID" and "Get Sensor Value" nodes are node-red-contrib-string nodes used to parse the ASCII message.

    "Get Sensor ID" checks to see if msg.payload startsWith "Sensor", parses the ID in the message. and stores it in msg.sensor_id. otherwise sets msg.sensor_id to '99'.

    Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.04.00 PM.png Views:	0 Size:	39.3 KB ID:	1535799Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.04.21 PM.png Views:	0 Size:	9.3 KB ID:	1535800

    Similar for "Get Sensor Value" except it stores into msg.sensor_value.

    Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.08.15 PM.png Views:	0 Size:	39.9 KB ID:	1535801Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.09.22 PM.png Views:	0 Size:	9.4 KB ID:	1535802

    "Prep HS Msg" is a change node that deletes msg.payload since it's no longer needed, sets msg.topic to "update", msg.payload.value to msg.sensor_value, and msg.payload.status to msg.sensor_value:

    Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.14.15 PM.png Views:	0 Size:	45.6 KB ID:	1535803

    Finally, a switch node "Select HS Device" routes the msg to the HS Device node based on msg.sensor_id. msg.sensor_id = '99' gets routed to a null output.

    Click image for larger version  Name:	Screen Shot 2022-04-08 at 1.18.47 PM.png Views:	0 Size:	29.9 KB ID:	1535804

    Here's the exported code:
    Code:
    [
    {
    "id": "a479ee8e8edc540e",
    "type": "tab",
    "label": "Temp05",
    "disabled": false,
    "info": "",
    "env": []
    },
    {
    "id": "20352579271c9d55",
    "type": "serial in",
    "z": "a479ee8e8edc540e",
    "name": "USB0",
    "serial": "ab715bde7f817d82",
    "x": 90,
    "y": 480,
    "wires": [
    [
    "cf7967b86ac55e05"
    ]
    ]
    },
    {
    "id": "cf7967b86ac55e05",
    "type": "string",
    "z": "a479ee8e8edc540e",
    "name": "Get Sensor ID",
    "methods": [
    {
    "name": "startsWith",
    "params": [
    {
    "type": "str",
    "value": "Sensor"
    }
    ]
    },
    {
    "name": "toString",
    "params": []
    },
    {
    "name": "replaceAll",
    "params": [
    {
    "type": "str",
    "value": "true"
    },
    {
    "type": "msg",
    "value": "payload"
    }
    ]
    },
    {
    "name": "getRightMost",
    "params": [
    {
    "type": "str",
    "value": "#"
    }
    ]
    },
    {
    "name": "getLeftMost",
    "params": [
    {
    "type": "str",
    "value": "["
    }
    ]
    },
    {
    "name": "replaceAll",
    "params": [
    {
    "type": "str",
    "value": "false"
    },
    {
    "type": "str",
    "value": "99"
    }
    ]
    }
    ],
    "prop": "payload",
    "propout": "sensor_id",
    "object": "msg",
    "objectout": "msg",
    "x": 240,
    "y": 480,
    "wires": [
    [
    "0c57b8750c8df218"
    ]
    ]
    },
    {
    "id": "6a680e1c982d937a",
    "type": "debug",
    "z": "a479ee8e8edc540e",
    "name": "",
    "active": false,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 810,
    "y": 400,
    "wires": []
    },
    {
    "id": "0c57b8750c8df218",
    "type": "string",
    "z": "a479ee8e8edc540e",
    "name": "Get Sensor Value",
    "methods": [
    {
    "name": "startsWith",
    "params": [
    {
    "type": "str",
    "value": "Sensor"
    }
    ]
    },
    {
    "name": "toString",
    "params": []
    },
    {
    "name": "replaceAll",
    "params": [
    {
    "type": "str",
    "value": "true"
    },
    {
    "type": "msg",
    "value": "payload"
    }
    ]
    },
    {
    "name": "getRightMost",
    "params": [
    {
    "type": "str",
    "value": "="
    }
    ]
    },
    {
    "name": "delRightMost",
    "params": [
    {
    "type": "str",
    "value": "F"
    }
    ]
    },
    {
    "name": "replaceAll",
    "params": [
    {
    "type": "str",
    "value": "false"
    },
    {
    "type": "str",
    "value": "99"
    }
    ]
    }
    ],
    "prop": "payload",
    "propout": "sensor_value",
    "object": "msg",
    "objectout": "msg",
    "x": 450,
    "y": 480,
    "wires": [
    [
    "8a8fe621c6b43892"
    ]
    ]
    },
    {
    "id": "95b79aa0bb97ef1d",
    "type": "switch",
    "z": "a479ee8e8edc540e",
    "name": "Select HS Device",
    "property": "sensor_id",
    "propertyType": "msg",
    "rules": [
    {
    "t": "eq",
    "v": "01",
    "vt": "str"
    },
    {
    "t": "eq",
    "v": "02",
    "vt": "str"
    },
    {
    "t": "eq",
    "v": "03",
    "vt": "str"
    },
    {
    "t": "eq",
    "v": "04",
    "vt": "str"
    },
    {
    "t": "eq",
    "v": "05",
    "vt": "str"
    },
    {
    "t": "eq",
    "v": "99",
    "vt": "str"
    }
    ],
    "checkall": "true",
    "repair": false,
    "outputs": 6,
    "x": 870,
    "y": 480,
    "wires": [
    [
    "c9226998c25bf48c"
    ],
    [
    "60742eb1d40cda7c"
    ],
    [
    "289c816e9ef4e9c5"
    ],
    [
    "b54553e73fd54b2a"
    ],
    [
    "15adf992e3013805"
    ],
    []
    ]
    },
    {
    "id": "8a8fe621c6b43892",
    "type": "change",
    "z": "a479ee8e8edc540e",
    "name": "Prep HS Msg",
    "rules": [
    {
    "t": "delete",
    "p": "payload",
    "pt": "msg"
    },
    {
    "t": "set",
    "p": "topic",
    "pt": "msg",
    "to": "update",
    "tot": "str"
    },
    {
    "t": "set",
    "p": "payload.value",
    "pt": "msg",
    "to": "sensor_value",
    "tot": "msg"
    },
    {
    "t": "set",
    "p": "payload.status",
    "pt": "msg",
    "to": "sensor_value",
    "tot": "msg"
    }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 660,
    "y": 480,
    "wires": [
    [
    "95b79aa0bb97ef1d",
    "6a680e1c982d937a"
    ]
    ]
    },
    {
    "id": "c9226998c25bf48c",
    "type": "hs-device",
    "z": "a479ee8e8edc540e",
    "name": "Server Rack",
    "device": "59",
    "server": "cca8073e1d5285f1",
    "feature": "60",
    "reportonstartup": false,
    "x": 1130,
    "y": 360,
    "wires": [
    []
    ]
    },
    {
    "id": "60742eb1d40cda7c",
    "type": "hs-device",
    "z": "a479ee8e8edc540e",
    "name": "Front Porch",
    "device": "59",
    "server": "cca8073e1d5285f1",
    "feature": "61",
    "reportonstartup": false,
    "x": 1130,
    "y": 420,
    "wires": [
    []
    ]
    },
    {
    "id": "289c816e9ef4e9c5",
    "type": "hs-device",
    "z": "a479ee8e8edc540e",
    "name": "Attic",
    "device": "59",
    "server": "cca8073e1d5285f1",
    "feature": "62",
    "reportonstartup": false,
    "x": 1110,
    "y": 480,
    "wires": [
    []
    ]
    },
    {
    "id": "b54553e73fd54b2a",
    "type": "hs-device",
    "z": "a479ee8e8edc540e",
    "name": "Backyard",
    "device": "59",
    "server": "cca8073e1d5285f1",
    "feature": "63",
    "reportonstartup": false,
    "x": 1120,
    "y": 540,
    "wires": [
    []
    ]
    },
    {
    "id": "15adf992e3013805",
    "type": "hs-device",
    "z": "a479ee8e8edc540e",
    "name": "Northside",
    "device": "59",
    "server": "cca8073e1d5285f1",
    "feature": "64",
    "reportonstartup": false,
    "x": 1120,
    "y": 600,
    "wires": [
    []
    ]
    },
    {
    "id": "ab715bde7f817d82",
    "type": "serial-port",
    "serialport": "/dev/ttyUSB0",
    "serialbaud": "9600",
    "databits": "8",
    "parity": "none",
    "stopbits": "1",
    "waitfor": "",
    "dtr": "none",
    "rts": "none",
    "cts": "none",
    "dsr": "none",
    "newline": "\\n",
    "bin": "false",
    "out": "char",
    "addchar": "",
    "responsetimeout": "10000"
    },
    {
    "id": "cca8073e1d5285f1",
    "type": "hs-server",
    "name": "HS4Pi",
    "host": "172.29.1.17",
    "port": "80"
    }
    ]
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    #2
    Nice! Short, sweet, concise, and it does all you need. Are you saving the data for graphing to watch trends or anything? I know HomeSeer has the capability. I set up InfluxDB with Node-RED integration and Grafana for the actual charting to do some, but admit that I really never look at the data anymore. It was nice at first but now it is just a "Hey, look! I can do this!" Others do have needs, but for me the biggest use has been to see if a new event or flow are doing what they are supposed to. Any thoughts to use the data from here for anything else?
    Karl S
    HS4Pro on Windows 10
    1070 Devices
    56 Z-Wave Nodes
    104 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

    Comment


      #3
      Thanks. I try to keep things clean and concise so I don't have to spend an hour figuring it out when I want to make a change or fix something.

      Yes, I use mcsMQTT to save HS device values into InfluxDB and Grafana to visualize. I haven't done any Node-RED integration with InfluxDB but it's on my list. That's mostly for fun but now that I've added a whole house power monitor and a bunch of Sonoff S31 power modules, I'm using it more and more to understand our energy usage. Considering a Tesla PowerWall.

      I also use these sensor readings along with some indoor sensors (Z-Wave) to set indicators of when it's getting hotter outside vs. inside and when it's cooler outside vs. inside. These indictors tell us when to close or open the windows instead of running the A/C. I also factor PurpleAir AQI into the indicators during fire season.
      "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

      Comment

      Working...
      X