Humidity - identify when rising?

Hello can anyone help me please. I’m trying to identify when the humidity in my bathroom rises quickly over a period of time or since the last valve was sent. I would like to do it in Node red if possible however i’m open to any suggestions.

Thank you.

I am interested in this too, I thought about trying to detect when the humidity in my bathroom has not fallen for a period of time so that I can turn off the exhaust fan as it is no longer getting the humidity any lower. I suppose you want to turn your fan on or declare the bathroom in use if humidity rises quickly, I want to keep it on if humidity is still falling quickly after use.

Take a look at the Trend Binary Sensor.

1 Like

Thanks for the help VDRainer. I’ve tried adding this which I think should track increases over a 15min period.However its not working. Any advise as where I’ve gone wrong please.

  • platform: trend
    sensors:
    temp_falling:
    entity_id: sensor.ensuite_humidity
    sample_duration: 15
    min_gradient: -0.01666
    device_class: cold

    temp_rising:
    entity_id: sensor.ensuite_humidity
    sample_duration: 15
    min_gradient: 0.01666
    device_class: heat

sample duration is in seconds. You might need to change the 15 to 900.

Thank you for your help. I’ll give it a go and see how I get on. I’ll report back soon. Thanks

So I can confirm this is getting better. Getting false positives so I’m guessing I need to adjust the gradients etc. Has anyone done this before? If so what did you do please. Thanks

hi Egoman,

I am having the same problem. are you having any luck with a (pure) node-red solution so far or have you stayed with the Trend Binary Sensor solution?

br Peter

Hello.

I’m sorry to report that I gave up on this method and used node red instead. All my node red script does is identify an increase in humidity and then turn on my extractor fan and then as soon as it starts dropping delays turning it off for an hour.

Good luck

hi again, thanks for your reply ergoman,

that sounds good. I am actually looking for a pure node red solution. Would you post yours as an example? I have tried a few different things, but I’m stuck (newbie).

it would be highly appreciated.

br Peter

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”
}
]

hi again, thanks a lot. Ill take any help i can get - pritty or not :wink:

But I can’t seem to be able to copy it to node-red. (when i choose the import function in node-red that i have used so often it will not let me import it (the import button stays greyed out)).

maybe somebody else can try to help and copy it (just to see if it is me that is the problem…). thanks for any help.

br Peter

I got something working in the end using trend sensors. I posted my code in another thread

Hi Ergoman, when i test your code in:


I get the following error:
Error: Parse error on line 1:

[{ “ id”: “58 fb255f.
----^
Expecting ‘STRING’, ‘}’, got ‘undefined’

Maybe something got lost in the pasting. Can you try to post it again.

Thanks in advance
Peter

thanks Crhass,

that looks interesting. I’ll go down that road if i cannot get node-red to work :+1:

Br Peter

hi again, here is a little update.

I was never able to read Ergomans node-rede code so I opted for a work-around.

First I created a sensor in HA that detects difference in humidity between shower and an other room (se below).

Then i read that sensor in node-red and use a max offset (for example +10%) as a trigger for the automation.

here is the sensor:

- platform: template
  sensors:
    shower_fugt:
      friendly_name: "Shower in Progress"
      value_template: '{{ ( (states.sensor.humidity_158d000255asdf.state | float ) - (states.sensor.humidity_158d000208asdf.state | float ) ) | round(1) }}'
(states.sensor.humidity_158d000255asdf.state | float ) ) | round(2) }}'
      device_class: humidity
      unit_of_measurement: '%'

BR
Peter

1 Like