Switch only above a certain temperatur

Hi,

i have an automation where a ventilation system is switched on/off when the status of a machine group changes. It also works as desired. But now the ventilation system should not be switched off below 18 degrees or switched on again when the temperature drops below 18 degrees, regardless of the status of the machine group. At the moment I have no idea how to implement this. It would be great if someone could help me here.

regards Thomas

Here a screenshot of my flow:

and here the exported flow:

[
    {
        "id": "a5df5e8e.25d76",
        "type": "tab",
        "label": "Lüftung Formenbau",
        "disabled": false,
        "info": ""
    },
    {
        "id": "5720183d.db86a8",
        "type": "server-state-changed",
        "z": "a5df5e8e.25d76",
        "name": "",
        "server": "71ca172d.a60118",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "group.maschinenpark_fob",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 200,
        "y": 340,
        "wires": [
            [
                "cb804273.337b1",
                "9d8499c4.d36848"
            ]
        ]
    },
    {
        "id": "cb804273.337b1",
        "type": "debug",
        "z": "a5df5e8e.25d76",
        "name": "Ausschalten",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 300,
        "wires": []
    },
    {
        "id": "6c1f79e2.12bc18",
        "type": "switch",
        "z": "a5df5e8e.25d76",
        "name": "Lüftung ausschalten",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 560,
        "y": 480,
        "wires": [
            [
                "7e8bf9ea.e40678",
                "b066f0f0.57f94"
            ]
        ]
    },
    {
        "id": "ce6e86d4.156e98",
        "type": "e-mail",
        "z": "a5df5e8e.25d76",
        "server": "172.31.2.xxx",
        "port": "25",
        "secure": false,
        "tls": false,
        "name": "[email protected]",
        "dname": "Email",
        "x": 940,
        "y": 740,
        "wires": []
    },
    {
        "id": "45d473d0.05e76c",
        "type": "template",
        "z": "a5df5e8e.25d76",
        "name": "MailText",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Produktion steht Lüftungsanlage wird ausgeschalten.",
        "output": "str",
        "x": 710,
        "y": 700,
        "wires": [
            [
                "ce6e86d4.156e98"
            ]
        ]
    },
    {
        "id": "7e8bf9ea.e40678",
        "type": "function",
        "z": "a5df5e8e.25d76",
        "name": "Message Title",
        "func": "msg.topic=\"Produktion steht\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 590,
        "y": 600,
        "wires": [
            [
                "45d473d0.05e76c",
                "a5569b09.3ea658"
            ]
        ]
    },
    {
        "id": "9d8499c4.d36848",
        "type": "ha-wait-until",
        "z": "a5df5e8e.25d76",
        "name": "",
        "server": "71ca172d.a60118",
        "outputs": 2,
        "entityId": "group.maschinenpark_fob",
        "entityIdFilterType": "exact",
        "property": "state",
        "comparator": "is",
        "value": "on",
        "valueType": "str",
        "timeout": "30",
        "timeoutType": "num",
        "timeoutUnits": "minutes",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 310,
        "y": 460,
        "wires": [
            [
                "5955db0f.c50694"
            ],
            [
                "6c1f79e2.12bc18"
            ]
        ]
    },
    {
        "id": "5955db0f.c50694",
        "type": "debug",
        "z": "a5df5e8e.25d76",
        "name": "wait-until",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 560,
        "y": 400,
        "wires": []
    },
    {
        "id": "a5569b09.3ea658",
        "type": "debug",
        "z": "a5df5e8e.25d76",
        "name": "email-senden",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 910,
        "y": 560,
        "wires": []
    },
    {
        "id": "5cc3d313.07807c",
        "type": "server-state-changed",
        "z": "a5df5e8e.25d76",
        "name": "",
        "server": "71ca172d.a60118",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "group.maschinenpark_fob",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 180,
        "y": 120,
        "wires": [
            [
                "f3c13a6a.2fd058"
            ]
        ]
    },
    {
        "id": "33a2cfb.48f173",
        "type": "switch",
        "z": "a5df5e8e.25d76",
        "name": "Lüftung Einschalten",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 590,
        "y": 160,
        "wires": [
            [
                "e5f6e774.3877d8",
                "1303ed6.a45e613"
            ]
        ]
    },
    {
        "id": "e5f6e774.3877d8",
        "type": "function",
        "z": "a5df5e8e.25d76",
        "name": "Message Title",
        "func": "msg.topic=\"Produktion läuft\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 760,
        "y": 80,
        "wires": [
            [
                "8e6232d1.ceb1d"
            ]
        ]
    },
    {
        "id": "8e6232d1.ceb1d",
        "type": "template",
        "z": "a5df5e8e.25d76",
        "name": "MailText",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Produktion läuft Lüftungsanlage wird eingeschalten",
        "output": "str",
        "x": 900,
        "y": 160,
        "wires": [
            [
                "45b1c85d.049e58"
            ]
        ]
    },
    {
        "id": "45b1c85d.049e58",
        "type": "e-mail",
        "z": "a5df5e8e.25d76",
        "server": "172.31.2.xxx",
        "port": "25",
        "secure": false,
        "tls": false,
        "name": "[email protected]",
        "dname": "Email",
        "x": 1080,
        "y": 120,
        "wires": []
    },
    {
        "id": "f3c13a6a.2fd058",
        "type": "ha-wait-until",
        "z": "a5df5e8e.25d76",
        "name": "",
        "server": "71ca172d.a60118",
        "outputs": 2,
        "entityId": "group.maschinenpark_fob",
        "entityIdFilterType": "exact",
        "property": "state",
        "comparator": "is",
        "value": "off",
        "valueType": "str",
        "timeout": "90",
        "timeoutType": "num",
        "timeoutUnits": "seconds",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": false,
        "x": 330,
        "y": 200,
        "wires": [
            [
                "be5a302a.7779e"
            ],
            [
                "33a2cfb.48f173"
            ]
        ]
    },
    {
        "id": "be5a302a.7779e",
        "type": "debug",
        "z": "a5df5e8e.25d76",
        "name": "Einschalten",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 40,
        "wires": []
    },
    {
        "id": "1303ed6.a45e613",
        "type": "api-call-service",
        "z": "a5df5e8e.25d76",
        "name": "Lüftung einschalten",
        "server": "71ca172d.a60118",
        "version": 1,
        "debugenabled": false,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.b09_lueftung",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 960,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "b066f0f0.57f94",
        "type": "api-call-service",
        "z": "a5df5e8e.25d76",
        "name": "Lüftung auschalten",
        "server": "71ca172d.a60118",
        "version": 1,
        "debugenabled": false,
        "service_domain": "light",
        "service": "turn_off",
        "entityId": "light.b09_lueftung",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 870,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "71ca172d.a60118",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "addon": true
    }
]

