MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-xiaomi - Temperature and Humidity from your smarthome

    Scheduled Pinned Locked Moved Utilities
    141 Posts 27 Posters 217.6k Views 27 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      mirko3000
      last edited by mirko3000

      Description

      Hi guys,

      just made a small module to display temperature and humidity from your Xiaomi smarthome sensors. Pretty basic so far, but hugely helpful to me to monitor heating and ventilation (humidity!).

      Screenshots

      Sensors look like this and cost around 8 €:
      alt text

      Here a sample from the module:
      alt text

      Download

      [card:mirko3000/MMM-xiaomi]

      1 Reply Last reply Reply Quote 2
      • cowboysdudeC Offline
        cowboysdude Module Developer
        last edited by cowboysdude

        Good call… that company is going to be making a ton of smart things! :) Great job.

        Do you have a link to the module?

        1 Reply Last reply Reply Quote 0
        • B Offline
          barnosch
          last edited by barnosch

          Great. Looking forward for the module…
          Meanwhile i order some of the Xiaomi stuff in China ;)

          1 Reply Last reply Reply Quote 1
          • C Offline
            cxlwill
            last edited by

            Great work. But mine keeps looking for gateway. I’m pretty sure that the ip of GW is correct.

            1 Reply Last reply Reply Quote 0
            • M Offline
              mirko3000
              last edited by

              Sorry, forgot about the link:
              https://github.com/mirko3000/MMM-xiaomi

              @barnosch, @cxlwill: Did you check the logs? Anything showing up there?

              cowboysdudeC 1 Reply Last reply Reply Quote 1
              • M Offline
                mirko3000
                last edited by

                Also it only supports xiaomi temperature sensors, so if you don’t have any registered on your gateway it will not show anything (Keeping in “Connecting to gateway…” mode).

                C 1 Reply Last reply Reply Quote 0
                • cowboysdudeC Offline
                  cowboysdude Module Developer @mirko3000
                  last edited by cowboysdude

                  @mirko3000 Thank you for this!! Exactly what I have been looking for… this is truly awesome!

                  I would like about 9 of these sensors… do I also need the gateway as well?

                  B 1 Reply Last reply Reply Quote 0
                  • B Offline
                    barnosch @cowboysdude
                    last edited by

                    @cowboysdude : As i read, the Gateway is mandatory.
                    But as always Xiaomi is really cheap. GW is about 25$ i guess.

                    I ordered some temp sensors. Can’t wait to test the stuff.

                    cowboysdudeC 1 Reply Last reply Reply Quote 1
                    • C Offline
                      cxlwill @mirko3000
                      last edited by

                      @mirko3000 Well, I have temp&hum sensor and it works well with Home Assistant and Homebridge. So I think the API itself is OK. I will check the log. Nice plugin anyway. Maybe we can extend it to more Xiaomi devices.

                      1 Reply Last reply Reply Quote 0
                      • cowboysdudeC Offline
                        cowboysdude Module Developer @barnosch
                        last edited by

                        @barnosch said in MMM-xiaomi - Temperature and Humidity from your smarthome:

                        @cowboysdude : As i read, the Gateway is mandatory.
                        But as always Xiaomi is really cheap. GW is about 25$ i guess.

                        I ordered some temp sensors. Can’t wait to test the stuff.

                        I saw the gateway was inexpensive so if I can find a US plug adapter for this I will be ordering the gateway and about 9 of the temp sensors :)

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          Albert2002
                          last edited by

                          How to figure out the id of the sensor?

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            mirko3000
                            last edited by

                            Well the IDs show up in your magic mirror - the problem is to identify which ID belongs to which sensor. I guessed them by checking the temperature, still I agree that this is not very convenient so far. Looking out for a better solution…

                            1 Reply Last reply Reply Quote 0
                            • A Offline
                              Albert2002
                              last edited by

                              Thank you for your replay!

                              When I do so I get a “Connecting to XIAOMI gatway…”
                              Connecting to XIAOMI gatway..

                              As far as I understand "ENETUNREACH " means Network unreachable. I can successfully ping the Gatway at 192.168.2.107 via VNC & LX Terminal.
                              Do I have to set up something on my Gateway first?
                              Any idea what to do?

                              This is what my error log says:

                              ERROR! Could not find main module js file for RepositoryForRC
                              ERROR! Could not find main module js file for async
                              { Error: send ENETUNREACH 192.168.2.107:54321
                                  at Object.exports._errnoException (util.js:1050:11)
                                  at exports._exceptionWithHostPort (util.js:1073:20)
                                  at SendWrap.afterSend [as oncomplete] (dgram.js:402:11)
                                code: 'ENETUNREACH',
                                errno: 'ENETUNREACH',
                                syscall: 'send',
                                address: '192.168.2.107',
                                port: 54321 }
                              

                              My mm out:

                              Starting MagicMirror: v2.1.3
                              Loading config ...
                              Loading module helpers ...
                              No helper found for module: alert.
                              No helper found for module: clock.
                              Initializing new module helper ...
                              Module helper loaded: MMM-Remote-Control
                              Initializing new module helper ...
                              Module helper loaded: MMM-xiaomi
                              All module helpers loaded.
                              Starting server on port 8080 ... 
                              Server started ...
                              Connecting socket for: MMM-Remote-Control
                              Starting node helper for: MMM-Remote-Control
                              Connecting socket for: MMM-xiaomi
                              Starting xiaomi helper
                              Sockets connected & modules started ...
                              Launching application.
                              Triggering Xiaomi Gateway upate
                              
                              1 Reply Last reply Reply Quote 0
                              • A Offline
                                Albert2002
                                last edited by

                                I’ve made a completely new Raspian & MM installation. No other modules installed. the default modules disabled in the config.js.

                                I Still get no connection. Im running the Home Gatewy V3 in Dev mode. Do I have to change any settings on my router or somewhere else?

                                Right now I get different error messages. Maybe it helps. I would love to see this module running!

                                mm-out:

                                > magicmirror@2.1.3 start /home/pi/MagicMirror
                                > sh run-start.sh
                                
                                Starting MagicMirror: v2.1.3
                                Loading config ...
                                Loading module helpers ...
                                Initializing new module helper ...
                                Module helper loaded: MMM-xiaomi
                                All module helpers loaded.
                                Starting server on port 8080 ... 
                                You're using a full whitelist configuration to allow for all IPs
                                Server started ...
                                Connecting socket for: MMM-xiaomi
                                Starting xiaomi helper
                                Sockets connected & modules started ...
                                Whoops! There was an uncaught exception...
                                MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
                                If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
                                Launching application.
                                

                                MagicMirror error log:

                                Error: Token could not be auto-discovered
                                    at Device._tokenResolve (/home/pi/MagicMirror/modules/MMM-xiaomi/node_modules/miio/lib/device.js:141:13)
                                    at Device._onMessage (/home/pi/MagicMirror/modules/MMM-xiaomi/node_modules/miio/lib/device.js:80:9)
                                    at emitTwo (events.js:106:13)
                                    at Socket.emit (events.js:194:7)
                                    at UDP.onMessage [as onmessage] (dgram.js:545:8)
                                

                                MagicMirror out:

                                 magicmirror@2.1.3 start /home/pi/MagicMirror
                                > sh run-start.sh
                                
                                Starting MagicMirror: v2.1.3
                                Loading config ...
                                Loading module helpers ...
                                Initializing new module helper ...
                                Module helper loaded: MMM-xiaomi
                                All module helpers loaded.
                                Starting server on port 8080 ... 
                                You're using a full whitelist configuration to allow for all IPs
                                Server started ...
                                Connecting socket for: MMM-xiaomi
                                Starting xiaomi helper
                                Sockets connected & modules started ...
                                Launching application.
                                Triggering Xiaomi Gateway upate
                                Triggering Xiaomi Gateway upate
                                

                                mm error log:

                                { Error: listen EADDRINUSE 127.0.0.1:8080
                                    at Object.exports._errnoException (util.js:1050:11)
                                    at exports._exceptionWithHostPort (util.js:1073:20)
                                    at Server.setupListenHandle [as _listen2] (net.js:1263:14)
                                    at listenInCluster (net.js:1304:12)
                                    at doListen (net.js:1428:7)
                                    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
                                    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:10)
                                  code: 'EADDRINUSE',
                                  errno: 'EADDRINUSE',
                                  syscall: 'listen',
                                  address: '127.0.0.1',
                                  port: 8080 }
                                
                                
                                1 Reply Last reply Reply Quote 0
                                • M Offline
                                  mirko3000
                                  last edited by

                                  Hey Albert,

                                  I think I have solved your issue: not all gateways seem to allow auto-discovery without authentification via a security token. I have added an additional configuration parameter now where you can provide your token:
                                  https://github.com/mirko3000/MMM-xiaomi

                                  Update the module and follow the description at the bottom:
                                  https://github.com/mirko3000/MMM-xiaomi#authentification

                                  Hope that works.

                                  Best regards.

                                  1 Reply Last reply Reply Quote 1
                                  • A Offline
                                    Albert2002
                                    last edited by

                                    Hi Mirko,

                                    thank you for your work! I really appreciate this!

                                    I’ve updated the module and installed the miio command line tools (with sudo)in the same directory. Or do I Have to install the miio command line tools in a different directory?
                                    How ever, when am running miio command line tools i get

                                    pi@raspberrypi:~/MagicMirror/modules/MMM-xiaomi $ miio --discover
                                     INFO  Discovering devices. Press Ctrl+C to stop.
                                    
                                    Device ID: 52238776
                                    Model info: Unknown 
                                    Address: 192.168.2.107 
                                    Token: ???
                                    Support: Unknown
                                    
                                    

                                    My id I’ve discovered seams to be a different style then the one in your example.
                                    After this I added the device id to my config:

                                    devices: [{ id: '52238776', name: 'Wohnzimmer' }]
                                    
                                    

                                    I still see the same as before.

                                    mm error:

                                    Error: Token could not be auto-discovered
                                        at Device._tokenResolve (/home/pi/MagicMirror/modules/MMM-xiaomi/node_modules/miio/lib/device.js:141:13)
                                        at Device._onMessage (/home/pi/MagicMirror/modules/MMM-xiaomi/node_modules/miio/lib/device.js:80:9)
                                        at emitTwo (events.js:106:13)
                                        at Socket.emit (events.js:194:7)
                                        at UDP.onMessage [as onmessage] (dgram.js:545:8)
                                    

                                    mm-out:

                                    
                                    > magicmirror@2.1.3 start /home/pi/MagicMirror
                                    > sh run-start.sh
                                    
                                    Starting MagicMirror: v2.1.3
                                    Loading config ...
                                    Loading module helpers ...
                                    Initializing new module helper ...
                                    Module helper loaded: MMM-xiaomi
                                    All module helpers loaded.
                                    Starting server on port 8080 ... 
                                    You're using a full whitelist configuration to allow for all IPs
                                    Server started ...
                                    Connecting socket for: MMM-xiaomi
                                    Starting xiaomi helper
                                    Sockets connected & modules started ...
                                    Launching application.
                                    Triggering Xiaomi Gateway upate
                                    Triggering Xiaomi Gateway upate
                                    
                                    

                                    MagicMirror error:

                                    { Error: listen EADDRINUSE 127.0.0.1:8080
                                        at Object.exports._errnoException (util.js:1050:11)
                                        at exports._exceptionWithHostPort (util.js:1073:20)
                                        at Server.setupListenHandle [as _listen2] (net.js:1263:14)
                                        at listenInCluster (net.js:1304:12)
                                        at doListen (net.js:1428:7)
                                        at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
                                        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:10)
                                      code: 'EADDRINUSE',
                                      errno: 'EADDRINUSE',
                                      syscall: 'listen',
                                      address: '127.0.0.1',
                                      port: 8080 }
                                    

                                    MagicMirror out:

                                    
                                    > magicmirror@2.1.3 start /home/pi/MagicMirror
                                    > sh run-start.sh
                                    
                                    Starting MagicMirror: v2.1.3
                                    Loading config ...
                                    Loading module helpers ...
                                    Initializing new module helper ...
                                    Module helper loaded: MMM-xiaomi
                                    All module helpers loaded.
                                    Starting server on port 8080 ... 
                                    You're using a full whitelist configuration to allow for all IPs
                                    Server started ...
                                    Connecting socket for: MMM-xiaomi
                                    Starting xiaomi helper
                                    Sockets connected & modules started ...
                                    Whoops! There was an uncaught exception...
                                    MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
                                    If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
                                    Launching application.
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • B Offline
                                      barnosch
                                      last edited by barnosch

                                      God damnit.
                                      Got a letter from the customs today, that my package from China arrived.
                                      Sadly they are closing Fridays at 2.30pm. The letter arrived at 2.45pm.
                                      So no chance to fetch it anymore.

                                      The whole weekend is now useless!

                                      Let`s see if i have also trouble …

                                      1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        Albert2002
                                        last edited by

                                        Maybe you can get it tomorrow? Would be great to figure out.

                                        Something crossed my mind. When I set up the Developer mode in the Gateway there is a password too. I know that I need this one for OpenHAB. Maybe I need it for this module as well?

                                        M 1 Reply Last reply Reply Quote 0
                                        • M Offline
                                          mirko3000 @Albert2002
                                          last edited by

                                          So I just read through the documentation of miio and found this:
                                          https://github.com/aholstenson/miio/blob/master/docs/management.md#getting-the-token-of-a-device
                                          or:
                                          https://github.com/aholstenson/miio/blob/master/docs/management.md#setting-the-token-of-a-device

                                          My device seems to provide the token “via auto-token”, in your case it seems it does not. Maybe try either of the above.

                                          IDs are same with me, maybe my documentation is wrong here.

                                          1 Reply Last reply Reply Quote 0
                                          • M Offline
                                            mirko3000
                                            last edited by

                                            When I run the discover tool I get the following:

                                            Device ID: 56804143
                                            Model info: Unknown 
                                            Address: 192.168.0.9 (xiaomi-gateway.fritz.box)
                                            Token: cfbdb315c0825ccc971918e36923febe via auto-token
                                            Support: Unknown
                                            
                                            Device ID: 158d0001635bb3
                                            Model info: lumi.sensor_ht (sensor)
                                            Address: Owned by 56804143
                                            Token: Automatic via parent device
                                            Support: At least basic
                                            
                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 8
                                            • 1 / 8
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy