Skip to main content

A Python package for retrieving data from Nortec/Evaskeri backend

Project description

Nortec / E-vaskeri

Description

Nortec.py allows the user to retrieve information about washing and drying machines located at a nortec site. Such as time remaining, program, current stage of program etc. It also allows the user to retrieve reciepts and saldo.

Installation

Follow these steps to get the project set up on your local machine.

  1. Clone the repository

    First, you will need to clone the repository using Git. You can do this by running the following command in your terminal:

    git clone https://github.com/kasperkls02/nortec.git
    
  2. Install dependencies This project requires Python and some Python packages. Make sure you have Python installed on your machine. You can download it from here.

    After installing python, navigate to the project directory and install the required packages using pip:

    cd nortec
    pip install -r requirements.txt
    
  3. Set up the serfver and session string Follow the instructions in the Getting the server and session string

Getting the server and session string

Currently, it's not possible to get the session string directly from a request on the server. However, you can obtain it by following these steps:

  1. Visit the Nortec or e-vaskeri.dk website and log in with your credentials

  2. After logging in, open the developer tools in your browser (usually by pressing F12). Open the Network tab and select 'Fetch/XHR'. Now reload the website (usually by Ctrl+R). Now find look for a request that is named along the lines of ".../?App=TUK@session=..."

  3. Open the request and copy copy the request url it should be along the lines of: https://backend.nortec1.dk/User/Refresh1/?App=TUK&session=asdasdadasdasdddas&tabid=&tick=1703096297554&native=false&.json

    We need

    Remember that the session is private and should not be shared with other people.

Functions and examples

get_machines(server, session):

The get_machines(server, session) function return a list that contains the timestamp provided by the server when the request was made and a second list containing information about the site.

The response is on the form:

(Timestamp, [[MachineName, unit, machineIdentifier],
             [MachineName, unit, machineIdentifier]])
>>> print(get_machines('https://backend.nortec1.dk/', session))
('18:48', [['Vaskemaskine 1', 'unit5', 'asddas'], ['Vaskemaskine 2', 'unit5', 'adsfgf'], ['Vaskemaskine 3', 'unit5','jgudjg']]) 

get_state(server, unit, machineIdentifier)

The get_state(server, unit, machineIdentifier) function return the state of a machine. The response is on the form:

['time remaining', 'program', 'state (e.g. "Hovedvask")', '?', 'status (e.g. "OPTAGET")', '?']
>>> print(get_state(server, unit, machineIdentifier))
['9:41', '40° Normal', 'Centrifugering', '', 'OPTAGET', '']

get_states(server, session)

The get_states(server,session) function is a combination of the above two function. It therefore returns a list that contains the timestamp provided by the server when the request was made and a second list containing information about all machines associated with the site.

The response is on the form:

[Time, 
    [
        [MachineName, 
            [time remaining, 
            program, 
            state (e.g. "Hovedvask"), 
            ?, 
            status (e.g. "OPTAGET"), 
            ?]
        ]
    ]
]
>>> print(get_states('https://backend.nortec1.dk', 'asdasdadasdasdddas'))
['18:46', [['Vaskemaskine 1', ['', '40° Normal', '', '', 'FÆRDIG', '']], ['Vaskemaskine 2', ['', '', '', '', 'FRI', '']]]]

get_statements(server, session):

The get_statements(server, session) function return a list of receipts and the current saldo and previus saldo. The output represents a JSON structure of the following properties:

  • Receipts: A list of receipt objects.
    • LocationId: The ID of the location.
    • Title: The date of the receipt.
    • Description: Address of the site.
    • Lines:
      • UnitId: The ID of the unit.
      • Time: The time of the wash/drying
      • Unit: The unit name.
      • Text: The selected program
      • Amount: The amount of the line.
      • Tag: The tag of the line.
      • Returned: Indicates if the line is returned.
    • LinesTotal: The total amount of the lines.
    • LinesVat: The VAT amount of the lines.
    • PaymentsTotal: The total amount of payments.
    • Saldo: The saldo amount.
  • Rate: The rate.
  • ReturnTime: The return time.
  • ServerId: The ID of the server.
  • Session: The session string.
  • Return: The return value.
  • Saldo: The saldo object.
    • CurrentPeriod: The saldo of the current period.
    • LastPeriod: The saldo of the last period.
>>> print(nortec.get_statements(server, session))
{'Receipts': [{'LocationId': 125, 'Title': 'Onsdag 13.  december 2023', 'Description': [''], 'Lines': [{'UnitId': 6, 'Time': '19:01', 'Unit': 'Vaskemaskine 6', 'Text': 'Program 4 Normal 40°, forvask, kulørt sæbe, meget snavset', 'Amount': 1200, 'Tag': 1, 'Returned': False}], 'LinesTotal': 1200, 'LinesVat': 0, 'PaymentsTotal': 0, 'Saldo': -1200},], 'Rate': 0, 'ReturnTime': 235, 'ServerId': 1, 'Session': '', 'Return': 100, 'Saldo': {'CurrentPeriod': '-1200', 'LastPeriod': '-3600'}}

get_saldo(server, session)

The get_saldo(server, session) is a function that extracts the current and previus saldo from the get_statemants function.

>>> print(get_saldo(server, session))
{'CurrentPeriod': '-1200', 'LastPeriod': '-3600'}

Contributing

Pull requests and issues are always welcome.

TODO:

  • Retrieve session from a standard post request on the login url
  • Retrieve if a machine is currently in use by user. Response from ../../User/Home3/ should contains this information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nortec-0.1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file nortec-0.1.tar.gz.

File metadata

  • Download URL: nortec-0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.5 importlib-metadata/4.12.0 keyring/23.9.1 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.28.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.12 CPython/3.10.12

File hashes

Hashes for nortec-0.1.tar.gz
Algorithm Hash digest
SHA256 180dd7c115098d288f11153f6ee06d32856bdfc29c12eb74bb4f8789c0ac692c
MD5 8d351c5c27f4c475d2c4adefaf1b91c4
BLAKE2b-256 cec1f3197eecee7e7cebc2987df7e3865878e3bdc1a70c31c4e75ec42e60f273

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page