from pyimb import imb
import model
import logging
import os.path
import json
owner_id = 123
owner_name = 'rasmus'
federation = 'ecodistrict'

#c = imb.Client(imb.TEST_URL, imb.TEST_PORT, owner_id, owner_name, federation)

try:
    m = model.RenobuildModel()
    #m.client = c

    request = {
    "method": "getModels",
    "type": "request",
    "parameters": {
        "kpiList": "kpi1"
    }
    }

    #m._handle_request(imb.encode_string(json.dumps(request)))

    inputs = [
        {
            "id": "time-frame",
            "type": "number",
            "value": 50
        },
        {
            "id": "buildings",
            "type": "list",
            "inputs": [
                [
                    {
                        "id": "building-name",
                        "type": "text",
                        "value": "building A"
                    },
                    {
                        "id": "heating-system",
                        "type": "select",
                        "value": 1
                    },
                    {
                        "id": "energy-use",
                        "type": "number",
                        "value": 5000
                    }
                ],
                [
                    {
                        "id": "building-name",
                        "type": "text",
                        "value": "building A"
                    },
                    {
                        "id": "heating-system",
                        "type": "select",
                        "value": 2
                    },
                    {
                        "id": "energy-use",
                        "type": "number",
                        "value": 10000
                    }
                ]
            ]
        }
    ]

    request = {
        "method": "startModel",
        "type": "request",
        "moduleId": "sp-renobuild-excel-model",
        "variantId": "variantId",
        "kpiAlias": "energy-kpi",
        "inputs": inputs
    }

    #m._handle_request(imb.encode_string(json.dumps(request)))
    print(m.run_model(inputs, 'energy-kpi'))

    #input()

finally:
    pass#c.disconnect()
@@ -70,16 +70,74 @@
 rt json%0A
+import time%0A%0Aurl = 'imb.lohman-solutions.com'%0Aport = 4000%0A
 owner_id
@@ -161,14 +161,10 @@
  = '
-rasmus
+SP
 '%0Afe
@@ -189,17 +189,25 @@
 trict'%0A%0A
-#
+try:%0A    
 c = imb.
@@ -217,35 +217,17 @@
 ent(
-imb.TEST_URL, imb.TEST_PORT
+url, port
 , ow
@@ -257,22 +257,16 @@
 eration)
-%0A%0Atry:
 %0A    m =
@@ -293,17 +293,16 @@
 l()%0A    
-#
 m.client
@@ -315,1888 +315,87 @@
     
-request = %7B%0A    %22method%22: %22getModels%22,%0A    %22type%22: %22request%22,%0A    %22parameters%22: %7B%0A        %22kpiList%22: %22kpi1%22%0A    %7D%0A    %7D%0A%0A    #m._handle_request(imb.encode_string(json.dumps(request)))%0A%0A    inputs = %5B%0A        %7B%0A            %22id%22: %22time-frame%22,%0A            %22type%22: %22number%22,%0A            %22value%22: 50%0A        %7D,%0A        %7B%0A            %22id%22: %22buildings%22,%0A            %22type%22: %22list%22,%0A            %22inputs%22: %5B%0A                %5B%0A                    %7B%0A                        %22id%22: %22building-name%22,%0A                        %22type%22: %22text%22,%0A                        %22value%22: %22building A%22%0A                    %7D,%0A                    %7B%0A                        %22id%22: %22heating-system%22,%0A                        %22type%22: %22select%22,%0A                        %22value%22: 1%0A                    %7D,%0A                    %7B%0A                        %22id%22: %22energy-use%22,%0A                        %22type%22: %22number%22,%0A                        %22value%22: 5000%0A                    %7D%0A                %5D,%0A                %5B%0A                    %7B%0A                        %22id%22: %22building-name%22,%0A                        %22type%22: %22text%22,%0A                        %22value%22: %22building A%22%0A                    %7D,%0A                    %7B%0A                        %22id%22: %22heating-system%22,%0A                        %22type%22: %22select%22,%0A                        %22value%22: 2%0A                    %7D,%0A                    %7B%0A                        %22id%22: %22energy-use%22,%0A                        %22type%22: %22number%22,%0A                        %22value%22: 10000%0A                    %7D%0A                %5D%0A            %5D%0A        %7D%0A    %5D%0A%0A    request = %7B%0A        %22method%22: %22startModel%22,%0A        %22type%22: %22request%22,%0A        %22moduleId%22: %22sp-renobuild-excel-model%22,%0A        %22variantId%22: %22variantId%22,%0A        %22kpiAlias%22: %22energy-kpi%22,%0A        %22inputs%22: inputs%0A    %7D%0A%0A    #m._handle_request(imb.encode_string(json.dumps(request)))%0A    print(m.run_model(inputs, 'energy-kpi'))%0A%0A    #input(
+time.sleep(0.5)%0A    input('Listening for input... Press return to stop module.'
 )%0A%0Af
@@ -410,13 +410,8 @@
     
-pass#
 c.di

Clean up module test code