Detecting powered button/lever with command blocks

I've went through various wiki pages and commands. I'm still stuck on the most basic command trying to make it work.

Here's the code:

/execute if block -272 70 199 minecraft:stone_button[powered=true] run say Hello, blocks!

Now the wiki says if block execute command works like /execute if block <position> <block> <command>. If I understood correctly, it should be:

  • if (block at -272 70 199 = powered stone button)
  • say "Hello, blocks!"

but well it doesn't do anything. Is there something wrong with the syntax?

enable-command-blocks is set to true, command block set to impulse-unconditional-always on, and I am the server admin.

※P.S. If somebody can tell me how the code structures work in this thing, it'd be greatly appreciated (mostly about what NBT tags are).

enter image description here enter image description here


Solution 1:

The command has to be executed at the same time as the button is pressed, otherwise the check will fail.