Announcement

Collapse
No announcement yet.

mcsMQTT and RPi 1-Wire hub

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

  • mcsMQTT and RPi 1-Wire hub

    Here over the years have used 1-wire sensors (well since the 1990's).

    Last HS2 configuration utilized 3 Temp-08's and 1 Temp-05 plus one USB 9097 with all of the cabling done with cat5x home run to the basement. It was done in a star fashion as suggested way long time ago. That changed over the years here. Along with said 1-wire networks here utilized xAP.

    Fast forward to now...and using extra RPi's. Some of the Homeseer 3 work today is being done by other computers (RPi) which forward data to the main mothership.

    Trying to keep it simple here went with one RPi in the attic using a USB Maxim 9097U and connecting it to a few temperature and temperature humidity sensors in the second floor. This 1-wire hub is using Digitemp which write a text file every few minutes which is read by a HS3 script which converts the data to HS3 variables. (thank you Rob). Roots of said script are a simple read of the CPU temperature of the RPi.

    A new endeavor as of yesterday. I built a new RPi 1-wire temperature - sensor hub with a collection of old AAG, Midon and Hobby boards combo sensors and temperature sensors. I have a few extra RPi's around and many 1-wire sensors.

    Step 1

    Installed OWFS and Digitemp to have a look see at the sensors connected to a USB 9097U. Here using 22/4 or 22/2 alarm cable instead of catXX.
    (apt-get install owfs and apt-get install digitemp then adjust configuration files).

    Mini-Network read (from workbench).

    Stretch175:/opt/digitemp# ./digitemp.sh
    10A04713000800D9 : DS1820/DS18S20/DS1920 Temperature Sensor
    10AE56130008007B : DS1820/DS18S20/DS1920 Temperature Sensor
    10A147E900080084 : DS1820/DS18S20/DS1920 Temperature Sensor
    10F197E101080043 : DS1820/DS18S20/DS1920 Temperature Sensor
    104B5613000800B9 : DS1820/DS18S20/DS1920 Temperature Sensor
    265CD3F1000000DC : DS2438 Temperature, A/D Battery Monitor
    2606157500000054 : DS2438 Temperature, A/D Battery Monitor
    ROM #0 : 10A04713000800D9
    ROM #1 : 10AE56130008007B
    ROM #2 : 10A147E900080084
    ROM #3 : 10F197E101080043
    ROM #4 : 104B5613000800B9
    ROM #5 : 265CD3F1000000DC
    ROM #6 : 2606157500000054
    Mar 09 07:00:48 Sensor 0 C: 21.19 F: 70.14
    Mar 09 07:00:49 Sensor 1 C: 21.31 F: 70.36
    Mar 09 07:00:50 Sensor 2 C: 21.00 F: 69.80
    Mar 09 07:00:51 Sensor 3 C: 21.25 F: 70.25
    Mar 09 07:00:53 Sensor 4 C: 20.81 F: 69.46
    Mar 09 07:00:53 Sensor 5 C: 21.00 F: 69.80 H: 45%
    Mar 09 07:00:54 Sensor 6 C: 20.69 F: 69.24 H: 48%

    Step 2 here installed Node Red. It's a one script install

    bash <(curl -sL hxxps://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)


    Node-RED is a flow-based development tool developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things.

    Node-RED provides a browser-based flow editor, which can be used to create JavaScript functions. Elements of applications can be saved or shared for re-use. The runtime is built on Node.js. The flows created in Node-RED are stored using JSON. Since version 0.14 MQTT nodes can make properly configured TLS connections.

    In 2016, IBM contributed Node-RED as an open source JS Foundation project.

    node-red -v
    9 Mar 07:03:32 - [info]

    Welcome to Node-RED
    ===================

    9 Mar 07:03:32 - [info] Node-RED version: v0.18.4
    9 Mar 07:03:32 - [info] Node.js version: v8.10.0
    9 Mar 07:03:32 - [info] Linux 4.9.59-v7+ arm LE
    9 Mar 07:03:34 - [info] Loading palette nodes
    9 Mar 07:03:39 - [info] Settings file : /root/.node-red/settings.js
    9 Mar 07:03:39 - [info] User directory : /root/.node-red
    9 Mar 07:03:39 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
    9 Mar 07:03:39 - [info] Flows file : /root/.node-red/flows_ICS-Stretch175.json
    9 Mar 07:03:39 - [info] Creating new flow file


    Stretch175:/opt/digitemp# npm -v
    5.6.0

    Step-3

    Next is learning the node-red graphical design interface. What is interesting is that you can start with node-red importing a flow as I have done here.

    [ATTACH]67344[/ATTACH]
    Last edited by Pete; March 9th, 2018, 08:18 AM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
    Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

  • #2
    Hi Pete,

    This npm package node-red-contrib-alexa-home have been update recently.
    ( need "version": "0.3.4" )

    One of its fonction is to give you the ip adress of the alexa device you used to call the device.

    I tried it, and it always gives me the same alexa device ip when i call the device with another alexa. if i create a new device and restart node-red, the ip change to another alexa device ip... but remains the same if i use another alexa.

    You surely have more experience with node-red than me. If you have time, would you be able to try this ?

    Thanks matt

    Comment


    • #3
      Yeah have no clue how to use node red yet....just tinkering...that said installed node-red-contrib-alexa-home

      ~/.node-red $ npm install node-red-contrib-alexa-local
      npm WARN node-red-project@0.0.1 No repository field.
      npm WARN node-red-project@0.0.1 No license field.

      + node-red-contrib-alexa-local@0.3.12
      added 13 packages in 7.594s
      Stretch175:~/.node-red $ npm install node-red-contrib-alexa-home
      npm WARN node-red-project@0.0.1 No repository field.
      npm WARN node-red-project@0.0.1 No license field.

      + node-red-contrib-alexa-home@0.3.4
      added 1 package in 4.841s
      Stretch175:~/.node-red $

      [ATTACH]67345[/ATTACH]
      Last edited by Pete; March 9th, 2018, 04:28 PM.
      - Pete

      Auto mator
      Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
      Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

      X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

      Comment


      • #4
        OK...was able to add a new device here using node-red-contrib-alexa-local and node-red-contrib-alexa-local using discover new devices via Alexa and via Alexa on Amazon.

        node-red-contrib-alexa-XXX is for Philips Hue devices.

        This topic / rednode Alexa stuff probably should be in it's own sub forum post...just do not know where...here getting back to the 1-wire stuff...

        Here goofing a bit with a combo OmniPro 2 panel / Smartthings hub / Alexa echo thing...this is totally autonomous from the HS3 Alexa stuff.

        [ATTACH]67356[/ATTACH]

        [ATTACH]67356[/ATTACH]
        Attached Files
        Last edited by Pete; March 10th, 2018, 09:52 AM.
        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
        Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

        Comment


        • #5
          I was able to connect to my OWFS 1-wire stuff with node red.....now at the point of sending MQTT messages then sending MQTT messages for all of the 1-wire devices connected to the RPi.

          [ATTACH]67370[/ATTACH]
          [ATTACH]67371[/ATTACH]

          Plugin is working.

          [ATTACH]67361[/ATTACH]

          Learning mode now...initial refresh of all devices is a tad slow...

          I want to filter only on my RPi Node Red device and see nothing else.

          [ATTACH]67362[/ATTACH]
          Last edited by Pete; March 10th, 2018, 06:08 PM.
          - Pete

          Auto mator
          Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
          Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

          X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

          Comment


          • #6
            Updated this morning to Version 3.1.0.0. Pointed it to my RPi / 1-wire Node Red and saw my stuff within seconds.

            Working on a new flow...

            [ATTACH]67514[/ATTACH]
            - Pete

            Auto mator
            Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
            Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

            X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

            Comment


            • #7
              HomeSeer Version: HS3 Pro Edition 3.0.0.368, Operating System: Microsoft Windows 10 - Home, Number of Devices: 373, Number of Events: 666, Enabled Plug-Ins
              2.0.83.0: BLRF, 2.0.10.0: BLUSBUIRT, 3.0.0.75: HSTouch Server, 3.0.0.58: mcsXap, 3.0.0.11: NetCAM, 3.0.0.36: X10, 3.0.1.25: Z-Wave,Alexa,HomeKit

              Comment


              • #8
                Hello Steve,

                Yes here did xAP and xPL around HS2 times mostly for 1-wire sensors. Used multiple 1-wire networks here connected to a temp05, temp08's and USB 9097s (Maxim).

                I switched to Linux with use of Homeseer 3. The MQTT plugin looks very similiar to xAP and the GUI is the same in Windows or Linux.

                Here in the beginning of HS3 / Linux started to tinker with Raspberry Pi's. They are small footprint computers which run Linux.

                I have one POE RPi in the attic which originally was a ZNet like device for ZWave.

                DIY stuff with the Raspberry Pi is plug n play and easy. You should get familiar with Linux. Many folks here are using RPi's and if you have questions just ask.

                Last year plugged a USB 9097U in to the RPi ZNet like device in the attic. I connected a few 2nd floor temperature and humidity sensors to the USB 9097U and using OWFS and DigiTemp. Basically here Digitemp writes a text file with temperatures and humidity stuff directly on to the HS3 /data directory box in the basement. A VB script reads the text file and creates variables from it. I consider this long math way because you have to make changes to the VB if you want to add sensors.

                Added MQTT and Node Red to the attic RPi. Still getting used to Node Red and specifically the OWFS "plugins". I have it working now and just have an issue that it is writing centigrade versus Fahrenheit. It is just a flag to change and while I have changed OWFS to Fahrenheit. The Node Red designer application if very intuitive. Really just build a flow and it starts to broadcast right away. Then on the HS3 side I just put the IP of the the RPi in the attic and I was good to go. Built a new RPi test network in the basement using stretch. This one is only doing the 1-wire network, MTQQ and Node Red.

                The Arduino is a microcontroller with a uploaded flash program (very much C). You can upload a sketch to it in Windows and there really is no need for knowing any Linux to use it. It's just a USB cable from the Arduino to a Windows computer and using the arduino programming too. It is way different than an RPi. It is tiny and more of a single purpose microcontroller like the Sonoff switches you purchased.

                Fast forward to Michael's MQTT plugin. First time I ran it it appeared identical to the xAP set up and was plug n play for me to configure.

                Personally test drive the mcsMQTT plugin and see how the show fits. You already know the xAP plugin such that the MQTT plugins is almost the same stuff. Michael has made the initial screen loads (configuration way faster than what you see in xAP today).
                - Pete

                Auto mator
                Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
                Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

                X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                Comment


                • #9
                  Hi Pete,

                  I did something really similar, but instead rolled my own python service using owfs to do my heavy lifting for me:
                  https://github.com/mloebl/mqtt-owfs-temp

                  Basically has a csv of the IDs from Owserver and the device type, then pumps them out to MQTT. Been using it for a couple of years, and super stable.

                  EDIT: Runs as a service, no NodeRed needed I found someone had done something similar but they lost interest; I forked/updated it.

                  -Mike
                  Last edited by mloebl; March 18th, 2018, 04:39 PM.

                  Comment


                  • #10
                    HomeSeer Version: HS3 Pro Edition 3.0.0.368, Operating System: Microsoft Windows 10 - Home, Number of Devices: 373, Number of Events: 666, Enabled Plug-Ins
                    2.0.83.0: BLRF, 2.0.10.0: BLUSBUIRT, 3.0.0.75: HSTouch Server, 3.0.0.58: mcsXap, 3.0.0.11: NetCAM, 3.0.0.36: X10, 3.0.1.25: Z-Wave,Alexa,HomeKit

                    Comment


                    • #11
                      Thank you Mike.

                      Going to give your script a try....have not shelved the APRS stuff - time seems shorter these days

                      Meanwhile here configured the node red stuff to output in Fahrenheit versus centigrade and it is working now for one sensor.

                      What it looks like on HS...

                      [ATTACH]67883[/ATTACH]

                      What the flow looks like (still a bit kludgey to me)

                      [ATTACH]67884[/ATTACH]

                      Debug looks like:

                      4/4/2018, 8:37:57 AMnode: 10.A04713000800/temperature10.A04713000800/temperature : msg.payload : number
                      71.9
                      4/4/2018, 8:38:06 AMnode: 10.A04713000800/temperature10.A04713000800/temperature : msg.payload : number
                      70.4

                      Here is the flow I am using. Still not where I want to be with it.

                      Code:
                      [{"id":"ab6c2546.a43be8","type":"inject","z":"6be1d6c0.f7c008","name":"10A04713000800D9","topic":"10.A04713000800/temperature","payload":"temperature","payloadType":"str","repeat":"10","crontab":"","once":true,"onceDelay":"","x":100,"y":440,"wires":[["b84a7b0b.6fb2e8"]]}]
                      Here is the function node for conversion if interested in converting Centigrade to Fahrenheit.
                      1. var tempc = msg.payload;
                      2. tempf = tempc * 9/5 + 32;
                      3. tempf = Math.round(tempf * 10) / 10;
                      4. msg.payload = tempf;
                      5. return msg;


                      [ATTACH]67885[/ATTACH]
                      Last edited by Pete; April 4th, 2018, 08:57 AM.
                      - Pete

                      Auto mator
                      Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
                      Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

                      X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                      Comment


                      • #12
                        Originally posted by Pete View Post
                        Thank you Mike.

                        Going to give your script a try.
                        Nice! Let me know if you have any problems. I also should be able to add any other sensor types pretty easily; I obviously added the ones I needed. I have it on my list to try out Nodered as a lot of different tools out there use it. I've been pretty hooked on MQTT for awhile, so slowly been porting things over using that script generically and customizing as needed (like the APRS and TED1000 ones I wrote.)

                        Here's how I do it; I go to the OWFS web server (or listing at the CLI) and get a list of the devices and their types. I think create a CSV for the python script to read:
                        Code:
                        localhost,4304,10.9D524D010800,temperature
                        localhost,4304,26.8F59A9000000,humidity
                        localhost,4304,26.8F59A9000000,temperature
                        localhost,4304,26.09E39D000000,temperature
                        localhost,4304,26.069B21010000,temperature
                        localhost,4304,26.069B21010000,humidity
                        That will dump like this:
                        Code:
                        /raw/owserver01/1-wire/10.9D524D010800/temperature 56.4125
                        /raw/owserver01/1-wire/26.8F59A9000000/humidity 51.5844
                        /raw/owserver01/1-wire/26.8F59A9000000/temperature 54.55616
                        /raw/owserver01/1-wire/26.09E39D000000/temperature 60.74384
                        /raw/owserver01/1-wire/26.069B21010000/temperature 54.44384
                        /raw/owserver01/1-wire/26.069B21010000/humidity 76.1056
                        I then format thru HS:

                        Comment


                        • #13
                          Thank you Mike.

                          Going to install your script on my first test RPi which is my ZNet device in the attic (and Noaa pics device).

                          Want to see what I can do with the old Hobby Boards lightning sensor which keeps ticking fine today.

                          Well noticed that it appears to be installed on my attic RPi. Not sure when I did this.

                          OK...running it....

                          Here is my owfs directory...

                          ICS-ZNet:/mnt# ls 1wire
                          1D.37C907000000 26.993AF5000000 alarm simultaneous system
                          26.3B3AF5000000 26.B3CA14000000 bus.0 statistics uncached
                          26.8CC814000000 28.CFD8F4020000 settings structure

                          Do not see anything in the csv file...

                          Do not see a log file...

                          Not sure if I have it running...(recently updated this RPi to Stretch).

                          Wierd...do not see it running...

                          ran the python script manually and see:

                          ZNet:/usr/local/mqtt-owfs-temp# python mqtt-owfs-temp.py
                          File "mqtt-owfs-temp.py", line 37
                          192.168.244.169, 4304, /26.8CC814000000/temperature
                          ^
                          SyntaxError: invalid syntax

                          Ahh...see that it is a combo humidity / temperature sensor ..DS2438
                          Last edited by Pete; April 4th, 2018, 09:44 AM.
                          - Pete

                          Auto mator
                          Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
                          Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

                          X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                          Comment


                          • #14
                            Originally posted by Pete View Post
                            Thank you Mike.

                            Going to install your script on my first test RPi which is my ZNet device in the attic (and Noaa pics device).

                            Want to see what I can do with the old Hobby Boards lightning sensor which keeps ticking fine today.
                            My Dad just started playing around with GOES16 decoding and sent me a pic from it this week, holy cow has technology improved...

                            You know, I think I still have that same HB 1wire lighting sensor somewhere put away as I never put it back up after moving. I should check that out. I picked up a MOD-1016 lightning sensor based on the AMS3935 to attach to a Wemos/NodeMCU, but haven't had a chance to yet.

                            I'm currently working on the PMS5003 air quality sensors, FINALLY figured out a bug with the arduino MQTT library causing blocking issues (ignore the outdoor part as testing inside):

                            Comment


                            • #15
                              The satellite stuff got me to tinker (again) with SDR...

                              Here moved the Hobby Boards sensor from the roof to the attic...works fine there in the attic too.

                              Still running the DIY'd to RPi lightning sensor here works but thinking it would work better with a battery outside...
                              - Pete

                              Auto mator
                              Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel CPU - Mono 5.20
                              Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e BeeLink 4Gb BT3 Pro - Mono 5.20

                              X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                              Comment

                              Working...
                              X