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 195.8k 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.
    • 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
              • A Offline
                Albert2002
                last edited by

                I am a step ahead!

                I followed the instructions to get the token “Getting the token when using the Mi Home app”
                This was working. I could see all the connected devices to the Gateway.

                pi@raspberrypi:~/MagicMirror/modules/MMM-xiaomi $ miio --discover --sync
                 INFO  Discovering devices. Press Ctrl+C to stop.
                
                Device ID: 52238776
                Model info: Unknown 
                Address: 192.168.13.1 
                Token: 6eea5ac1eb475bfedbfff98aab7c2bc7 via auto-token
                Support: Unknown
                
                Device ID: 158d000119fcb2
                Model info: lumi.magnet (magnet)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00013e28ee
                Model info: lumi.plug (power-plug)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00015aa973
                Model info: lumi.switch (controller)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00015736a8
                Model info: lumi.sensor_ht (sensor)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                

                At this point I had to switch over to the Pi with the installed MagicMirror:

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

                I’ve updated the Token as described:

                pi@MagicMirror:~ $ miio --update 52238776 --token 6eea5ac1eb475bfedbfff98aab7c2bc7
                 INFO  Attempting to update 52238776
                 INFO  Device updated
                

                I’ve searched for devices again. Now with success!

                
                pi@MagicMirror:~ $ miio --discover
                
                 INFO  Discovering devices. Press Ctrl+C to stop.
                
                Device ID: 52238776
                Model info: Unknown 
                Address: 192.168.2.107 
                Token: 6eea5ac1eb475bfedbfff98aab7c2bc7 via stored token
                Support: Unknown
                
                Device ID: 158d000119fcb2
                Model info: lumi.magnet (magnet)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00013e28ee
                Model info: lumi.plug (power-plug)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00015aa973
                Model info: lumi.switch (controller)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                Device ID: 158d00015736a8
                Model info: lumi.sensor_ht (sensor)
                Address: Owned by 52238776
                Token: Automatic via parent device
                Support: At least basic
                
                

                The problem so far is, that I still don’t get any informations visible in MM. I’ve tried ‘158d00015736a8’ and as well ‘52238776’ as id.
                The second problem is, that I’ve lost the Gateway in my Mi Home app after updating the Token!

                The question is, how to copy ( Store?) over the Token to a different Machine?

                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)
                
                1 Reply Last reply Reply Quote 0
                • M Offline
                  mirko3000
                  last edited by mirko3000

                  Ok at least some progress. So first to enable your manual token just update the configuration:

                  config: {
                  	 interval: 30,
                  	 gatewayIP: '192.168.13.1',
                  	 gatewayToken: '6eea5ac1eb475bfedbfff98aab7c2bc7',
                  	 devices : [{
                  	     id: '158d00015736a8',
                  	     name: 'MyRoom1'
                  	 }]
                  }
                  

                  You only need the IDs from your sensors, not the gateway.

                  About the Mi Home App and your lost token, I would try once this works to reconfigure your gateway with the Mi Home app, and then try to fetch the auto-token again (in your first sample it seems to provide auto-token).

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

                    I did the steps again to get the (new) Token. Now, I have a new Token and the Gateway again in my Mi Home app. I didn’t updated the Token on the different machine this time.

                    I’ve tried out your new config. I still don’t see more than before on the MM, but I don’t have an error log as well, which make it a bit more harder.

                    I have checked the IP address of the Gateway, its still the same. Dev is still enabled.

                    My config with the new Token.

                    		{
                    		module: 'MMM-xiaomi',
                    		position: 'bottom_left',
                    		header: 'Temperatur / Feuchtigkeit',  // This is optional
                    		config: {
                    			interval: 30,
                    			gatewayIP: '192.168.2.107',
                    			gatewayToken: '050591e66a82f7adc92bfa6b03058cdb',
                    			devices: [{ id: '158d00015736a8', name: 'Wohnzimmer' }]
                    			// See 'Configuration options' for more information.
                    				}
                    		},
                    

                    Edit:

                    I get a error when I try to discover with miio:

                    pi@MagicMirror:~/MagicMirror/modules/MMM-xiaomi/node_modules/miio $ miio --discover
                     INFO  Discovering devices. Press Ctrl+C to stop.
                    
                    Device ID: 52238776
                    Model info: Unknown 
                    Address: 192.168.2.107 
                    Token: 6eea5ac1eb475bfedbfff98aab7c2bc7 via stored token
                    Support: Unknown
                    
                    (node:3626) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Call to device timed out
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      Albert2002
                      last edited by

                      Where did miio stored the Token?
                      The Token Miio used “Token: 6eea5ac1eb475bfedbfff98aab7c2bc7 via stored token”
                      is the old one! the new one is 050591e66a82f7adc92bfa6b03058cdb

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

                        Hmm not sure about miio details, I just know that you can sync the tokens via

                        miio --discover --sync
                        

                        Else I would try manually setting to the correct (new) token.
                        For the MM: try to uncomment line 51 in node_helper.js, this logs all found devices. You could also add some more logs here to see where the program fails.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 14
                        • 15
                        • 2 / 15
                        • 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