Bump version to 0.1.3
This commit is contained in:
		@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@vvzvlad/node-red-contrib-rn-combined-nodes",
 | 
					  "name": "@vvzvlad/node-red-contrib-rn-combined-nodes",
 | 
				
			||||||
  "version": "0.1.2",
 | 
					  "version": "0.1.3",
 | 
				
			||||||
  "description": "",
 | 
					  "description": "",
 | 
				
			||||||
  "main": "index.js",
 | 
					  "main": "index.js",
 | 
				
			||||||
  "keywords": [
 | 
					  "keywords": [
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										133
									
								
								thermostat.js
									
									
									
									
									
								
							
							
						
						
									
										133
									
								
								thermostat.js
									
									
									
									
									
								
							@ -45,70 +45,6 @@ module.exports = function(RED) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function logic() {
 | 
					 | 
				
			||||||
            if (control_mode === "off") {
 | 
					 | 
				
			||||||
                heater_status = 0
 | 
					 | 
				
			||||||
                debug_text("Heater: force/off")
 | 
					 | 
				
			||||||
                return
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (control_mode === "on") {
 | 
					 | 
				
			||||||
                heater_status = 1
 | 
					 | 
				
			||||||
                debug_text("Heater: force/on")
 | 
					 | 
				
			||||||
                return
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (control_mode === "auto-predict" && current_temp !== null && target_temp !== null) {
 | 
					 | 
				
			||||||
                const predicted_temp = predict_temp_change(current_temp, 40)
 | 
					 | 
				
			||||||
                if (window_state === "open" && window_mode === "cool") {
 | 
					 | 
				
			||||||
                    heater_status = 0
 | 
					 | 
				
			||||||
                    debug_text("Heater: w-open-cool/off")
 | 
					 | 
				
			||||||
                    return
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (window_state === "open" && window_mode === "heat") {
 | 
					 | 
				
			||||||
                    heater_status = 1
 | 
					 | 
				
			||||||
                    debug_text("Heater: w-open-heat/on")
 | 
					 | 
				
			||||||
                    return
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (window_state === "close") {
 | 
					 | 
				
			||||||
                    if (predicted_temp < target_temp) {
 | 
					 | 
				
			||||||
                        heater_status = 1
 | 
					 | 
				
			||||||
                        debug_text(`Heater: auto-predict/${"on"}`)
 | 
					 | 
				
			||||||
                    } else if (predicted_temp >= target_temp) {
 | 
					 | 
				
			||||||
                        heater_status = 0
 | 
					 | 
				
			||||||
                        debug_text(`Heater: auto-predict/${"off"}`)
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (control_mode === "auto" && current_temp !== null && target_temp !== null) {
 | 
					 | 
				
			||||||
                if (window_state === "open" && window_mode === "cool") {
 | 
					 | 
				
			||||||
                    heater_status = 0
 | 
					 | 
				
			||||||
                    debug_text("Heater: w-open-cool/off")
 | 
					 | 
				
			||||||
                    return
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (window_state === "open" && window_mode === "heat") {
 | 
					 | 
				
			||||||
                    heater_status = 1
 | 
					 | 
				
			||||||
                    debug_text("Heater: w-open-heat/on")
 | 
					 | 
				
			||||||
                    return
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (window_state === "close") {
 | 
					 | 
				
			||||||
                    if (current_temp <= target_temp - HEAT_ON_THRESHOLD) {
 | 
					 | 
				
			||||||
                        heater_status = 1
 | 
					 | 
				
			||||||
                        debug_text(`Heater: auto/${"on"}`)
 | 
					 | 
				
			||||||
                    } else if (current_temp >= target_temp + HEAT_OFF_THRESHOLD) {
 | 
					 | 
				
			||||||
                        heater_status = 0
 | 
					 | 
				
			||||||
                        debug_text(`Heater: auto/${"off"}`)
 | 
					 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        debug_text(`Heater: auto/${"hyst"}`)
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        node.on('input', function(msg) {
 | 
					        node.on('input', function(msg) {
 | 
				
			||||||
            let topic = msg.topic
 | 
					            let topic = msg.topic
 | 
				
			||||||
@ -121,6 +57,75 @@ module.exports = function(RED) {
 | 
				
			|||||||
            let window_mode = context.get("window_mode") || "cool" //heat, cool, off
 | 
					            let window_mode = context.get("window_mode") || "cool" //heat, cool, off
 | 
				
			||||||
            let heater_status = null
 | 
					            let heater_status = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            function logic() {
 | 
				
			||||||
 | 
					                if (control_mode === "off") {
 | 
				
			||||||
 | 
					                    heater_status = 0
 | 
				
			||||||
 | 
					                    debug_text("Heater: force/off")
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (control_mode === "on") {
 | 
				
			||||||
 | 
					                    heater_status = 1
 | 
				
			||||||
 | 
					                    debug_text("Heater: force/on")
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (control_mode === "auto-predict" && current_temp !== null && target_temp !== null) {
 | 
				
			||||||
 | 
					                    const predicted_temp = predict_temp_change(current_temp, 40)
 | 
				
			||||||
 | 
					                    if (window_state === "open" && window_mode === "cool") {
 | 
				
			||||||
 | 
					                        heater_status = 0
 | 
				
			||||||
 | 
					                        debug_text("Heater: w-open-cool/off")
 | 
				
			||||||
 | 
					                        return
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (window_state === "open" && window_mode === "heat") {
 | 
				
			||||||
 | 
					                        heater_status = 1
 | 
				
			||||||
 | 
					                        debug_text("Heater: w-open-heat/on")
 | 
				
			||||||
 | 
					                        return
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (window_state === "close") {
 | 
				
			||||||
 | 
					                        if (predicted_temp < target_temp) {
 | 
				
			||||||
 | 
					                            heater_status = 1
 | 
				
			||||||
 | 
					                            debug_text(`Heater: auto-predict/${"on"}`)
 | 
				
			||||||
 | 
					                        } else if (predicted_temp >= target_temp) {
 | 
				
			||||||
 | 
					                            heater_status = 0
 | 
				
			||||||
 | 
					                            debug_text(`Heater: auto-predict/${"off"}`)
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (control_mode === "auto" && current_temp !== null && target_temp !== null) {
 | 
				
			||||||
 | 
					                    if (window_state === "open" && window_mode === "cool") {
 | 
				
			||||||
 | 
					                        heater_status = 0
 | 
				
			||||||
 | 
					                        debug_text("Heater: w-open-cool/off")
 | 
				
			||||||
 | 
					                        return
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (window_state === "open" && window_mode === "heat") {
 | 
				
			||||||
 | 
					                        heater_status = 1
 | 
				
			||||||
 | 
					                        debug_text("Heater: w-open-heat/on")
 | 
				
			||||||
 | 
					                        return
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (window_state === "close") {
 | 
				
			||||||
 | 
					                        if (current_temp <= target_temp - HEAT_ON_THRESHOLD) {
 | 
				
			||||||
 | 
					                            heater_status = 1
 | 
				
			||||||
 | 
					                            debug_text(`Heater: auto/${"on"}`)
 | 
				
			||||||
 | 
					                        } else if (current_temp >= target_temp + HEAT_OFF_THRESHOLD) {
 | 
				
			||||||
 | 
					                            heater_status = 0
 | 
				
			||||||
 | 
					                            debug_text(`Heater: auto/${"off"}`)
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            debug_text(`Heater: auto/${"hyst"}`)
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            debug_text(`W-mode: ${window_mode}`)
 | 
					            debug_text(`W-mode: ${window_mode}`)
 | 
				
			||||||
            if (topic === "window_mode_control" && (payload === "cool" || payload === "heat" || payload === "off")) {
 | 
					            if (topic === "window_mode_control" && (payload === "cool" || payload === "heat" || payload === "off")) {
 | 
				
			||||||
                window_mode = payload
 | 
					                window_mode = payload
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user