Handing over variables to scripts, i need help. (DND and queuing for notofications)

So I got android wallpannel from thetimewalker, and use mqtt command “speak” to announce for when e.g. the washing machine or the vacuum robot downstairs is finished or anything else happens in the house that is annoying but not obvious, like the irrigation system was switched on manually and is x minutes later still on, or a server is not reachable anymore, or such stuff.

However, for maintaining the … its imperative it does not start talking in the middle of the night, and we had just that happen yesterday in lieu of me building a new HA instance and moving everything over. My wife presented me with a vid of it talking in the middle of the night, and i looked into the traces for that automation, zilch, last run was yesterday evening, not this night at 3 am, i presume there was some sort of old mqtt message that made it through at that time…

How ever, the boss mandates, i put a filter before the output.

so in stead of configuring this in each automation, where a global change woudl be a mess, i want to have a script, that i call in the automations, and hand over the text to speak… (also want this for notifications to the companion app)

then the script will check if its inside or outside of DND and if outside, will go ahead and publish the speak command to my tablet. while during DND it will wait till end of DND (do not disturb) and amend the text by "at {date/time} i wanted to say: “text”, but was in DND!

and if a second message comes in, that should be handled like

at {date/time} i wanted to say: “text” and at {date/time} i wanted to say: “text2”… but I was in DND!

How ever, ive been reading through the posts here and through

and i cant make head nor tail from from it. especially how to queue the messages.

Im sure im not the only one that has a wife that does not want to be bothered in the middle of the night by HA informing (and wakening up every one) about a finished washing machine or an offline Kodi or what not.

how do you fix it?
or any suggetions how i can get what I described further up?
thanks
Manny

just half an hour ago i figured out why its talking at night.

we do a power cycle on thr poe to reset the unifi APs (i use nanoHD, cant recomend them), as they tend to execute themselves if left on for extended periods (days to weeks), hence a hard powercycle each night.

Intenionally we cycle them 5 mins apart so clients can switch over. Of course i disabled that in the tasmota, as I dont want them to jump APs…

The first enpoint to notice problems is the old fruit stuff of my better half, that cant connect anymore (funny thing: our androids dont have the same issues). Hence me hard reseting the APs each night between 3 and half past 3. every 5 minutes one AP.

Everytime the AP is rebooting, the clients are disconected. most just jump to the next AP, but the tasmota nous a1 dont, as I did not tell em to AP jump. Hence the automations are executed on reconect and the wall panels start to spek…

post the automation

I updated stuff in post 2, for more clarification and details!

Hers the automation.

alias: BK_Insektenvernichter
description: ""
triggers:
  - entity_id: sun.sun
    attribute: elevation
    above: 5
    id: "on"
    trigger: numeric_state
  - entity_id: sun.sun
    attribute: elevation
    below: "-5"
    id: "off"
    trigger: numeric_state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id: "on"
              - condition: state
                entity_id: >-
                  switch.steckdose_insektenvernichter_steckdose_insektenvernichter
                state: "off"
        sequence:
          - data:
              payload: "{\"speak\": \"Der humbrum brutzler wird gleich eingeschaltet!\"}"
              topic: wallpanel/BK-fire10-11-Flur/command
              qos: "2"
              retain: true
            action: mqtt.publish
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data: {}
            target:
              device_id:
                - f7702e3c8c1b63bcdff9db0832b860e9
            action: switch.turn_on
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id: "off"
              - condition: state
                entity_id: >-
                  switch.steckdose_insektenvernichter_steckdose_insektenvernichter
                state: "on"
        sequence:
          - data:
              topic: wallpanel/BK-fire10-11-Flur/command
              payload: >-
                {"speak": "Der humbrum brutzler hat für heute genug
                gebrutzelt!"}
              qos: 0
              retain: false
            action: mqtt.publish
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - data: {}
            target:
              device_id:
                - f7702e3c8c1b63bcdff9db0832b860e9
            action: switch.turn_off
    default: []
mode: single

However, I still want to outsource the talking stuff into a script. So i dont need to find all the right “wallpanel mqtt details” in each automation thats suppost to communicate something. One typo, and im good in typos… and it wont speak, and im searching half an hour for that typo…

Also if i change those tables around (or replace em with something not as cheap as the amazon stuff), i need to touch all automations… so why not do it right and have a script for each tablett, then i only need to touch that in case of change.

What I have as an idea: I would like to have some sort of timetable for the wallpanel DND and a script for each unit. then in the automations i just hand over to DND with vairable “wallpanel for address” and “contend”

is this somehow possible? if so, whats the best way forward here?