Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const config = {
- // directory for files generated by emulator
- tmpDirectory: './tmp',
- // 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'], // objectIds of child objects
- '_devices': ['0x000A0000'], // objectIds of child objects
- 'hc_mode': {
- value: 0, // HEATING
- time: new Date()
- },
- 'vacation': {
- value: false,
- time: new Date()
- },
- 'vacation_end_time': {
- value: null,
- time: new Date()
- },
- 'standby': {
- value: 0,
- 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.heat.temp_set_party': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_party': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_adjusted': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_adjusted': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_manual': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_manual': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_eco': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_eco': {
- value: 10.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_comfort': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_comfort': {
- value: 18,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_extra_comfort': {
- value: 27.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_extra_comfort': {
- value: 25.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_eco': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_eco': {
- value: 14,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_hysteresis': {
- value: 10,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_hysteresis': {
- value: 10,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_hysteresis': {
- value: 14,
- time: new Date()
- },
- 'hum_ctrl.hum_hysteresis': {
- value: 15,
- 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.heat.temp_set_party': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_party': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_adjusted': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_adjusted': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_manual': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_manual': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_eco': {
- value: 16.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_eco': {
- value: 10.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_comfort': {
- value: 22,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_comfort': {
- value: 18,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_set_extra_comfort': {
- value: 27.5,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_set_extra_comfort': {
- value: 25.5,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_eco': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_eco': {
- value: 14,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_extra_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_extra_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_min_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_limit_max_comfort': {
- value: 12,
- time: new Date()
- },
- 'tmp_ctrl.cool.temp_hysteresis': {
- value: 10,
- time: new Date()
- },
- 'tmp_ctrl.heat.temp_hysteresis': {
- value: 10,
- time: new Date()
- },
- 'tmp_ctrl.heat.floor_temp_hysteresis': {
- value: 14,
- time: new Date()
- },
- 'hum_ctrl.hum_hysteresis': {
- value: 15,
- 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('0x000A0000', 'status', 1);
- 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