How to detect when the player is at half a heart with command blocks 1.16.3 [duplicate]

For this method you need a scoreboard for health. You can make it with the following command.

scoreboard objectives add health health

To test if a player has a certain amount of health, you can do it with the following command:

execute as @a[scores={health=<number>}] at @s run tp <coordinates>

Default health is 0–20. Half a heart is 1.