Before 60 sec

good morning,
given a certain time how can in nodered have an event that goes off 60 seconds earlier

Inject Node, timestamp, repeat at specific time

thanks wuench,
I read the time from HA variable.
In HA I created a page where I set times and various things, so I can’t inject the time

What is the name of the object in HA the time is stored in?

input_datetime.only_time

- alias: "Avviso 1 minuto prima della chiusura tapparelle"
  trigger:
  - platform: template
    value_template: >
      {{ states('sensor.time') ==
         (state_attr('input_datetime.clshutall', 'timestamp') - 60)
         |timestamp_custom('%H:%M' , false) }}
  action:
    - service: script.speak_all
      data_template:
        message: Attenzione ! Tra un minuto le tapparelle si chiuderanno

This is what I should turn into nodered.
I’ve already worked on the alexa ad part.
My problem is having a trigger one minute before the event.

Thanks, Alberto

Good morning,
I solved my problem by adding a second big timer by setting the times a minute before.
It works but I don’t like it very much.
I wish it could be done with just one BT !!
To do this I would have to create a function that subtracts from the set time, on or off of the BT, from the current time.
If equal to one minute, with a switch, I would direct the flow to one or the other output
To do this I would have to extract the time set in the BT but I don’t know how to do it and if it’s possible.
A little help?
Thanks, Alberto

Cattura

[{"id":"5944f2a8.71d97c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"f82ea2c9.30cb3","type":"bigtimer","z":"5944f2a8.71d97c","outtopic":"","outpayload1":"on","outpayload2":"off","name":"7:30 > Sunset+30","comment":"","lat":"45.12419","lon":"10.10842","starttime":"450","endtime":"5004","startoff":"0","endoff":"30","startoff2":"","endoff2":"","offs":"0","outtext1":"on","outtext2":"off","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":310,"y":140,"wires":[["aaac9e17.e2914"],[],[]]},{"id":"aaac9e17.e2914","type":"switch","z":"5944f2a8.71d97c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":140,"wires":[[],[]]},{"id":"c6eac929.0ace68","type":"bigtimer","z":"5944f2a8.71d97c","outtopic":"","outpayload1":"on","outpayload2":"off","name":"Speak - 1 Minuto","comment":"","lat":"45.12419","lon":"10.10842","starttime":"450","endtime":"5004","starttime2":"0","endtime2":"0","startoff":"-1","endoff":"29","startoff2":0,"endoff2":"0","offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":310,"y":260,"wires":[["e52c7112.eef4"],[],[]]},{"id":"e52c7112.eef4","type":"switch","z":"5944f2a8.71d97c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":260,"wires":[[],[]]},{"id":"90c3d366.7a313","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["f82ea2c9.30cb3"]]},{"id":"a8d961ba.c518d","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":140,"wires":[["f82ea2c9.30cb3"]]},{"id":"f354bf96.a8ce1","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":180,"wires":[["f82ea2c9.30cb3"]]},{"id":"aa42f9e3.f3d168","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["c6eac929.0ace68"]]},{"id":"95ec9b9a.5ff5f8","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":260,"wires":[["c6eac929.0ace68"]]},{"id":"fbec3788.88a7c8","type":"inject","z":"5944f2a8.71d97c","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":300,"wires":[["c6eac929.0ace68"]]}]

I use this flow to check for the time set in HomeAssistant and then subtract 10min.

[
    {
        "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": 750,
        "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": 920,
        "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": 90,
        "y": 300,
        "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.alarmtime",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 320,
        "y": 120,
        "wires": [
            [
                "ed1570d4.2671d"
            ]
        ]
    },
    {
        "id": "4c2301de.7c484",
        "type": "inject",
        "z": "1de400c0.5ce76f",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "60",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 120,
        "wires": [
            [
                "cb3ff133.0f556",
                "c2b4d347.fde2"
            ]
        ]
    },
    {
        "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": 580,
        "y": 120,
        "wires": [
            [
                "5fd4bf94.3d203"
            ]
        ]
    },
    {
        "id": "48f113d4.4573dc",
        "type": "comment",
        "z": "1de400c0.5ce76f",
        "name": "START ALARM CLOCK SEQUENCE",
        "info": "",
        "x": 140,
        "y": 240,
        "wires": []
    },
    {
        "id": "7202dbb0.5bd1b4",
        "type": "comment",
        "z": "1de400c0.5ce76f",
        "name": "Set Initial Flow Variables",
        "info": "",
        "x": 550,
        "y": 340,
        "wires": []
    },
    {
        "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": 570,
        "y": 180,
        "wires": [
            [
                "5fd4bf94.3d203"
            ]
        ]
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

Thanks Marcus,
unfortunately in my automation I use BT and the problem I have is to extract from BT the times set in it.
I think it can’t be done so I think I’ll have to keep it as it is :frowning:

Thanks for your help

Yes correct, with big timer this seems not possible to put all into one flow, since BigTimer does not output the actual time when the sunsets into a msg. You could use the sun events node though to do the same. However, simply using 2 BigTimers is also perfectly fine.