Here you go - its not pretty but I’m hoping you can make sense of it!
If you improve on it please let me know.
Also there may be bit in there which are not used as I did create this from scratch!
Cheers
[
{
“id”: “58fb255f.a2c42c”,
“type”: “subflow”,
“name”: “Notify”,
“info”: “”,
“category”: “”,
“in”: [
{
“x”: 52,
“y”: 96,
“wires”: [
{
“id”: “ece283f.37e9d8”
}
]
}
],
“out”: []
},
{
“id”: “ece283f.37e9d8”,
“type”: “mqtt out”,
“z”: “58fb255f.a2c42c”,
“name”: “Zanzito notify “,
“topic”: “zanzito/my_mobile/notification”,
“qos”: “1”,
“retain”: “false”,
“broker”: “3657a96b.ad3c36”,
“x”: 212,
“y”: 96,
“wires”: []
},
{
“id”: “3657a96b.ad3c36”,
“type”: “mqtt-broker”,
“z”: “”,
“name”: “MQTT Broker 1”,
“broker”: “”,
“port”: “1883”,
“tls”: “”,
“clientid”: “”,
“usetls”: false,
“compatmode”: true,
“keepalive”: “60”,
“cleansession”: true,
“birthTopic”: “”,
“birthQos”: “0”,
“birthPayload”: “”,
“closeTopic”: “”,
“closeQos”: “0”,
“closePayload”: “”,
“willTopic”: “”,
“willQos”: “0”,
“willPayload”: “”
},
{
“id”: “e3c94631.4af248”,
“type”: “tab”,
“label”: “Ensuite”,
“disabled”: false,
“info”: “”
},
{
“id”: “8cd2cc14.6cc58”,
“type”: “time-range-switch”,
“z”: “e3c94631.4af248”,
“name”: “”,
“lat”: “LAT”,
“lon”: “LON”,
“startTime”: “06:15”,
“endTime”: “22:30”,
“startOffset”: 0,
“endOffset”: 0,
“x”: 326,
“y”: 80,
“wires”: [
[
“88a27c2a.18f19”
],
[
“f6fe16a.3760ee8”
]
]
},
{
“id”: “9fd58e6e.1b5c3”,
“type”: “template”,
“z”: “e3c94631.4af248”,
“name”: “Compile Message”,
“field”: “payload”,
“fieldType”: “msg”,
“format”: “handlebars”,
“syntax”: “mustache”,
“template”: “{ “title”:“Ensuite Fan | New”, “message”:”{{payload}}”}”,
“output”: “str”,
“x”: 1010,
“y”: 40,
“wires”: [
[
“3e65d85b.86c128”
]
]
},
{
“id”: “3e65d85b.86c128”,
“type”: “rbe”,
“z”: “e3c94631.4af248”,
“name”: “”,
“func”: “rbe”,
“gap”: “”,
“start”: “”,
“inout”: “out”,
“property”: “payload”,
“x”: 1090,
“y”: 120,
“wires”: [
[
“234775cc.cf53ca”
]
]
},
{
“id”: “f8bf0eb2.25519”,
“type”: “change”,
“z”: “e3c94631.4af248”,
“name”: “flow.ensuite_humidity_type”,
“rules”: [
{
“t”: “set”,
“p”: “ensuite_humidity_type”,
“pt”: “flow”,
“to”: “payload”,
“tot”: “msg”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 712,
“y”: 304,
“wires”: [
[
“6cffe154.dda9f”
]
]
},
{
“id”: “6cffe154.dda9f”,
“type”: “debug”,
“z”: “e3c94631.4af248”,
“name”: “rising?”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “true”,
“x”: 962,
“y”: 304,
“wires”: []
},
{
“id”: “96227205.2f8d4”,
“type”: “trigger”,
“z”: “e3c94631.4af248”,
“op1”: “”,
“op2”: “1”,
“op1type”: “nul”,
“op2type”: “str”,
“duration”: “1”,
“extend”: true,
“units”: “hr”,
“reset”: “”,
“bytopic”: “all”,
“name”: “”,
“x”: 598,
“y”: 128,
“wires”: [
[
“f6fe16a.3760ee8”
]
]
},
{
“id”: “32776592.229faa”,
“type”: “function”,
“z”: “e3c94631.4af248”,
“name”: "Humidity > ",
“func”: “var ensuite_hum_old = flow.get(“ensuite_humidity_old”);\nvar ensuite_hum_new = flow.get(“ensuite_humidity_new”);\nvar ensuite_hum_difference = ensuite_hum_new - ensuite_hum_old;\nflow.set(“ensuite_hum_difference”, ensuite_hum_difference );\nvar ensuite_hum_percentage = (ensuite_hum_difference / ensuite_hum_old) * 100;\nflow.set(“ensuite_hum_percentage”, ensuite_hum_percentage );\nif (ensuite_hum_percentage > 8){ \n msg.payload = “rising”;\n}else if(ensuite_hum_percentage < -2){\n msg.payload = “falling”;\n}else {\n msg.payload = “stagnant”;\n}\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 438,
“y”: 320,
“wires”: [
[
“f8bf0eb2.25519”
]
],
“outputLabels”: [
“rising”
]
},
{
“id”: “78cc19b9.b9ebf8”,
“type”: “function”,
“z”: “e3c94631.4af248”,
“name”: “set flows”,
“func”: “//set current humidty to old val \nvar ensuite_humidity_old = flow.get(“ensuite_humidity_new”);\nvar ensuite_humidity_old_time = flow.get(“ensuite_humidity_new_time”);\nflow.set(“ensuite_humidity_old”, ensuite_humidity_old);\nmsg.payload = Number(msg.payload);\nflow.set(“ensuite_humidity_new”, msg.payload);\nflow.set(“ensuite_humidity_new_time”, new Date().toISOString());\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 284,
“y”: 320,
“wires”: [
[
“32776592.229faa”
]
]
},
{
“id”: “dbcb9723.05d0f8”,
“type”: “switch”,
“z”: “e3c94631.4af248”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “eq”,
“v”: “rising”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “falling”,
“vt”: “str”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 514,
“y”: 80,
“wires”: [
[
“94e9b992.5043e8”
],
[
“96227205.2f8d4”
]
]
},
{
“id”: “be46743a.c50fa8”,
“type”: “server-state-changed”,
“z”: “e3c94631.4af248”,
“name”: “Ensuite Humidity”,
“server”: “944aaede.4e091”,
“entityidfilter”: “sensor.xiaomi_humidity_1_zha”,
“entityidfiltertype”: “substring”,
“outputinitially”: true,
“state_type”: “str”,
“haltifstate”: “”,
“halt_if_type”: “str”,
“halt_if_compare”: “is”,
“outputs”: 1,
“output_only_on_state_change”: false,
“x”: 112,
“y”: 96,
“wires”: [
[
“78cc19b9.b9ebf8”,
“7a1df227.cbfe7c”
]
]
},
{
“id”: “88a27c2a.18f19”,
“type”: “change”,
“z”: “e3c94631.4af248”,
“name”: “”,
“rules”: [
{
“t”: “set”,
“p”: “payload”,
“pt”: “msg”,
“to”: “ensuite_humidity_type”,
“tot”: “flow”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 544,
“y”: 32,
“wires”: [
[
“dbcb9723.05d0f8”
]
]
},
{
“id”: “733e6c17.300664”,
“type”: “change”,
“z”: “e3c94631.4af248”,
“name”: “Turn on”,
“rules”: [
{
“t”: “set”,
“p”: “payload”,
“pt”: “msg”,
“to”: “on”,
“tot”: “str”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 812,
“y”: 32,
“wires”: [
[
“9fd58e6e.1b5c3”
]
]
},
{
“id”: “2f256d58.18ec82”,
“type”: “change”,
“z”: “e3c94631.4af248”,
“name”: “Turn off”,
“rules”: [
{
“t”: “set”,
“p”: “payload”,
“pt”: “msg”,
“to”: “off”,
“tot”: “str”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 880,
“y”: 140,
“wires”: [
[
“9fd58e6e.1b5c3”
]
]
},
{
“id”: “94e9b992.5043e8”,
“type”: “api-call-service”,
“z”: “e3c94631.4af248”,
“name”: “Sonoff Extractor Fan On”,
“server”: “944aaede.4e091”,
“service_domain”: “homeassistant”,
“service”: “turn_on”,
“data”: “{“entity_id”:“switch.sonoff_basic_ensuite_extractor_fan”}”,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 750,
“y”: 80,
“wires”: [
[
“733e6c17.300664”
]
]
},
{
“id”: “f6fe16a.3760ee8”,
“type”: “api-call-service”,
“z”: “e3c94631.4af248”,
“name”: “Sonoff Extractor Fan Off”,
“server”: “944aaede.4e091”,
“service_domain”: “homeassistant”,
“service”: “turn_off”,
“data”: “{“entity_id”:“switch.sonoff_basic_ensuite_extractor_fan”}”,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 686,
“y”: 176,
“wires”: [
[
“2f256d58.18ec82”
]
]
},
{
“id”: “234775cc.cf53ca”,
“type”: “subflow:58fb255f.a2c42c”,
“z”: “e3c94631.4af248”,
“name”: “”,
“x”: 1280,
“y”: 120,
“wires”: []
},
{
“id”: “7a1df227.cbfe7c”,
“type”: “delay”,
“z”: “e3c94631.4af248”,
“name”: “”,
“pauseType”: “delay”,
“timeout”: “5”,
“timeoutUnits”: “seconds”,
“rate”: “1”,
“nbRateUnits”: “1”,
“rateUnits”: “second”,
“randomFirst”: “1”,
“randomLast”: “5”,
“randomUnits”: “seconds”,
“drop”: false,
“x”: 300,
“y”: 32,
“wires”: [
[
“8cd2cc14.6cc58”
]
]
},
{
“id”: “944aaede.4e091”,
“type”: “server”,
“z”: “”,
“name”: “Home Assistant 1”,
“legacy”: false,
“hassio”: true,
“rejectUnauthorizedCerts”: true,
“ha_boolean”: “y|yes|true|on|home|open”
}
]