Compare commits

..

4 Commits

View File

@@ -1745,7 +1745,8 @@
"8a84615173fd7e97",
"f260e2410571356a",
"b497fe229c8f2eea",
"f47a0d107875d550"
"f47a0d107875d550",
"f34011787b8474ef"
],
"x": 34,
"y": 139,
@@ -3016,10 +3017,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,
@@ -24928,7 +24931,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,
@@ -34678,6 +34681,38 @@
[]
]
},
{
"id": "f34011787b8474ef",
"type": "inject",
"z": "ebd5561c4f077718",
"g": "4329e464360d0afa",
"name": "Manual Trigger",
"props": [
{
"p": "payload"
},
{
"p": "duration",
"v": "10",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "on",
"payloadType": "str",
"x": 160,
"y": 300,
"wires": [
[
"70f795fb061cbfef",
"b2c0d6629b2603b7"
]
]
},
{
"id": "1f7af146c06b8b85",
"type": "ha-select",