Advertisement
Guest User

Untitled

a guest
May 4th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. const config = {
  4.   // directory for files generated by emulator
  5.   tempDirectory: './temp',
  6.  
  7.   // only used with switch --store-log-to-database
  8.   database: {
  9.     host: 'localhost',
  10.     port: 3307,
  11.     user: 'root',
  12.     password: '',
  13.     database: 'ngwcs'
  14.   },
  15.  
  16.   logLevel: 'TRACE',
  17.   // TODO
  18.   // logFile: './temp/default.log',
  19.  
  20.   // device state file (overriden by command line)
  21.   // if not present generated to temp directory in format [serialNumber].json
  22.   // deviceStateFile: './temp/default.json',
  23.  
  24.   /**
  25.    * Default state of device at first boot
  26.    *
  27.    * state is used to store persistent data and state of emulated machine
  28.    */
  29.   defaultDeviceState: {
  30.     // Factory-default ytun configuration
  31.     ytunHost: 'ytun2.jablotron.cz', // required
  32.     ytunPort: 8087, // required
  33.  
  34.     /**
  35.      * Variables for complex behavior not emulated, but simply mocked
  36.      */
  37.     allowRegister: true,
  38.  
  39.     /**
  40.      * Set by data enable command sent at registration
  41.      * false - no state data send to application (application has no entries for this location and cannot store values)
  42.      * true - sending state data
  43.      */
  44.     dataEnable: true,
  45.  
  46.     // identifier of structure in varState; mismatch with identifier on application side will trigger synchronization
  47.     // of varState to application
  48.     structureId: 1,
  49.  
  50.     // State of device
  51.     varState: {
  52.       // location = root object - object_id of this object translates to serial number
  53.       /**
  54.        * Ids of objects are 4 bytes long. 'location' is root object whitch has
  55.        * same objectId as serial number of location, for better readability it is named 'location' in config
  56.        */
  57.       'location': {
  58.         '_type': 'location',
  59.         '_rooms': ['0x010A0000', '0x020A0000', '0x030A0000', '0x040A0000'], // objectIds of child objects
  60.         '_devices': ['0x000A0000'], // objectIds of child objects
  61.         'hc_mode': {
  62.           value: 0, // HEATING
  63.           time: new Date()
  64.         }
  65.       },
  66.       /**
  67.        * Rooms are connected to device with same bottom three bytes in id and zero top byte.
  68.        * Room with id 0x01120FBA belongs to device with id 0x00120FBA and it is 12th room on that device
  69.        */
  70.       '0x000A0000': {
  71.         '_type': 'device',
  72.         'name': {
  73.           value: 'Living room and Bedroom',
  74.           time: new Date()
  75.         },
  76.         'status': {
  77.           value: Math.floor(new Date().getTime() / 1000), // disconnected now
  78.           time: new Date()
  79.         }
  80.       },
  81.       '0x010A0000': {
  82.         '_type': 'room',
  83.         'name': {
  84.           value: 'Badroom',
  85.           time: new Date()
  86.         },
  87.         'air_temp': {
  88.           value: 21.2,
  89.           time: new Date()
  90.         },
  91.         'floor_temp': {
  92.           value: 20.3,
  93.           time: new Date()
  94.         },
  95.         'humidity': {
  96.           value: 64,
  97.           time: new Date()
  98.         },
  99.         'tmp_ctrl.temp_desired': {
  100.           value: 22,
  101.           time: new Date()
  102.         },
  103.         'tmp_ctrl.heat.temp_set_eco': {
  104.           value: 16.5,
  105.           time: new Date()
  106.         },
  107.         'tmp_ctrl.heat.temp_set_comfort': {
  108.           value: 22,
  109.           time: new Date()
  110.         },
  111.         'tmp_ctrl.heat.temp_set_extra_comfort': {
  112.           value: 27.5,
  113.           time: new Date()
  114.         },
  115.         'therm_access_level': {
  116.           value: 32,
  117.           time: new Date()
  118.         },
  119.         'hum_ctrl.blocking': {
  120.           value: 1,
  121.           time: new Date()
  122.         },
  123.         'hum_ctrl.state': {
  124.           value: 0,
  125.           time: new Date()
  126.         },
  127.         'tmp_ctrl.heat.temp_set_manual': {
  128.           value: 13,
  129.           time: new Date()
  130.         },
  131.         'tmp_ctrl.cool.temp_set_manual': {
  132.           value: 15,
  133.           time: new Date()
  134.         },
  135.         'tmp_ctrl.cool.temp_set_eco': {
  136.           value: 13,
  137.           time: new Date()
  138.         },
  139.         'tmp_ctrl.cool.temp_set_comfort': {
  140.           value: 11,
  141.           time: new Date()
  142.         },
  143.         'tmp_ctrl.cool.temp_set_extra_comfort': {
  144.           value: 12,
  145.           time: new Date()
  146.         },
  147.         'tmp_ctrl.heat.adaptive_mode_ena': {
  148.           value: 0,
  149.           time: new Date()
  150.         },
  151.         'allow_vacation_away': {
  152.           value: 0,
  153.           time: new Date()
  154.         },
  155.         'tmp_ctrl.heat.floor_temp_limit_min_eco': {
  156.           value: 11,
  157.           time: new Date()
  158.         },
  159.         'tmp_ctrl.heat.floor_temp_limit_max_eco': {
  160.           value: 12,
  161.           time: new Date()
  162.         },
  163.         'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
  164.           value: 13,
  165.           time: new Date()
  166.         },
  167.         'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
  168.           value: 14,
  169.           time: new Date()
  170.         },
  171.         'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
  172.           value: 15,
  173.           time: new Date()
  174.         },
  175.         'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
  176.           value: 16,
  177.           time: new Date()
  178.         },
  179.         'tmp_ctrl.heat.temp_set_vacation': {
  180.           value: 20,
  181.           time: new Date()
  182.         },
  183.         'tmp_ctrl.heat.temp_set_standby': {
  184.           value: 22,
  185.           time: new Date()
  186.         },
  187.         'tmp_ctrl.cool.temp_set_vacation': {
  188.           value: 21,
  189.           time: new Date()
  190.         },
  191.         'tmp_ctrl.cool.temp_set_standby': {
  192.           value: 23,
  193.           time: new Date()
  194.         },
  195.         'tmp_ctrl.cool.temp_span_min': {
  196.           value: 3,
  197.           time: new Date()
  198.         },
  199.         'tmp_ctrl.cool.temp_span_max': {
  200.           value: 4,
  201.           time: new Date()
  202.         },
  203.         'tmp_ctrl.heat.temp_span_min': {
  204.           value: 5,
  205.           time: new Date()
  206.         },
  207.         'tmp_ctrl.heat.temp_span_max': {
  208.           value: 6,
  209.           time: new Date()
  210.         },
  211.         'tmp_ctrl.heat.regulated_val_src': {
  212.           value: 0,
  213.           time: new Date()
  214.         },
  215.         'hum_ctrl.enabled': {
  216.           value: 1,
  217.           time: new Date()
  218.         },
  219.         'tmp_ctrl.heat.floor_temp_hysteresis': {
  220.           value: 20,
  221.           time: new Date()
  222.         },
  223.         'tmp_ctrl.cool.temp_hysteresis': {
  224.           value: 26,
  225.           time: new Date()
  226.         },
  227.         'tmp_ctrl.heat.temp_hysteresis': {
  228.           value: 27,
  229.           time: new Date()
  230.         },
  231.         'hum_ctrl.hum_hysteresis': {
  232.           value: 33,
  233.           time: new Date()
  234.         },
  235.         'hum_ctrl.hum_set_manual': {
  236.           value: 35,
  237.           time: new Date()
  238.         },
  239.         'tmp_ctrl.state': {
  240.           value: 1,
  241.           time: new Date()
  242.         },
  243.         'tmp_ctrl.blocking': {
  244.           value: 3,
  245.           time: new Date()
  246.         },
  247.         'mode_override': {
  248.           value: 3,
  249.           time: new Date()
  250.         },
  251.         'mode_override_end_time': {
  252.           value: 900,
  253.           time: new Date()
  254.         }
  255.       },
  256.       '0x020A0000': {
  257.         '_type': 'room',
  258.         'name': {
  259.           value: 'Bedroom',
  260.           time: new Date()
  261.         },
  262.         'air_temp': {
  263.           value: 21.7,
  264.           time: new Date()
  265.         },
  266.         'floor_temp': {
  267.           value: 20.8,
  268.           time: new Date()
  269.         },
  270.         'humidity': {
  271.           value: 64,
  272.           time: new Date()
  273.         },
  274.         'tmp_ctrl.temp_desired': {
  275.           value: 27.5,
  276.           time: new Date()
  277.         },
  278.         'tmp_ctrl.heat.temp_set_eco': {
  279.           value: 16.5,
  280.           time: new Date()
  281.         },
  282.         'tmp_ctrl.heat.temp_set_comfort': {
  283.           value: 22,
  284.           time: new Date()
  285.         },
  286.         'tmp_ctrl.heat.temp_set_extra_comfort': {
  287.           value: 27.5,
  288.           time: new Date()
  289.         },
  290.         'therm_access_level': {
  291.           value: 40,
  292.           time: new Date()
  293.         },
  294.         'hum_ctrl.blocking': {
  295.           value: 1,
  296.           time: new Date()
  297.         },
  298.         'hum_ctrl.state': {
  299.           value: 0,
  300.           time: new Date()
  301.         },
  302.         'tmp_ctrl.heat.temp_set_manual': {
  303.           value: 15,
  304.           time: new Date()
  305.         },
  306.         'tmp_ctrl.cool.temp_set_manual': {
  307.           value: 13,
  308.           time: new Date()
  309.         },
  310.         'tmp_ctrl.cool.temp_set_eco': {
  311.           value: 11,
  312.           time: new Date()
  313.         },
  314.         'tmp_ctrl.cool.temp_set_comfort': {
  315.           value: 12,
  316.           time: new Date()
  317.         },
  318.         'tmp_ctrl.cool.temp_set_extra_comfort': {
  319.           value: 13,
  320.           time: new Date()
  321.         },
  322.         'tmp_ctrl.heat.adaptive_mode_ena': {
  323.           value: 1,
  324.           time: new Date()
  325.         },
  326.         'allow_vacation_away': {
  327.           value: 1,
  328.           time: new Date()
  329.         },
  330.         'tmp_ctrl.heat.floor_temp_limit_min_eco': {
  331.           value: 13,
  332.           time: new Date()
  333.         },
  334.         'tmp_ctrl.heat.floor_temp_limit_max_eco': {
  335.           value: 14,
  336.           time: new Date()
  337.         },
  338.         'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
  339.           value: 15,
  340.           time: new Date()
  341.         },
  342.         'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
  343.           value: 16,
  344.           time: new Date()
  345.         },
  346.         'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
  347.           value: 17,
  348.           time: new Date()
  349.         },
  350.         'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
  351.           value: 18,
  352.           time: new Date()
  353.         },
  354.         'tmp_ctrl.heat.temp_set_vacation': {
  355.           value: 19,
  356.           time: new Date()
  357.         },
  358.         'tmp_ctrl.heat.temp_set_standby': {
  359.           value: 21,
  360.           time: new Date()
  361.         },
  362.         'tmp_ctrl.cool.temp_set_vacation': {
  363.           value: 20,
  364.           time: new Date()
  365.         },
  366.         'tmp_ctrl.cool.temp_set_standby': {
  367.           value: 22,
  368.           time: new Date()
  369.         },
  370.         'tmp_ctrl.cool.temp_span_min': {
  371.           value: 7,
  372.           time: new Date()
  373.         },
  374.         'tmp_ctrl.cool.temp_span_max': {
  375.           value: 8,
  376.           time: new Date()
  377.         },
  378.         'tmp_ctrl.heat.temp_span_min': {
  379.           value: 9,
  380.           time: new Date()
  381.         },
  382.         'tmp_ctrl.heat.temp_span_max': {
  383.           value: 10,
  384.           time: new Date()
  385.         },
  386.         'tmp_ctrl.heat.regulated_val_src': {
  387.           value: 3,
  388.           time: new Date()
  389.         },
  390.         'hum_ctrl.enabled': {
  391.           value: 0,
  392.           time: new Date()
  393.         },
  394.         'tmp_ctrl.heat.floor_temp_hysteresis': {
  395.           value: 25,
  396.           time: new Date()
  397.         },
  398.         'tmp_ctrl.cool.temp_hysteresis': {
  399.           value: 25,
  400.           time: new Date()
  401.         },
  402.         'tmp_ctrl.heat.temp_hysteresis': {
  403.           value: 26,
  404.           time: new Date()
  405.         },
  406.         'hum_ctrl.hum_hysteresis': {
  407.           value: 44,
  408.           time: new Date()
  409.         },
  410.         'hum_ctrl.hum_set_manual': {
  411.           value: 55,
  412.           time: new Date()
  413.         },
  414.         'tmp_ctrl.state': {
  415.           value: 2,
  416.           time: new Date()
  417.         },
  418.         'tmp_ctrl.blocking': {
  419.           value: 0,
  420.           time: new Date()
  421.         },
  422.         'mode_override': {
  423.           value: 1,
  424.           time: new Date()
  425.         },
  426.         'mode_override_end_time': {
  427.           value: 200,
  428.           time: new Date()
  429.         }
  430.       }
  431.     }
  432.   },
  433.  
  434.   simulations: [
  435.     {
  436.       count: 0, // 0 - infinity
  437.       delay: 8 * 1000, // delay time for one run, interval time for multiple runs
  438.       action: function (location) {
  439.         /**
  440.          * Simulate random air_temp, floor_temp and humidity change on each room every 8 seconds
  441.          */
  442.         let objects = location.listObjects();
  443.         for (let i in objects) {
  444.           if (objects[i]['_type'] === 'room') {
  445.             location.set(i, 'air_temp', Math.floor(Math.random() * 40) / 10 + 20);
  446.             location.set(i, 'floor_temp', Math.floor(Math.random() * 40) / 10 + 21);
  447.             location.set(i, 'humidity', Math.floor(Math.random() * 40) + 50);
  448.           }
  449.         }
  450.         location.set('0x010A0000', 'hum_ctrl.blocking', 0);
  451.         location.set('0x010A0000', 'hum_ctrl.state', 3);
  452.         location.set('0x010A0000', 'therm_access_level', 0);
  453.         location.set('0x000A0000', 'status', 2);
  454.         location.send('changed', null, 500)  // send all changed after 0.5 s
  455.           .catch(e => {
  456.             console.log(e);
  457.           });
  458.       }
  459.     }
  460.   ],
  461.  
  462.   /**
  463.    * Actions provided in config.example.js are defaults
  464.    * For onValue methods default is simply saving value
  465.    */
  466.   interactions: {
  467.     onConnect: function (location) {
  468.       // synchronization of state to application - for correct work must be executed
  469.       let forceSyncStrcuture = false;
  470.       location.sync(forceSyncStrcuture).then(() => {
  471.         location.set('0x010A0000', 'tmp_ctrl.temp_desired', 16.5);
  472.         location.send('changed', 1 * 1000)
  473.           .catch(e => {
  474.             console.log(e);
  475.           });
  476.       });
  477.     },
  478.     onValue: {
  479.       // location
  480.       'location': {
  481.         'name': function (location, objectId, value) {
  482.           location.set(objectId, 'name', value);
  483.           location.send('changed', 1 * 1000)
  484.             .catch(e => {
  485.               console.log(e);
  486.             });
  487.         }
  488.       },
  489.  
  490.       // rooms
  491.       'room': {
  492.         'name': function (location, objectId, value) {
  493.           location.set(objectId, 'name', value);
  494.         },
  495.         'tmp_ctrl.heat.temp_set_eco': function (location, objectId, value) {
  496.           // custom implementation
  497.           location.set(objectId, 'tmp_ctrl.heat.temp_set_eco', value);
  498.           location.set(objectId, 'tmp_ctrl.temp_desired', value - 1.5);
  499.           location.send('changed', 500)
  500.             .catch(e => {
  501.               console.log(e);
  502.             });
  503.         }
  504.       }
  505.     },
  506.     onDataEnable: function (location, enabled) {
  507.       // if data were enabled
  508.       if (enabled) {
  509.         // synchronization of state to application - for correct work must be executed
  510.         location.sync(true);
  511.       }
  512.     }
  513.   }
  514. };
  515.  
  516. module.exports = config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement