Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const config = {
- // directory for files generated by emulator
- tempDirectory: './temp',
- // only used with switch --store-log-to-database
- database: {
- host: 'localhost',
- port: 3307,
- user: 'root',
- password: '',
- database: 'ngwcs'
- },
- logLevel: 'TRACE',
- // TODO
- // logFile: './temp/default.log',
- // device state file (overriden by command line)
- // if not present generated to temp directory in format [serialNumber].json
- // deviceStateFile: './temp/default.json',
- /**
- * Default state of device at first boot
- *
- * state is used to store persistent data and state of emulated machine
- */
- defaultDeviceState: {
- // Factory-default ytun configuration
- ytunHost: 'ytun2.jablotron.cz', // required
- ytunPort: 8087, // required
- /**
- * Variables for complex behavior not emulated, but simply mocked
- */
- allowRegister: true,
- /**
- * Set by data enable command sent at registration
- * false - no state data send to application (application has no entries for this location and cannot store values)
- * true - sending state data
- */
- dataEnable: true,
- // identifier of structure in varState; mismatch with identifier on application side will trigger synchronization
- // of varState to application
- structureId: 1,
- // State of device
- varState: {
- // location = root object - object_id of this object translates to serial number
- /**
- * Ids of objects are 4 bytes long. 'location' is root object whitch has
- * same objectId as serial number of location, for better readability it is named 'location' in config
- */
- 'location': {
- '_type': 'location',
- '_rooms': ['0x010A0000', '0x020A0000', '0x030A0000', '0x040A0000'], // objectIds of child objects
- '_devices': ['0x000A0000'], // objectIds of child objects
- 'hc_mode': {
- value: 0, // HEATING
- time: new Date()
- }
- },
- /**
- * Rooms are connected to device with same bottom three bytes in id and zero top byte.
- * Room with id 0x01120FBA belongs to device with id 0x00120FBA and it is 12th room on that device
- */
- '0x000A0000': {
- '_type': 'device',
- 'name': {
- value: 'Living room and Bedroom',
- time: new Date()
- },
- 'status': {
- value: Math.floor(new Date().getTime() / 1000), // disconnected now
- time: new Date()
- }
- },
- '0x010A0000': {
- '_type': 'room',
- 'name': {
- value: 'Badroom',
- time: new Date()
- },
- 'air_temp': {
- value: 21.2,
- time: new Date()
- },
- 'floor_temp': {
- value: 20.3,
- time: new Date()
- },
- 'humidity': {
- value: 64,
- time: new Date()
- },
- 'tmp_ctrl.temp_desired': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_eco': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_comfort': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_extra_comfort': {
- value: 27.5,
- time: new Date()
- },
- 'therm_access_level': {
- value: 32,
- time: new Date()
- },
- 'hum_ctrl.blocking': {
- value: 1,
- time: new Date()
- },
- 'hum_ctrl.state': {
- value: 0,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_manual': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_manual': {
- value: 15,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_eco': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_comfort': {
- value: 11,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_extra_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.adaptive_mode_ena': {
- value: 0,
- time: new Date()
- },
- 'allow_vacation_away': {
- value: 0,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_eco': {
- value: 11,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_eco': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
- value: 14,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
- value: 15,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
- value: 16,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_vacation': {
- value: 20,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_standby': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_vacation': {
- value: 21,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_standby': {
- value: 23,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_span_min': {
- value: 3,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_span_max': {
- value: 4,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_span_min': {
- value: 5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_span_max': {
- value: 6,
- time: new Date()
- },
- 'tmp_ctrl.heat.regulated_val_src': {
- value: 0,
- time: new Date()
- },
- 'hum_ctrl.enabled': {
- value: 1,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_hysteresis': {
- value: 20,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_hysteresis': {
- value: 26,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_hysteresis': {
- value: 27,
- time: new Date()
- },
- 'hum_ctrl.hum_hysteresis': {
- value: 33,
- time: new Date()
- },
- 'hum_ctrl.hum_set_manual': {
- value: 35,
- time: new Date()
- },
- 'tmp_ctrl.state': {
- value: 1,
- time: new Date()
- },
- 'tmp_ctrl.blocking': {
- value: 3,
- time: new Date()
- },
- 'mode_override': {
- value: 3,
- time: new Date()
- },
- 'mode_override_end_time': {
- value: 900,
- time: new Date()
- }
- },
- '0x020A0000': {
- '_type': 'room',
- 'name': {
- value: 'Bedroom',
- time: new Date()
- },
- 'air_temp': {
- value: 21.7,
- time: new Date()
- },
- 'floor_temp': {
- value: 20.8,
- time: new Date()
- },
- 'humidity': {
- value: 64,
- time: new Date()
- },
- 'tmp_ctrl.temp_desired': {
- value: 27.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_eco': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_comfort': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_extra_comfort': {
- value: 27.5,
- time: new Date()
- },
- 'therm_access_level': {
- value: 40,
- time: new Date()
- },
- 'hum_ctrl.blocking': {
- value: 1,
- time: new Date()
- },
- 'hum_ctrl.state': {
- value: 0,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_manual': {
- value: 15,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_manual': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_eco': {
- value: 11,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_extra_comfort': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.heat.adaptive_mode_ena': {
- value: 1,
- time: new Date()
- },
- 'allow_vacation_away': {
- value: 1,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_eco': {
- value: 13,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_eco': {
- value: 14,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
- value: 15,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
- value: 16,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
- value: 17,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
- value: 18,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_vacation': {
- value: 19,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_standby': {
- value: 21,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_vacation': {
- value: 20,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_standby': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_span_min': {
- value: 7,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_span_max': {
- value: 8,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_span_min': {
- value: 9,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_span_max': {
- value: 10,
- time: new Date()
- },
- 'tmp_ctrl.heat.regulated_val_src': {
- value: 3,
- time: new Date()
- },
- 'hum_ctrl.enabled': {
- value: 0,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_hysteresis': {
- value: 25,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_hysteresis': {
- value: 25,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_hysteresis': {
- value: 26,
- time: new Date()
- },
- 'hum_ctrl.hum_hysteresis': {
- value: 44,
- time: new Date()
- },
- 'hum_ctrl.hum_set_manual': {
- value: 55,
- time: new Date()
- },
- 'tmp_ctrl.state': {
- value: 2,
- time: new Date()
- },
- 'tmp_ctrl.blocking': {
- value: 0,
- time: new Date()
- },
- 'mode_override': {
- value: 1,
- time: new Date()
- },
- 'mode_override_end_time': {
- value: 200,
- time: new Date()
- }
- }
- }
- },
- simulations: [
- {
- count: 0, // 0 - infinity
- delay: 8 * 1000, // delay time for one run, interval time for multiple runs
- action: function (location) {
- /**
- * Simulate random air_temp, floor_temp and humidity change on each room every 8 seconds
- */
- let objects = location.listObjects();
- for (let i in objects) {
- if (objects[i]['_type'] === 'room') {
- location.set(i, 'air_temp', Math.floor(Math.random() * 40) / 10 + 20);
- location.set(i, 'floor_temp', Math.floor(Math.random() * 40) / 10 + 21);
- location.set(i, 'humidity', Math.floor(Math.random() * 40) + 50);
- }
- }
- location.set('0x010A0000', 'hum_ctrl.blocking', 0);
- location.set('0x010A0000', 'hum_ctrl.state', 3);
- location.set('0x010A0000', 'therm_access_level', 0);
- location.set('0x000A0000', 'status', 2);
- location.send('changed', null, 500) // send all changed after 0.5 s
- .catch(e => {
- console.log(e);
- });
- }
- }
- ],
- /**
- * Actions provided in config.example.js are defaults
- * For onValue methods default is simply saving value
- */
- interactions: {
- onConnect: function (location) {
- // synchronization of state to application - for correct work must be executed
- let forceSyncStrcuture = false;
- location.sync(forceSyncStrcuture).then(() => {
- location.set('0x010A0000', 'tmp_ctrl.temp_desired', 16.5);
- location.send('changed', 1 * 1000)
- .catch(e => {
- console.log(e);
- });
- });
- },
- onValue: {
- // location
- 'location': {
- 'name': function (location, objectId, value) {
- location.set(objectId, 'name', value);
- location.send('changed', 1 * 1000)
- .catch(e => {
- console.log(e);
- });
- }
- },
- // rooms
- 'room': {
- 'name': function (location, objectId, value) {
- location.set(objectId, 'name', value);
- },
- 'tmp_ctrl.heat.temp_set_eco': function (location, objectId, value) {
- // custom implementation
- location.set(objectId, 'tmp_ctrl.heat.temp_set_eco', value);
- location.set(objectId, 'tmp_ctrl.temp_desired', value - 1.5);
- location.send('changed', 500)
- .catch(e => {
- console.log(e);
- });
- }
- }
- },
- onDataEnable: function (location, enabled) {
- // if data were enabled
- if (enabled) {
- // synchronization of state to application - for correct work must be executed
- location.sync(true);
- }
- }
- }
- };
- module.exports = config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement