Code Monkey home page Code Monkey logo

mmm-postnord's Introduction

MMM-Postnord

Magic Mirror Module - Automatically track and trace PostNords letters, parcels and pallets with your phone number or email

Right now the module only supports incoming parcels. In the future support for tracking outgoing parcels will be included.

Install

  1. Clone repository into ../modules/ inside your MagicMirror folder.
  2. Run npm install inside ../modules/MMM-Postnord/ folder
  3. Add the module to the MagicMirror config

Update

  1. Run git pull inside ../modules/MMM-Postnord/ folder.
  2. Run npm install inside ../modules/MMM-Postnord/ folder

Configuration

modules: [
    ...
    {
        module: "MMM-Postnord",
        position: "bottom_left",
        config: {
            locale: "sv", //Optional, default is 'sv' allowed codes 'en', 'da', 'fi', 'no', 'sv'
            refreshRateMin: "60", //Optional, default is 60 min
            deliveredPackagesCooldown: "24" //Optional, hours a package should be visible until removed, default null always visible.
        }
    }
    ...
]

Setup subscriptions

In order to automatically track letters, parcels and pallets based on your phone number or email you need to retrieve an access token (hash). In order to-do that you need to run attached program called postnord-hash-generator.js after you have performed npm install. Which will create a local subscription database entry for you. You could add multiple phone numbers or emails.

postnord-hash-generator.js

MMM-Postnord uses a local database (db.json) which will contain you subscription information, such as hash, email, phone number, refreshed time etc. In order to run the program you need to navigate to your locale module folder ../modules/MMM-Postnord/. Inside the folder run $ node postnord-hash-generator.js help. You will now see what commands is supported and how you could run the different commands.

Help

Create a new subscription

Run $ node postnord-hash-generator.js new this will prompt you to enter subscription id (supports phone number (example: 46727777777) or email (example: [email protected]), country and language separated by SPACE. Please enter input like 46727777777 SE sv

Subscription input

List subscriptions

Run $ node postnord-hash-generator.js list, this will write out the database. Please ensure your subscription status is VERIFIED if not then please delete your subscription and try again.

Subscription input

Delete subscriptions

Run $ node postnord-hash-generator.js remove, this will prompt you for the subscription id you would like to remove (either email or phone number). Enter the subscription id and press Enter. This will remove the subscription from the database.

Subscription input

Supported languages

Default language is Swedish, but the module support english (en), norwegian (no), danish (da) and finish (fi).

Screenshot

Postnord Module

mmm-postnord's People

Contributors

bureus avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

mmm-postnord's Issues

Included Hash Generator will not run

After git pull and npm install the guide tells you to run node postnord-hash-generator.js help. However, that does not give me the help text needed to go forward, instead it generates an error:
pi@raspberrypi:~/MagicMirror/modules/MMM-Postnord $ node postnord-hash-generator.js help
internal/modules/cjs/loader.js:905
throw err;
^

Error: Cannot find module 'awesome-phonenumber'
Require stack:

  • /home/pi/MagicMirror/modules/MMM-Postnord/postnord-hash-generator.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object. (/home/pi/MagicMirror/modules/MMM-Postnord/postnord-hash-generator.js:5:21)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/pi/MagicMirror/modules/MMM-Postnord/postnord-hash-generator.js'
    ]
    }

deliveredPackagesCooldown configuration causing problems

`WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: /home/pi/MagicMirror/config/config.js:131
                deliveredPackagesCooldown: "3"
                ^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:722:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Module.require (internal/modules/cjs/loader.js:685:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at loadConfig (/home/pi/MagicMirror/js/app.js:70:12)
    at App.start (/home/pi/MagicMirror/js/app.js:217:3)
    at Object.<anonymous> (/home/pi/MagicMirror/js/electron.js:129:7)
    at Module._compile (internal/modules/cjs/loader.js:786:30)`

Unable to configure the plugin for Norway

I am trying to configure the plugin for Norway but somehow, it fails.
I am trying to run "node postnord-hash-generator.js new" with different values as phone number and different values as languate -they all fail with invalid input.
The phone number has been tried in the form "+4740xxxxxx", "004740xxxxxx", "4740xxxxxx" and "40xxxxxx".
For the country, it's obvious - it should be NO.
For the language I have tried with both no and en.

As far as I can tell, there is a validation on 11 digits for the phone number (once it was changed to 10, it will work) - the validation should be based on the country code (11 for Sweden, 10 for Norway, etc.).

postnord-hash-generator.js generate a HTTP 503

pi@raspberrypi:~/MagicMirror/modules/MMM-Postnord $ node postnord-hash-generator.js new

Enter subscriptionId (either phone number example 46702136611 or email example [email protected]), country ('SE', 'NO', 'FI', 'DK') and language ('en', 'sv', 'no', 'da', 'fi'):
4612345678 SE sv
Please wait until you recives a 4 digit code on your email: 4612345678
Type in validation code that you will recive thru SMS or email:

generateSubscription failed: {"name":"StatusCodeError","statusCode":503,"message":"503 - undefined","options":{"method":"POST","uri":"https://appi.postnord.com/rest/customer/v1/identity/register/4612345678?apikey=591aa0cdb8cf85d41fede9b027b1e1c7","headers":{"User-Agent":"PostNord/6.5.2-Android","Connection":"Keep-Alive","Host":"appi.postnord.com","Accept-Encoding":"gzip","Content-Type":"application/json; charset=UTF-8"},"json":true,"body":{"deviceid":"07627a83-e8e2-4877-b0a4-55b521b2a360","language":"sv","country":"SE","licenseversion":2},"simple":true,"resolveWithFullResponse":false,"transform2xxOnly":false},"response":{"statusCode":503,"headers":{"content-length":"0","connection":"keep-alive"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"appi.postnord.com","port":443,"hostname":"appi.postnord.com","hash":null,"search":"?apikey=591aa0cdb8cf85d41fede9b027b1e1c7","query":"apikey=591aa0cdb8cf85d41fede9b027b1e1c7","pathname":"/rest/customer/v1/identity/register/4612345678","path":"/rest/customer/v1/identity/register/4612345678?apikey=591aa0cdb8cf85d41fede9b027b1e1c7","href":"https://appi.postnord.com/rest/customer/v1/identity/register/4612345678?apikey=591aa0cdb8cf85d41fede9b027b1e1c7"},"method":"POST","headers":{"User-Agent":"PostNord/6.5.2-Android","Connection":"Keep-Alive","Host":"appi.postnord.com","Accept-Encoding":"gzip","Content-Type":"application/json; charset=UTF-8","accept":"application/json","content-length":101}}}}

My questions:
1: Valid API key?
2. Deprecated API? (since postnord dev-doc refer to api2.postnord.com as host
3. Update to https://guides.developer.postnord.com/#ddf7f133-ed64-4703-ab67-ba295a82c2b3 or something here https://developer.postnord.com/apis ?

Unhandled rejection ReferenceError: response is not defined

Module wont load, recreated the hash = noavail:

0|mm  | [15.09.2022 22:06.41.400] [WARN]
0|mm  | Unhandled rejection ReferenceError: response is not defined
0|mm  |     at /home/micke/MagicMirror/modules/MMM-Postnord/node_helper.js:164:15
0|mm  |     at tryCatcher (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/util.js:16:23)
0|mm  |     at Promise._settlePromiseFromHandler (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/promise.js:547:31)
0|mm  |     at Promise._settlePromise (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/promise.js:604:18)
0|mm  |     at Promise._settlePromise0 (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/promise.js:649:10)
0|mm  |     at Promise._settlePromises (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/promise.js:725:18)
0|mm  |     at _drainQueueStep (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/async.js:93:12)
0|mm  |     at _drainQueue (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/async.js:86:9)
0|mm  |     at Async._drainQueues (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/async.js:102:5)
0|mm  |     at Immediate.Async.drainQueues [as _onImmediate] (/home/micke/MagicMirror/modules/MMM-Postnord/node_modules/bluebird/js/release/async.js:15:14)
0|mm  |     at processImmediate (node:internal/timers:466:21)

Keeps Crashing MM2

i tryed everything with this module with no succes each time i add it to the config.js file mirror crashes and tells me to reconfigure the file

here is what im pasting in to it

...
{
        module: "MMM-Postnord",
        position: "bottom_left",
        config: {
            locale: "sv", //Optional, default is 'sv' allowed codes 'en', 'da', 'fi', 'no', 'sv'
            refreshRateMin: "60" //Optional, default is 60 min
            deliveredPackagesCooldown: "24" //Optional, hours a package should be visible until removed, default null always visible.
        }
    },
...

tryed without ... and in start of the file and in bottom same issue keeps crashing and telling me config file is not correct configed

Visible

Is it possible to make the Postnord logo visible all the time? Now it is visible only before the list appears.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.