Retrieve values from electrical power sensors by sending zigbee command

I need to retrieve values from electrical power sensors by sending zigbee command. Polling them is the only working solution for now.

I retrieve power usage values quitte often (5 to 15 minute).
But every 30 minute, in a single command i also retrieve bloc of data containing multiple values from theese sensors. The block of data contains the power usage value.
I don’t want to unnecessarily over charge zigbe network retrieving this block of data every 5 to 15 minutes.
I also don’t need to retrieve the single power usage values when i retrieve thesse block of data from sensors.

I already find a way to do this polling.

trigger:
  - platform: time_pattern
    minutes: 30
    hours: "*"
  - platform: time_pattern
    minutes: /5
    hours: "*"
    id: cond1
condition: []
action:
...
                    - condition: not
                      conditions:
                        - condition: trigger
                          id: cond1
...
mode: single

It works. The only drawback is that i get warning messages telling that my automation is already running. Using a Cron syntaxe could easily help me prevent trigger the automation two times (i tried it at first, then realising that it is not Cron syntax, i was fooled by the similarity). With single mode it’s not a big deal, but i thought it is too bad not to use Cron syntax and features. Cron syntax could also easily keep backward compatibility, due to their similarities.

I still can’t say if you necessarily need time pattern but what you have showed here is one trigger at any half hour and one every five minutes.
So that means you don’t need the half hour trigger.

Based on the id of the trigger the automation will not send the same command.
Like this i know if it is trigged for single value retrieve (every 5 minutes) or for a data block (every 30 minutes).

Trigger order is important.
Every 30 minutes the first trigger is triggered. No id is passed to the action section.
Every 5 minutes second trigger is triggered. Id is passed to the action section.

Withe the single mode only one instance can run at the time. 30 minutes trigger is the first one, so it will prevent 5 minutes trigger action to perform.

You can get that from {{ now().minute == 30 }} in a condition or if then else, or choose

You don’t need both.

Every 5 minutes i send a command to retrieve a single value.
Every 30 minutes i send a command to retrieve a block of data, containing among other things the value retrieve every 5 minutes.

It already works. I feel that it is more rellaiable to use trigger like this, rather than using condition after triggering. Otherwise i should need to add some margin of error in the condition.

I know…

Ehmm…

Isn’t that a condition?
How does that condition differ from another condition?

What margin of error? It still trigger at the exact same time.
There are still condition in both solutions.
One creates a warning in the logs, the other doesn’t.
:man_shrugging:

The delay between the triggering event and the conditions resolution is not guaranteed.
In my case your solution could work fine.

At first, I only asked to extend the time pattern trigger syntax. To be able to use the same syntax as Cron.

Current syntax looks like Cron syntax with less features. I find this frustrating.

I’ll leave it here.
We have established that Cron is not needed and that it’s not complex at all.
Still don’t know if you need time pattern at all, but I’ll leave it here.
It’s obvious you are not willing to show this or even willing to change.

There is a reason why all time pattern questions are asked by new members and also a reason why all feature requests of time pattern upgrades fail.
It’s only used by new members who hasn’t yet learned how to use Home Assistant.

I’m not going to say time patterns are never used because there are some very odd cases.
But most of the times there are entities or events you can trigger on instead.

There is quitte always a way to bypass a problem. In the other hand it is nice to have multiple way to achive the same purpose. Letting people used what are used to, chosse their prefered way.

In the same time, this is a good things to make pedagogy, explaining all the different possiblities and explaining why some ways are better than another. Like you did.

I used HA for three years now. I encounter this problem of syntax at least two time during the last six months. We do not have all same usages and habits.

Cron was released 47 years ago. Current time pattern syntax seems based on its syntax. People using it or knowing its syntax are countless.

As i already, say. It is too bad not to have it.