little udpate
This commit is contained in:
		
							parent
							
								
									dc97e5fe62
								
							
						
					
					
						commit
						421b6ff7e1
					
				@ -16,7 +16,7 @@ module.exports = {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            response = await got('https://public.wcs.schneider-electric.ws/rpc/public_genie/' + url, options);
 | 
					            let response = await got('https://public.wcs.schneider-electric.ws/rpc/public_genie/' + url, options);
 | 
				
			||||||
            const res = JSON.parse(response.body)
 | 
					            const res = JSON.parse(response.body)
 | 
				
			||||||
            logger.debug(url + " - ZONES - " + res.updateData.zones.length)
 | 
					            logger.debug(url + " - ZONES - " + res.updateData.zones.length)
 | 
				
			||||||
            if (res.updateData.zones.length < 2) {
 | 
					            if (res.updateData.zones.length < 2) {
 | 
				
			||||||
@ -25,7 +25,7 @@ module.exports = {
 | 
				
			|||||||
            return res
 | 
					            return res
 | 
				
			||||||
        } catch (error) {
 | 
					        } catch (error) {
 | 
				
			||||||
            logger.warn('-- post error --');
 | 
					            logger.warn('-- post error --');
 | 
				
			||||||
            logger.crit(JSON.stringify(response))
 | 
					            logger.crit(JSON.stringify(error))
 | 
				
			||||||
            logger.warn('-- post error --');
 | 
					            logger.warn('-- post error --');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ let logger = require('perfect-logger')
 | 
				
			|||||||
module.exports = function (app) {
 | 
					module.exports = function (app) {
 | 
				
			||||||
    app.post("/water/switch", async function (req, res, next) {
 | 
					    app.post("/water/switch", async function (req, res, next) {
 | 
				
			||||||
        logger.debug('POST - /water/switch - START')
 | 
					        logger.debug('POST - /water/switch - START')
 | 
				
			||||||
        if (req.body.switch === 1) {
 | 
					        if (req.body.switch === "1") {
 | 
				
			||||||
            logger.debug('POST - /water/switch - ON - START')
 | 
					            logger.debug('POST - /water/switch - ON - START')
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                await post.postRequest('{"zoneId":[1],"setPoint": 255,"durationMinutes": 90}', 'apply_timer')
 | 
					                await post.postRequest('{"zoneId":[1],"setPoint": 255,"durationMinutes": 90}', 'apply_timer')
 | 
				
			||||||
@ -22,7 +22,7 @@ module.exports = function (app) {
 | 
				
			|||||||
            } catch (error) {
 | 
					            } catch (error) {
 | 
				
			||||||
                logger.warn('POST - /water/switch - ON - FAILED')
 | 
					                logger.warn('POST - /water/switch - ON - FAILED')
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (req.body.switch === 0) {
 | 
					        } else if (req.body.switch === "0") {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                logger.debug('POST - /water/switch - OFF - START')
 | 
					                logger.debug('POST - /water/switch - OFF - START')
 | 
				
			||||||
                await post.postRequest('{"zoneId":[1]}', 'cancel_timer')
 | 
					                await post.postRequest('{"zoneId":[1]}', 'cancel_timer')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user