Action based on alarm entity

Hi!

I have input_datetime.next_alarm which has been created (date/time) from Android phone via hassalarm app. I have a plan to create wakeup light…

How can I start increasing light based on alarm time (if has been set) minus 5 min? This is entity detail if alarm hasn’t been set:
image

This is what i have been using now for more than a year. Works very reliable:

[
    {
        "id": "5fd4bf94.3d203",
        "type": "join",
        "z": "1de400c0.5ce76f",
        "name": "",
        "mode": "custom",
        "build": "array",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "2",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 810,
        "y": 180,
        "wires": [
            [
                "3baa06b3.7b18fa"
            ]
        ]
    },
    {
        "id": "3baa06b3.7b18fa",
        "type": "function",
        "z": "1de400c0.5ce76f",
        "name": "Compare Times",
        "func": "newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 960,
        "y": 180,
        "wires": [
            [
                "69f8941b.a2457c"
            ]
        ]
    },
    {
        "id": "69f8941b.a2457c",
        "type": "switch",
        "z": "1de400c0.5ce76f",
        "name": "Is it Time?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "True",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1120,
        "y": 180,
        "wires": [
            [
                "1123ea0c.e5c056"
            ]
        ]
    },
    {
        "id": "cb3ff133.0f556",
        "type": "api-current-state",
        "z": "1de400c0.5ce76f",
        "name": "Get Alarm Time",
        "server": "2fba4297.e4145e",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": true,
        "entity_id": "input_datetime.alarm",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 460,
        "y": 120,
        "wires": [
            [
                "ed1570d4.2671d"
            ]
        ]
    },
    {
        "id": "ed1570d4.2671d",
        "type": "moment",
        "z": "1de400c0.5ce76f",
        "name": "Alarm - 10min",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Berlin",
        "adjAmount": "10",
        "adjType": "minutes",
        "adjDir": "subtract",
        "format": "YYYY-MM-DD HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Berlin",
        "x": 640,
        "y": 120,
        "wires": [
            [
                "5fd4bf94.3d203"
            ]
        ]
    },
    {
        "id": "c2b4d347.fde2",
        "type": "moment",
        "z": "1de400c0.5ce76f",
        "name": "Current Time",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Berlin",
        "adjAmount": "0",
        "adjType": "minutes",
        "adjDir": "subtract",
        "format": "YYYY-MM-DD HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Berlin",
        "x": 630,
        "y": 180,
        "wires": [
            [
                "5fd4bf94.3d203"
            ]
        ]
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "name": "Home Assistant",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]
1 Like