Compare commits

...

4 Commits

View File

@@ -2861,12 +2861,13 @@
"334c28e08be1db12",
"de09ef54cbab864a",
"5c919106ebd7c9d4",
"75072695f27adae7"
"75072695f27adae7",
"12e0c7c54a58f849"
],
"x": 54,
"y": 239,
"w": 1092,
"h": 322
"h": 382
},
{
"id": "7d1c0a1099be4427",
@@ -3015,10 +3016,12 @@
"id": "9e87348d.9c1c48",
"type": "server",
"name": "Home Assistant",
"version": 5,
"version": 6,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "",
"ha_boolean": [
""
],
"connectionDelay": false,
"cacheJson": false,
"heartbeat": false,
@@ -24927,7 +24930,7 @@
"z": "72f99805df043603",
"g": "5802ea32c1de36e8",
"name": "Watchdog",
"func": "const states = global.get('homeassistant.homeAssistant.states')\nconst sleeping = states['input_boolean.emma_sleeping'].state\n\nif (sleeping !== 'on') {\n node.status({fill:'red',shape:'ring',text:'Emma not sleeping, watchdog disabled'})\n return null\n}\n\nconst airconEntity = ['climate.emma_bedroom_aircon']\n\n// Gather relevant attributes from the aircon entity\n\nconst airconState = msg.payload.state\nconst airconAttributes = msg.payload.attributes\nconst airconEco = airconAttributes['eco_mode']\nconst airconTargetTemp = airconAttributes['temperature']\nconst airconFanMode = airconAttributes['fan_mode']\nconst airconDisplay = airconAttributes['screen_display']\n\n// Gather the last explicitly sent configuration from the context\n\nconst airconHvacCfg = flow.get('emmaBedroom.airconHvacMode', 'diskCon')\nconst airconEcoCfg = flow.get('emmaBedroom.airconEco', 'diskCon')\nconst airconTargetTempCfg = parseFloat(flow.get('emmaBedroom.airconTargetTemp', 'diskCon'))\nconst airconFanModeCfg = flow.get('emmaBedroom.airconFanMode', 'diskCon')\nconst airconDisplayCfg = flow.get('emmaBedroom.airconDisplay', 'diskCon')\n\n// Compare the current state with the last sent configuration\n\nlet ecoMatch = {}\nlet displayMatch = {}\nlet counter = 0\n\nlet sendDisplay = {\n \"payload\": {\n \"action\": `switch.${airconDisplayCfg}`,\n \"target\": {\n \"entity_id\": [\"switch.emma_bedroom_aircon_display\"]\n },\n \"data\": {}\n }\n}\n\nlet sendHvac = {\n \"payload\": {\n \"action\": \"climate.set_hvac_mode\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"hvac_mode\": airconHvacCfg\n }\n }\n}\n\nlet sendTemp = {\n \"payload\": {\n \"action\": \"climate.set_temperature\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"temperature\": airconTargetTempCfg\n }\n }\n}\n\nlet sendEco = {\n \"payload\": {\n \"action\": `switch.${airconEcoCfg}`,\n \"target\": {\n \"entity_id\": [\"switch.emma_bedroom_aircon_eco_mode\"]\n },\n \"data\": {}\n }\n}\n\nlet sendAcFan = {\n \"payload\": {\n \"action\": \"climate.set_fan_mode\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"fan_mode\": airconFanModeCfg\n }\n }\n}\n\n// Fix hvac mode if mismatch\n\nif (airconState != airconHvacCfg) {\n node.log(`Emma Bedroom Aircon HVAC mode mismatch: ${airconState} vs ${airconHvacCfg}`)\n node.send(sendHvac)\n counter += 1\n}\n\n// Fix eco mode if mismatch\n\nif (airconEco === false && airconEcoCfg === 'turn_off') {\n ecoMatch = true\n} else if (airconEco === true && airconEcoCfg === 'turn_on') {\n ecoMatch = true\n} else {\n ecoMatch = false\n}\n\nif (ecoMatch === false) {\n node.log(`Emma Bedroom Aircon Eco mode mismatch: ${airconEco} vs ${airconEcoCfg}`)\n node.send(sendEco)\n counter += 1\n}\n\n// Fix target temperature if mismatch\n\nif (airconTargetTemp != airconTargetTempCfg) {\n node.log(`Target temperature mismatch: ${airconTargetTemp} vs ${airconTargetTempCfg}`)\n node.send(sendTemp)\n counter += 1\n}\n\n// Fix fan mode if mismatch\n\nif (airconFanMode != airconFanModeCfg) {\n node.log(`Fan mode mismatch: ${airconFanMode} vs ${airconFanModeCfg}`)\n node.send(sendAcFan)\n counter += 1\n}\n\n// Fix display mode if mismatch\n\nif (airconDisplay === false && airconDisplayCfg === 'turn_off') {\n displayMatch = true\n} else if (airconDisplay === true && airconDisplayCfg === 'turn_on') {\n displayMatch = true\n} else {\n displayMatch = false\n}\n\nif (displayMatch === false) {\n node.log(`Emma Bedroom Aircon Display mode mismatch: ${airconDisplay} vs ${airconDisplayCfg}`)\n node.send(sendDisplay)\n counter += 1\n}\n\nif (counter > 0) {\n node.log(`Emma Bedroom Aircon: ${counter} configuration(s) fixed`)\n node.status({fill:'yellow',shape:'dot',text:`${counter} config(s) fixed`})\n} else {\n node.status({fill:'green',shape:'dot',text:`No config changes`})\n}",
"func": "const states = global.get('homeassistant.homeAssistant.states')\n\n// Check if all settings support aircon usage\n\nconst ac = global.get('emmaBedroom.aircon.installed', \"diskCon\")\nconst allowed = states['input_boolean.emma_bedroom_climate_protocol'].state\nconst schedMode = states['input_select.scheduled_climate_mode_emma_bedroom'].state\nconst coolingActive = states[\"input_boolean.emma_bedroom_cooling_on\"].state\nconst sleeping = states[\"input_boolean.emma_sleeping\"].state\n\nlet proceed = false\n\nif (ac === 'on' && allowed === 'on' && schedMode === 'AC' && coolingActive === 'on') {\n proceed = true\n}\n\nif (sleeping != 'on') {\n node.status({fill:'red',shape:'ring',text:'Emma not sleeping, watchdog disabled'})\n return null\n} else if (proceed === false) {\n node.status({fill:'red',shape:'ring',text:'Aircon not in use, watchdog disabled'})\n return null\n}\n\n// Gather relevant attributes from the aircon entity\n\nconst airconEntity = ['climate.emma_bedroom_aircon']\nconst airconState = msg.payload.state\nconst airconAttributes = msg.payload.attributes\nconst airconEco = airconAttributes['eco_mode']\nconst airconTargetTemp = airconAttributes['temperature']\nconst airconFanMode = airconAttributes['fan_mode']\nconst airconDisplay = airconAttributes['screen_display']\n\n// Gather the last explicitly sent configuration from the context\n\nconst airconHvacCfg = flow.get('emmaBedroom.airconHvacMode', 'diskCon')\nconst airconEcoCfg = flow.get('emmaBedroom.airconEco', 'diskCon')\nconst airconTargetTempCfg = parseFloat(flow.get('emmaBedroom.airconTargetTemp', 'diskCon'))\nconst airconFanModeCfg = flow.get('emmaBedroom.airconFanMode', 'diskCon')\nconst airconDisplayCfg = flow.get('emmaBedroom.airconDisplay', 'diskCon')\n\n// Compare the current state with the last sent configuration\n\nlet ecoMatch = {}\nlet displayMatch = {}\nlet counter = 0\n\nlet sendDisplay = {\n \"payload\": {\n \"action\": `switch.${airconDisplayCfg}`,\n \"target\": {\n \"entity_id\": [\"switch.emma_bedroom_aircon_display\"]\n },\n \"data\": {}\n }\n}\n\nlet sendHvac = {\n \"payload\": {\n \"action\": \"climate.set_hvac_mode\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"hvac_mode\": airconHvacCfg\n }\n }\n}\n\nlet sendTemp = {\n \"payload\": {\n \"action\": \"climate.set_temperature\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"temperature\": airconTargetTempCfg\n }\n }\n}\n\nlet sendEco = {\n \"payload\": {\n \"action\": `switch.${airconEcoCfg}`,\n \"target\": {\n \"entity_id\": [\"switch.emma_bedroom_aircon_eco_mode\"]\n },\n \"data\": {}\n }\n}\n\nlet sendAcFan = {\n \"payload\": {\n \"action\": \"climate.set_fan_mode\",\n \"target\": {\n \"entity_id\": airconEntity\n },\n \"data\": {\n \"fan_mode\": airconFanModeCfg\n }\n }\n}\n\n// Fix hvac mode if mismatch\n\nif (airconState != airconHvacCfg) {\n node.log(`Emma Bedroom Aircon HVAC mode mismatch: ${airconState} vs ${airconHvacCfg}`)\n node.send(sendHvac)\n counter += 1\n}\n\n// Fix eco mode if mismatch\n\nif (airconEco === false && airconEcoCfg === 'turn_off') {\n ecoMatch = true\n} else if (airconEco === true && airconEcoCfg === 'turn_on') {\n ecoMatch = true\n} else {\n ecoMatch = false\n}\n\nif (ecoMatch === false) {\n node.log(`Emma Bedroom Aircon Eco mode mismatch: ${airconEco} vs ${airconEcoCfg}`)\n node.send(sendEco)\n counter += 1\n}\n\n// Fix target temperature if mismatch\n\nif (airconTargetTemp != airconTargetTempCfg) {\n node.log(`Target temperature mismatch: ${airconTargetTemp} vs ${airconTargetTempCfg}`)\n node.send(sendTemp)\n counter += 1\n}\n\n// Fix fan mode if mismatch\n\nif (airconFanMode != airconFanModeCfg) {\n node.log(`Fan mode mismatch: ${airconFanMode} vs ${airconFanModeCfg}`)\n node.send(sendAcFan)\n counter += 1\n}\n\n// Fix display mode if mismatch\n\nif (airconDisplay === false && airconDisplayCfg === 'turn_off') {\n displayMatch = true\n} else if (airconDisplay === true && airconDisplayCfg === 'turn_on') {\n displayMatch = true\n} else {\n displayMatch = false\n}\n\nif (displayMatch === false) {\n node.log(`Emma Bedroom Aircon Display mode mismatch: ${airconDisplay} vs ${airconDisplayCfg}`)\n node.send(sendDisplay)\n counter += 1\n}\n\nif (counter > 0) {\n node.log(`Emma Bedroom Aircon: ${counter} configuration(s) fixed`)\n node.status({fill:'yellow',shape:'dot',text:`${counter} config(s) fixed`})\n} else {\n node.status({fill:'green',shape:'dot',text:`No config changes`})\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
@@ -28230,8 +28233,9 @@
"09c7a61f7a4c4d05",
"60ce44747cf3e507",
"50e351d1ee6108b3",
"f30486c8e11db0e4",
"334c28e08be1db12"
"334c28e08be1db12",
"20b3699a56b0e901",
"12e0c7c54a58f849"
]
]
},
@@ -28263,12 +28267,10 @@
"blockInputOverrides": false,
"domain": "switch",
"service": "turn_on",
"x": 680,
"y": 460,
"x": 880,
"y": 520,
"wires": [
[
"20b3699a56b0e901"
]
[]
]
},
{
@@ -28296,7 +28298,7 @@
"domain": "script",
"service": "turn_on",
"x": 890,
"y": 520,
"y": 580,
"wires": [
[]
]
@@ -28328,7 +28330,7 @@
"blockInputOverrides": false,
"domain": "input_boolean",
"service": "turn_off",
"x": 930,
"x": 730,
"y": 460,
"wires": [
[]
@@ -28429,7 +28431,7 @@
"finalize": "",
"libs": [],
"x": 680,
"y": 520,
"y": 580,
"wires": [
[
"9bd4665845af0545"
@@ -28878,6 +28880,56 @@
],
"l": false
},
{
"id": "12e0c7c54a58f849",
"type": "api-current-state",
"z": "9824adcf61e30734",
"g": "f4057835848d0904",
"name": "Quiet Time?",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "binary_sensor.quiet_time",
"state_type": "str",
"blockInputOverrides": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 670,
"y": 520,
"wires": [
[
"f30486c8e11db0e4"
],
[]
],
"outputLabels": [
"On",
"Off"
]
},
{
"id": "6f84caa4bd59a747",
"type": "ha-button",