diff --git a/lib/jeedom-api.js b/lib/jeedom-api.js index ea21d50..402cb7e 100755 --- a/lib/jeedom-api.js +++ b/lib/jeedom-api.js @@ -207,8 +207,8 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { var cmd = that._cachedModel.cmds[c]; if(cmd.id == ID && cmd.type=='info') { eq = that.getDevicePropertiesFromCache(cmd.eqLogic_id); - if(!internal) { that.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value); } - else { that.log('info','[Maj interne] commande:'+ID+' value:'+value); } + if(!internal) {that.log('info','[Maj reçue de Jeedom] commande:'+ID+' value:'+value);} + else {that.log('info','[Maj interne] commande:'+ID+' value:'+value);} that.log('info','[[Modification Cache Jeedom: '+eq.name+'>'+cmd.name+'('+cmd.generic_type+') de '+cmd.currentValue+' vers '+value+' dans ' + JSON.stringify(cmd).replace('\n','')); if(cmd.generic_type == 'ALARM_STATE') { if(cmd.currentValue != value) { @@ -239,11 +239,11 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) { }; JeedomClient.prototype.executeDeviceAction = function(ID, action, param) { - if(USE_QUEUES === 0) { return this._executeDeviceAction(ID, action, param); } + if(USE_QUEUES === 0) {return this._executeDeviceAction(ID, action, param);} return new Promise((resolve, reject) => { this.queue.push({ID, action, param, type:'cmd'}, (err, result) => { - if (err) { reject(err); } - else { resolve(result); } + if (err) {reject(err);} + else {resolve(result);} }); }); }; @@ -286,11 +286,11 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) { }; JeedomClient.prototype.executeScenarioAction = function(ID, action) { - if(USE_QUEUES === 0) { return this._executeScenarioAction(ID, action); } + if(USE_QUEUES === 0) {return this._executeScenarioAction(ID, action);} return new Promise((resolve, reject) => { this.queue.push({ID, action, type:'scenario'}, (err, result) => { - if (err) { reject(err); } - else { resolve(result); } + if (err) {reject(err);} + else {resolve(result);} }); }); }; @@ -346,481 +346,247 @@ JeedomClient.prototype.refreshStates = function() { }); }; -function initServ(result_cmd, serviceType, property, value, isPush = false) { - result_cmd.services[serviceType] ??= []; +function initServ(result_cmd, value, serviceType, property, isPush = false) { + result_cmd.services[serviceType] ??= []; const service = {}; - if (isPush) { - service[property] ??= []; - service[property].push(value); - } else { - service[property] = value; - } + if (isPush) { + service[property] ??= []; + service[property].push(value); + } else { + service[property] = value; + } result_cmd.services[serviceType].push(service); } JeedomClient.prototype.ParseGenericType = function(EqLogic, cmds) { const result_cmd = {...EqLogic, services: {}, numSwitches: 0, numDetector: 0}; - cmds.forEach((cmd) => { if (cmd.generic_type !== null) { - switch(cmd.generic_type) { - case 'SHOCK' : - case 'RAIN_CURRENT' : - case 'RAIN_TOTAL' : - case 'WIND_SPEED' : - case 'WIND_DIRECTION' : - case 'GENERIC_INFO': - initServ(result_cmd,'generic','state',cmd); - break; - /** *************** MODE ***********************/ - case 'MODE_STATE' : - initServ(result_cmd,'mode','state',cmd); - break; - case 'MODE_SET_STATE' : - if(cmd.logicalId=="returnPreviousMode") { - initServ(result_cmd,'mode','set_state_previous',cmd); - } else { - initServ(result_cmd,'mode','set_state',cmd,true); - } - break; - /** *************** LIGHT ***********************/ - case 'LIGHT_STATE' : - initServ(result_cmd,'light','state',cmd); - break; - case 'LIGHT_BRIGHTNESS' : - initServ(result_cmd,'light','brightness',cmd); - break; - case 'LIGHT_STATE_BOOL' : - initServ(result_cmd,'light','state_bool',cmd); - break; - case 'LIGHT_ON' : - initServ(result_cmd,'light','on',cmd); - break; - case 'LIGHT_OFF' : - initServ(result_cmd,'light','off',cmd); - break; - case 'LIGHT_SLIDER' : - initServ(result_cmd,'light','slider',cmd); - break; - case 'LIGHT_COLOR' : - initServ(result_cmd,'light','color',cmd); - break; - case 'LIGHT_COLOR_TEMP' : - initServ(result_cmd,'light','color_temp',cmd); - break; - case 'LIGHT_SET_COLOR' : - initServ(result_cmd,'light','setcolor',cmd); - break; - case 'LIGHT_SET_COLOR_TEMP' : - initServ(result_cmd,'light','setcolor_temp',cmd); - break; - /** *************** WEATHER ***********************/ - case 'WEATHER_TEMPERATURE' : - initServ(result_cmd,'weather','temperature',cmd); - break; - case 'WEATHER_HUMIDITY' : - initServ(result_cmd,'weather','humidity',cmd); - break; - case 'WEATHER_PRESSURE' : - initServ(result_cmd,'weather','pressure',cmd); - break; - case 'WEATHER_WIND_SPEED' : - initServ(result_cmd,'weather','wind_speed',cmd); - break; - case 'WEATHER_WIND_DIRECTION' : - initServ(result_cmd,'weather','wind_direction',cmd); - break; - case 'WEATHER_CONDITION' : - initServ(result_cmd,'weather','condition',cmd); - break; - case 'WEATHER_UVINDEX' : - initServ(result_cmd,'weather','UVIndex',cmd); - break; - case 'WEATHER_VISIBILITY' : - initServ(result_cmd,'weather','visibility',cmd); - break; - case 'WEATHER_RAIN' : - initServ(result_cmd,'weather','rain',cmd); - break; - case 'WEATHER_SNOW' : - initServ(result_cmd,'weather','snow',cmd); - break; - case 'WEATHER_TEMPERATURE_MIN' : - initServ(result_cmd,'weather','temperature_min',cmd); - break; - /** *************** SIREN ***********************/ - case 'SIREN_STATE' : - initServ(result_cmd,'siren','state',cmd); - break; - /* case 'SIREN_ON' : - initServ(result_cmd,'siren','on',cmd); - break; - case 'SIREN_OFF' : - initServ(result_cmd,'siren','off',cmd); - break; */ - /** *************** ENERGY ***********************/ - case 'ENERGY_STATE' : - initServ(result_cmd,'energy','state',cmd); - break; - case 'ENERGY_ON' : - initServ(result_cmd,'energy','on',cmd); - break; - case 'ENERGY_OFF' : - initServ(result_cmd,'energy','off',cmd); - break; - case 'ENERGY_INUSE' : - initServ(result_cmd,'energy','inuse',cmd); - break; - /** *************** VALVES ***********************/ - case 'FAUCET_STATE' : - initServ(result_cmd,'faucet','state',cmd); - break; - case 'FAUCET_ON' : - initServ(result_cmd,'faucet','on',cmd); - break; - case 'FAUCET_OFF' : - initServ(result_cmd,'faucet','off',cmd); - break; - case 'IRRIG_STATE' : - initServ(result_cmd,'irrigation','state',cmd); - break; - case 'IRRIG_ON' : - initServ(result_cmd,'irrigation','on',cmd); - break; - case 'IRRIG_OFF' : - initServ(result_cmd,'irrigation','off',cmd); - break; - case 'VALVE_STATE' : - initServ(result_cmd,'valve','state',cmd); - break; - case 'VALVE_ON' : - initServ(result_cmd,'valve','on',cmd); - break; - case 'VALVE_OFF' : - initServ(result_cmd,'valve','off',cmd); - break; - case 'VALVE_SET_DURATION' : - initServ(result_cmd,'valve','setDuration',cmd); - break; - case 'VALVE_REMAINING_DURATION' : - initServ(result_cmd,'valve','remainingDuration',cmd); - break; - /** *************** FAN ***********************/ - case 'FAN_STATE' : - case 'FAN_SPEED_STATE' : - initServ(result_cmd,'fan','state',cmd); - break; - case 'FAN_ON' : - initServ(result_cmd,'fan','on',cmd); - break; - case 'FAN_OFF' : - initServ(result_cmd,'fan','off',cmd); - break; - case 'FAN_SLIDER' : - case 'FAN_SPEED' : - initServ(result_cmd,'fan','slider',cmd); - break; - /** *************** SWITCH ***********************/ - case 'SWITCH_STATE' : - case 'CAMERA_RECORD_STATE' : - initServ(result_cmd,'Switch','state',cmd); - result_cmd.numSwitches++; - break; - case 'SWITCH_ON' : - case 'CAMERA_RECORD' : - initServ(result_cmd,'Switch','on',cmd); - break; - case 'SWITCH_OFF' : - case 'CAMERA_STOP' : - initServ(result_cmd,'Switch','off',cmd); - break; - /** *************** SWITCH ***********************/ - case 'GENERIC_ACTION' : - if(cmd.subType=="other") { - initServ(result_cmd,'Push','Push',cmd); - } - break; - case 'PUSH_BUTTON' : - case 'CAMERA_UP' : - case 'CAMERA_DOWN' : - case 'CAMERA_LEFT' : - case 'CAMERA_RIGHT' : - case 'CAMERA_ZOOM' : - case 'CAMERA_DEZOOM' : - case 'CAMERA_PRESET' : - initServ(result_cmd,'Push','Push',cmd); - break; - /** *************** BARRIER/GARAGE**************/ - case "BARRIER_STATE" : - case "GARAGE_STATE" : - initServ(result_cmd,'GarageDoor','state',cmd); - break; - case "GB_OPEN" : // should not be used - initServ(result_cmd,'GarageDoor','on',cmd); - break; - case "GB_CLOSE" : // should not be used - initServ(result_cmd,'GarageDoor','off',cmd); - break; - case "GB_TOGGLE" : - initServ(result_cmd,'GarageDoor','toggle',cmd); - break; - /** *************** LOCK ***********************/ - case 'LOCK_STATE' : - initServ(result_cmd,'lock','state',cmd); - break; - case 'LOCK_OPEN' : - initServ(result_cmd,'lock','on',cmd); - break; - case 'LOCK_CLOSE' : - initServ(result_cmd,'lock','off',cmd); - break; - /** *************** StatelessSwitch ******************/ - case 'SWITCH_STATELESS_ALLINONE' : - initServ(result_cmd,'StatelessSwitch','eventType',cmd); - break; - case 'SWITCH_STATELESS_SINGLE' : - initServ(result_cmd,'StatelessSwitchMono','Single',cmd); - break; - case 'SWITCH_STATELESS_DOUBLE' : - initServ(result_cmd,'StatelessSwitchMono','Double',cmd); - break; - case 'SWITCH_STATELESS_LONG' : - initServ(result_cmd,'StatelessSwitchMono','Long',cmd); - break; - /** *************** FLAP ***********************/ - case 'FLAP_STATE' : - initServ(result_cmd,'flap','state',cmd); - break; - case 'FLAP_STATE_CLOSING' : - initServ(result_cmd,'flap','stateClosing',cmd); - break; - case 'FLAP_UP' : - initServ(result_cmd,'flap','up',cmd); - break; - case 'FLAP_DOWN' : - initServ(result_cmd,'flap','down',cmd); - break; - case 'FLAP_SLIDER' : - initServ(result_cmd,'flap','slider',cmd); - break; - case 'FLAP_STOP' : - initServ(result_cmd,'flap','stop',cmd); - break; - case 'FLAP_HOR_TILT_STATE' : - initServ(result_cmd,'flap','HorTiltState',cmd); - break; - case 'FLAP_HOR_TILT_SLIDER' : - initServ(result_cmd,'flap','HorTiltSlider',cmd); - break; - case 'FLAP_VER_TILT_STATE' : - initServ(result_cmd,'flap','VerTiltState',cmd); - break; - case 'FLAP_VER_TILT_SLIDER' : - initServ(result_cmd,'flap','VerTiltSlider',cmd); - break; - /** *************** WINDOW ***********************/ - case 'WINDOW_STATE' : - initServ(result_cmd,'windowMoto','state',cmd); - break; - case 'WINDOW_UP' : - initServ(result_cmd,'windowMoto','up',cmd); - break; - case 'WINDOW_DOWN' : - initServ(result_cmd,'windowMoto','down',cmd); - break; - case 'WINDOW_SLIDER' : - initServ(result_cmd,'windowMoto','slider',cmd); - break; - /** ************* THERMOSTAT ***********************/ - case 'THERMOSTAT_STATE' : - initServ(result_cmd,'thermostat','state',cmd); - break; - case 'THERMOSTAT_STATE_NAME' : - initServ(result_cmd,'thermostat','state_name',cmd); - break; - case 'THERMOSTAT_TEMPERATURE' : - initServ(result_cmd,'thermostat','temperature',cmd); - break; - case 'THERMOSTAT_SET_SETPOINT' : - initServ(result_cmd,'thermostat','set_setpoint',cmd); - break; - case 'THERMOSTAT_SETPOINT' : - initServ(result_cmd,'thermostat','setpoint',cmd); - break; - case 'THERMOSTAT_SET_MODE' : - initServ(result_cmd,'thermostat','set_mode',cmd); - break; - case 'THERMOSTAT_MODE' : - initServ(result_cmd,'thermostat','mode',cmd); - break; - case 'THERMOSTAT_LOCK' : - initServ(result_cmd,'thermostat','lock',cmd); - break; - case 'THERMOSTAT_SET_LOCK' : - initServ(result_cmd,'thermostat','set_lock',cmd); - break; - case 'THERMOSTAT_SET_UNLOCK' : - initServ(result_cmd,'thermostat','set_unlock',cmd); - break; - case 'THERMOSTAT_TEMPERATURE_OUTDOOR' : - initServ(result_cmd,'thermostat','temperature_outdoor',cmd); - break; - /** ************* THERMOSTAT_HC ***********************/ - case 'THERMOSTAT_HC_STATE' : - initServ(result_cmd,'thermostatHC','state',cmd); - break; - case 'THERMOSTAT_HC_STATE_NAME' : - initServ(result_cmd,'thermostatHC','state_name',cmd); - break; - case 'THERMOSTAT_HC_TEMPERATURE' : - initServ(result_cmd,'thermostatHC','temperature',cmd); - break; - case 'THERMOSTAT_HC_SET_SETPOINT_H' : - initServ(result_cmd,'thermostatHC','set_setpointH',cmd); - break; - case 'THERMOSTAT_HC_SET_SETPOINT_C' : - initServ(result_cmd,'thermostatHC','set_setpointC',cmd); - break; - case 'THERMOSTAT_HC_SETPOINT_H' : - initServ(result_cmd,'thermostatHC','setpointH',cmd); - break; - case 'THERMOSTAT_HC_SETPOINT_C' : - initServ(result_cmd,'thermostatHC','setpointC',cmd); - break; - case 'THERMOSTAT_HC_SET_MODE' : - initServ(result_cmd,'thermostatHC','set_mode',cmd); - break; - case 'THERMOSTAT_HC_MODE' : - initServ(result_cmd,'thermostatHC','mode',cmd); - break; - case 'THERMOSTAT_HC_LOCK' : - initServ(result_cmd,'thermostatHC','lock',cmd); - break; - case 'THERMOSTAT_HC_SET_LOCK' : - initServ(result_cmd,'thermostatHC','set_lock',cmd); - break; - case 'THERMOSTAT_HC_SET_UNLOCK' : - initServ(result_cmd,'thermostatHC','set_unlock',cmd); - break; - /** ************* ALARME ***********************/ - case 'ALARM_STATE' : - initServ(result_cmd,'alarm','state',cmd); - break; - case 'ALARM_MODE' : - initServ(result_cmd,'alarm','mode',cmd); - break; - case 'ALARM_ENABLE_STATE' : - initServ(result_cmd,'alarm','enable_state',cmd); - break; - case 'ALARM_ARMED' : - initServ(result_cmd,'alarm','armed',cmd); - break; - case 'ALARM_RELEASED' : - initServ(result_cmd,'alarm','released',cmd); - break; - case 'ALARM_SET_MODE' : - initServ(result_cmd,'alarm','set_mode',cmd); - break; - /** *************** GENERIC ***********************/ - case 'AIRQUALITY_INDEX' : - initServ(result_cmd,'AirQuality','Index',cmd); - break; - case 'AIRQUALITY_PM25' : - initServ(result_cmd,'AirQuality','PM25',cmd); - break; - case 'AIRQUALITY_CUSTOM' : - initServ(result_cmd,'AirQualityCustom','Index',cmd); - break; - case 'NOISE' : - initServ(result_cmd,'Noise','Noise',cmd); - break; - case 'CO2' : - initServ(result_cmd,'CO2','CO2',cmd); - break; - case 'CO' : - initServ(result_cmd,'CO','CO',cmd); - break; - case 'OPENING_WINDOW' : - case 'OPENING' : - initServ(result_cmd,'opening','opening',cmd); - break; - case 'BATTERY' : - initServ(result_cmd,'battery','battery',cmd); - break; - case 'BATTERY_CHARGING' : // not existing yet - initServ(result_cmd,'battery','batteryCharging',cmd); - break; - case 'DEFECT' : - initServ(result_cmd,'defect','defect',cmd); - break; - case 'PRESENCE' : - initServ(result_cmd,'presence','presence',cmd); - result_cmd.numDetector++; - break; - case 'OCCUPANCY' : - initServ(result_cmd,'occupancy','occupancy',cmd); - result_cmd.numDetector++; - break; - case 'TEMPERATURE' : - initServ(result_cmd,'temperature','temperature',cmd); - break; - case 'BRIGHTNESS' : - initServ(result_cmd,'brightness','brightness',cmd); - break; - case 'SMOKE' : - initServ(result_cmd,'smoke','smoke',cmd); - break; - case 'UV' : // via custom - initServ(result_cmd,'uv','uv',cmd); - break; - case 'HUMIDITY' : - initServ(result_cmd,'humidity','humidity',cmd); - break; - case 'SABOTAGE' : - initServ(result_cmd,'sabotage','sabotage',cmd); - break; - case 'FLOOD' : - case 'WATER_LEAK' : - initServ(result_cmd,'flood','flood',cmd); - break; - case 'POWER' : // via custom - initServ(result_cmd,'power','power',cmd); - break; - case 'CONSUMPTION' : // via custom - initServ(result_cmd,'consumption','consumption',cmd); - break; - case 'ACTIVE' : - initServ(result_cmd,'status_active','status_active',cmd); - break; - case 'SPEAKER_VOLUME' : - case 'VOLUME' : - initServ(result_cmd,'speaker','volume',cmd); - break; - case 'SPEAKER_SET_VOLUME' : - case 'SET_VOLUME' : - initServ(result_cmd,'speaker','set_volume',cmd); - break; - case 'SPEAKER_MUTE' : - initServ(result_cmd,'speaker','mute',cmd); - break; - case 'SPEAKER_MUTE_TOGGLE' : - initServ(result_cmd,'speaker','mute_toggle',cmd); - break; - case 'SPEAKER_MUTE_ON' : - initServ(result_cmd,'speaker','mute_on',cmd); - break; - case 'SPEAKER_MUTE_OFF' : - initServ(result_cmd,'speaker','mute_off',cmd); - break; - case 'PRESSURE' : - initServ(result_cmd,'pressure','pressure',cmd); - break; + + if(cmd.generic_type === 'MODE_SET_STATE') { + if(cmd.logicalId === "returnPreviousMode") { + initServ(result_cmd,cmd,'mode','set_state_previous'); + } else { + initServ(result_cmd,cmd,'mode','set_state',true); + } + return; + } else if(cmd.generic_type === 'GENERIC_ACTION') { + if(cmd.subType=="other") { + initServ(result_cmd,cmd,'Push','Push'); + } + return; + } + + const serviceInfo = genTypesMapping[cmd.generic_type]; + if(!serviceInfo) {return;} + initServ(result_cmd, cmd, serviceInfo.serviceType, serviceInfo.property, serviceInfo.isPush || false); + + if(cmd.generic_type === 'PRESENCE') { + result_cmd.numDetector++; + } else if(cmd.generic_type === 'OCCUPANCY') { + result_cmd.numDetector++; + } else if(cmd.generic_type === 'SWITCH_STATE' || cmd.generic_type === 'CAMERA_RECORD_STATE') { + result_cmd.numSwitches++; } } }); return result_cmd; }; +const genTypesMapping = { + // *************** MODE *********************** + 'MODE_STATE': {serviceType: 'mode', property: 'state'}, + + // *************** LIGHT *********************** + 'LIGHT_STATE': {serviceType: 'light', property: 'state'}, + 'LIGHT_BRIGHTNESS': {serviceType: 'light', property: 'brightness'}, + 'LIGHT_STATE_BOOL': {serviceType: 'light', property: 'state_bool'}, + 'LIGHT_ON': {serviceType: 'light', property: 'on'}, + 'LIGHT_OFF': {serviceType: 'light', property: 'off'}, + 'LIGHT_SLIDER': {serviceType: 'light', property: 'slider'}, + 'LIGHT_COLOR': {serviceType: 'light', property: 'color'}, + 'LIGHT_COLOR_TEMP': {serviceType: 'light', property: 'color_temp'}, + 'LIGHT_SET_COLOR': {serviceType: 'light', property: 'setcolor'}, + 'LIGHT_SET_COLOR_TEMP': {serviceType: 'light', property: 'setcolor_temp'}, + + // *************** WEATHER *********************** + 'WEATHER_TEMPERATURE': {serviceType: 'weather', property: 'temperature'}, + 'WEATHER_HUMIDITY': {serviceType: 'weather', property: 'humidity'}, + 'WEATHER_PRESSURE': {serviceType: 'weather', property: 'pressure'}, + 'WEATHER_WIND_SPEED': {serviceType: 'weather', property: 'wind_speed'}, + 'WEATHER_WIND_DIRECTION': {serviceType: 'weather', property: 'wind_direction'}, + 'WEATHER_CONDITION': {serviceType: 'weather', property: 'condition'}, + 'WEATHER_UVINDEX': {serviceType: 'weather', property: 'UVIndex'}, + 'WEATHER_VISIBILITY': {serviceType: 'weather', property: 'visibility'}, + 'WEATHER_RAIN': {serviceType: 'weather', property: 'rain'}, + 'WEATHER_SNOW': {serviceType: 'weather', property: 'snow'}, + 'WEATHER_TEMPERATURE_MIN': {serviceType: 'weather', property: 'temperature_min'}, + + // *************** SIREN *********************** + 'SIREN_STATE': {serviceType: 'siren', property: 'state'}, + // 'SIREN_ON': {serviceType: 'siren', property: 'on'}, + // 'SIREN_OFF': {serviceType: 'siren', property: 'off'}, + + // *************** ENERGY *********************** + 'ENERGY_STATE': {serviceType: 'energy', property: 'state'}, + 'ENERGY_ON': {serviceType: 'energy', property: 'on'}, + 'ENERGY_OFF': {serviceType: 'energy', property: 'off'}, + 'ENERGY_INUSE': {serviceType: 'energy', property: 'inuse'}, + + // *************** VALVES *********************** + 'FAUCET_STATE': {serviceType: 'faucet', property: 'state'}, + 'FAUCET_ON': {serviceType: 'faucet', property: 'on'}, + 'FAUCET_OFF': {serviceType: 'faucet', property: 'off'}, + 'IRRIG_STATE': {serviceType: 'irrigation', property: 'state'}, + 'IRRIG_ON': {serviceType: 'irrigation', property: 'on'}, + 'IRRIG_OFF': {serviceType: 'irrigation', property: 'off'}, + 'VALVE_STATE': {serviceType: 'valve', property: 'state'}, + 'VALVE_ON': {serviceType: 'valve', property: 'on'}, + 'VALVE_OFF': {serviceType: 'valve', property: 'off'}, + 'VALVE_SET_DURATION': {serviceType: 'valve', property: 'setDuration'}, + 'VALVE_REMAINING_DURATION': {serviceType: 'valve', property: 'remainingDuration'}, + + // *************** FAN *********************** + 'FAN_STATE': {serviceType: 'fan', property: 'state'}, + 'FAN_SPEED_STATE': {serviceType: 'fan', property: 'state'}, + 'FAN_ON': {serviceType: 'fan', property: 'on'}, + 'FAN_OFF': {serviceType: 'fan', property: 'off'}, + 'FAN_SLIDER': {serviceType: 'fan', property: 'slider'}, + 'FAN_SPEED': {serviceType: 'fan', property: 'slider'}, + + // *************** SWITCH *********************** + 'SWITCH_STATE': {serviceType: 'Switch', property: 'state'}, + 'SWITCH_ON': {serviceType: 'Switch', property: 'on'}, + 'SWITCH_OFF': {serviceType: 'Switch', property: 'off'}, + 'CAMERA_RECORD_STATE': {serviceType: 'Switch', property: 'state'}, + 'CAMERA_RECORD': {serviceType: 'Switch', property: 'on'}, + 'CAMERA_STOP': {serviceType: 'Switch', property: 'off'}, + + // *************** PUSH *********************** + 'PUSH_BUTTON': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_UP': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_DOWN': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_LEFT': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_RIGHT': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_ZOOM': {serviceType: 'Push', property: 'Push'}, + 'CAMERA_DEZOOM':{serviceType: 'Push', property: 'Push'}, + 'CAMERA_PRESET':{serviceType: 'Push', property: 'Push'}, + + // *************** BARRIER/GARAGE************** + 'BARRIER_STATE': {serviceType: 'GarageDoor', property: 'state'}, + 'GARAGE_STATE': {serviceType: 'GarageDoor', property: 'state'}, + 'GB_OPEN': {serviceType: 'GarageDoor', property: 'on'}, // should not be used + 'GB_CLOSE': {serviceType: 'GarageDoor', property: 'off'}, // should not be used + 'GB_TOGGLE': {serviceType: 'GarageDoor', property: 'toggle'}, + + // *************** LOCK *********************** + 'LOCK_STATE': {serviceType: 'lock', property: 'state'}, + 'LOCK_OPEN': {serviceType: 'lock', property: 'on'}, + 'LOCK_CLOSE': {serviceType: 'lock', property: 'off'}, + + // *************** StatelessSwitch ****************** + 'SWITCH_STATELESS_ALLINONE':{serviceType: 'StatelessSwitch', property: 'eventType'}, + 'SWITCH_STATELESS_SINGLE': {serviceType: 'StatelessSwitchMono', property: 'Single'}, + 'SWITCH_STATELESS_DOUBLE': {serviceType: 'StatelessSwitchMono', property: 'Double'}, + 'SWITCH_STATELESS_LONG': {serviceType: 'StatelessSwitchMono', property: 'Long'}, + + // *************** FLAP *********************** + 'FLAP_STATE': {serviceType: 'flap', property: 'state'}, + 'FLAP_STATE_CLOSING': {serviceType: 'flap', property: 'stateClosing'}, + 'FLAP_UP': {serviceType: 'flap', property: 'up'}, + 'FLAP_DOWN': {serviceType: 'flap', property: 'down'}, + 'FLAP_SLIDER': {serviceType: 'flap', property: 'slider'}, + 'FLAP_STOP': {serviceType: 'flap', property: 'stop'}, + 'FLAP_HOR_TILT_STATE': {serviceType: 'flap', property: 'HorTiltState'}, + 'FLAP_HOR_TILT_SLIDER': {serviceType: 'flap', property: 'HorTiltSlider'}, + 'FLAP_VER_TILT_STATE': {serviceType: 'flap', property: 'VerTiltState'}, + 'FLAP_VER_TILT_SLIDER': {serviceType: 'flap', property: 'VerTiltSlider'}, + + // *************** WINDOW *********************** + 'WINDOW_STATE': {serviceType: 'windowMoto', property: 'state'}, + 'WINDOW_UP': {serviceType: 'windowMoto', property: 'up'}, + 'WINDOW_DOWN': {serviceType: 'windowMoto', property: 'down'}, + 'WINDOW_SLIDER':{serviceType: 'windowMoto', property: 'slider'}, + + // ************* THERMOSTAT *********************** + 'THERMOSTAT_STATE': {serviceType: 'thermostat', property: 'state'}, + 'THERMOSTAT_STATE_NAME': {serviceType: 'thermostat', property: 'state_name'}, + 'THERMOSTAT_TEMPERATURE': {serviceType: 'thermostat', property: 'temperature'}, + 'THERMOSTAT_SET_SETPOINT': {serviceType: 'thermostat', property: 'set_setpoint'}, + 'THERMOSTAT_SETPOINT': {serviceType: 'thermostat', property: 'setpoint'}, + 'THERMOSTAT_SET_MODE': {serviceType: 'thermostat', property: 'set_mode'}, + 'THERMOSTAT_MODE': {serviceType: 'thermostat', property: 'mode'}, + 'THERMOSTAT_LOCK': {serviceType: 'thermostat', property: 'lock'}, + 'THERMOSTAT_SET_LOCK': {serviceType: 'thermostat', property: 'set_lock'}, + 'THERMOSTAT_SET_UNLOCK': {serviceType: 'thermostat', property: 'set_unlock'}, + 'THERMOSTAT_TEMPERATURE_OUTDOOR': {serviceType: 'thermostat', property: 'temperature_outdoor'}, + + // ************* THERMOSTAT_HC *********************** + 'THERMOSTAT_HC_STATE': {serviceType: 'thermostatHC', property: 'state'}, + 'THERMOSTAT_HC_STATE_NAME': {serviceType: 'thermostatHC', property: 'state_name'}, + 'THERMOSTAT_HC_TEMPERATURE': {serviceType: 'thermostatHC', property: 'temperature'}, + 'THERMOSTAT_HC_SET_SETPOINT_H': {serviceType: 'thermostatHC', property: 'set_setpointH'}, + 'THERMOSTAT_HC_SET_SETPOINT_C': {serviceType: 'thermostatHC', property: 'set_setpointC'}, + 'THERMOSTAT_HC_SETPOINT_H': {serviceType: 'thermostatHC', property: 'setpointH'}, + 'THERMOSTAT_HC_SETPOINT_C': {serviceType: 'thermostatHC', property: 'setpointC'}, + 'THERMOSTAT_HC_SET_MODE': {serviceType: 'thermostatHC', property: 'set_mode'}, + 'THERMOSTAT_HC_MODE': {serviceType: 'thermostatHC', property: 'mode'}, + 'THERMOSTAT_HC_LOCK': {serviceType: 'thermostatHC', property: 'lock'}, + 'THERMOSTAT_HC_SET_LOCK': {serviceType: 'thermostatHC', property: 'set_lock'}, + 'THERMOSTAT_HC_SET_UNLOCK': {serviceType: 'thermostatHC', property: 'set_unlock'}, + + // ************* ALARME *********************** + 'ALARM_STATE': {serviceType: 'alarm', property: 'state'}, + 'ALARM_MODE': {serviceType: 'alarm', property: 'mode'}, + 'ALARM_ENABLE_STATE': {serviceType: 'alarm', property: 'enable_state'}, + 'ALARM_ARMED': {serviceType: 'alarm', property: 'armed'}, + 'ALARM_RELEASED': {serviceType: 'alarm', property: 'released'}, + 'ALARM_SET_MODE': {serviceType: 'alarm', property: 'set_mode'}, + + // ************* SPEAKER *********************** + 'SPEAKER_VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'VOLUME': {serviceType: 'speaker', property: 'volume'}, + 'SPEAKER_SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, + 'SET_VOLUME': {serviceType: 'speaker', property: 'set_volume'}, + 'SPEAKER_MUTE': {serviceType: 'speaker', property: 'mute'}, + 'SPEAKER_MUTE_TOGGLE': {serviceType: 'speaker', property: 'mute_toggle'}, + 'SPEAKER_MUTE_ON': {serviceType: 'speaker', property: 'mute_on'}, + 'SPEAKER_MUTE_OFF': {serviceType: 'speaker', property: 'mute_off'}, + + // *************** GENERIC *********************** + 'AIRQUALITY_INDEX': {serviceType: 'AirQuality', property: 'Index'}, + 'AIRQUALITY_PM25': {serviceType: 'AirQuality', property: 'PM25'}, + 'AIRQUALITY_CUSTOM':{serviceType: 'AirQualityCustom', property: 'Index'}, + 'NOISE': {serviceType: 'Noise', property: 'Noise'}, + 'CO2': {serviceType: 'CO2', property: 'CO2'}, + 'CO': {serviceType: 'CO', property: 'CO'}, + 'OPENING_WINDOW': {serviceType: 'opening', property: 'opening'}, + 'OPENING': {serviceType: 'opening', property: 'opening'}, + 'BATTERY': {serviceType: 'battery', property: 'battery'}, + 'BATTERY_CHARGING': {serviceType: 'battery', property: 'batteryCharging'}, // not existing yet + 'DEFECT': {serviceType: 'defect', property: 'defect'}, + 'PRESENCE': {serviceType: 'presence', property: 'presence'}, + 'OCCUPANCY': {serviceType: 'occupancy', property: 'occupancy'}, + 'TEMPERATURE': {serviceType: 'temperature', property: 'temperature'}, + 'BRIGHTNESS': {serviceType: 'brightness', property: 'brightness'}, + 'SMOKE': {serviceType: 'smoke', property: 'smoke'}, + 'UV': {serviceType: 'uv', property: 'uv'}, // via custom + 'HUMIDITY': {serviceType: 'humidity', property: 'humidity'}, + 'SABOTAGE': {serviceType: 'sabotage', property: 'sabotage'}, + 'FLOOD': {serviceType: 'flood', property: 'flood'}, + 'WATER_LEAK': {serviceType: 'flood', property: 'flood'}, + 'POWER': {serviceType: 'power', property: 'power'}, // via custom + 'CONSUMPTION': {serviceType: 'consumption', property: 'consumption'}, // via custom + 'ACTIVE': {serviceType: 'status_active', property: 'status_active'}, + 'PRESSURE': {serviceType: 'pressure', property: 'pressure'}, + 'SHOCK': {serviceType: 'generic', property: 'state'}, + 'RAIN_CURRENT': {serviceType: 'generic', property: 'state'}, + 'RAIN_TOTAL': {serviceType: 'generic', property: 'state'}, + 'WIND_SPEED': {serviceType: 'generic', property: 'state'}, + 'WIND_DIRECTION': {serviceType: 'generic', property: 'state'}, + 'GENERIC_INFO': {serviceType: 'generic', property: 'state'}, +}; + module.exports.createClient = function(url, apikey, Plateform,myPlugin) { return new JeedomClient(url, apikey, Plateform,myPlugin); };