In your state node try:
image

You will get an extra output, one e.g. >18 and one <=18 degree

Hi

I have a question somewhat related.

I want to turn my lights on when the lux/brightness becomes lower then X, and turn them off when the lux becomes too high.

I’m using an event:state node as you indicated and I’ve the two outputs. And, depending the lux/brightness, the lights are correctly turned on from output 1 or turned off from output 2.

But the lux value changes continuously. And the message “turn on” or “turn off” is sent every time the lux changes.

How can I avoid this? So when the lux/brightness becomes lower than X, then turn on the lights BUT ONLY ONCE. And the reverse, turn_off only once.

1 Like

Only once per what? Week, hour, day? Think in logic first then define your flow.

Every time the brightness drops below X, the lights should turn on. And every time the brightness becomes too high, the lights should go out.

Normally the on and off will appear only once a day.
But if the weather changes, it could be several times a day. Exemple: it rains -> it becomes dark -> lights should go on. It stops raining and the sun shines -> it becomes bright -> lights should turn off.

But with my state event now, it sends a message to turn the lights on/off each time the lux changes = nearly every 10 seconds.
My flow should send a message turn_on ONLY if it becomes dark. And a turn_off it it becomes bright. Normally only once a day, but it can be more than once a day.

If have got something similar solved like this (do something once my Co2 sensor is above a certain limit, but only once):

You use a switch to evaluate against your treshold.

You use a trigger to sent the message only once / block the flow:

You enable the flow again, if sensor value is lower than treshold:

Perhaps a snapshot can help.

Below my flow and the configuration of the event:state

As I said, the lux changes all the time. The lux changed recently at 14:13. And att the same time, my lights are turned_off (even when they are off since this morning). So I prefer to have the message turn-off to be sent not so many times.

Sorry, our messages crossed at the same time.

I tried out your proposal and it seems to work. See image below, One light is not turned_off anymore, the others are still turned off constantly

But another question. In your image the “event:state” node has only one output. I have two outputs.
Why? And how can I achieve only one output? Because with two outputs I have to use the “evaluate function” on both outputs.

Just leave the “If State” empty (red marker) and you get only one output:

This looks good. But you will need the trigger/reset combination two times:
one for the “turn lights on once” logic, and the same for the “turn lights off” logic.

Beware: I am a noob in node red, this might not be the best solution there is, but it works for me. :grin:

Thanks a lot.

You have solved my problem