Minecraft Bedrock 1.21.100+ behavior pack, detects the state of the weather and assigns a scoreboard value to a fake player. You can then run your own commands using execute if score subcommands.
You may dowload the latest release from the Releases Page
Add the Detect Weather add-on to your behavior packs on your world. Behavior packs may disable achievements, but editing the world with an NBT editor can re-enable achievements when uploading your world to a realm.
Re-enable achievements on either pc or mobile with the free NBT editor Dovetail
You can run commands based on a fake player's score:
execute if score .Weather.Man detect:weather matches 1 run say The weather is clear
execute if score .Weather.Man detect:weather matches 2 run say The weather is rain
execute if score .Weather.Man detect:weather matches 3 run say The weather is rain and thunderNote
This add-on also assigns an id and adds a tag when a player first joins the world.
The scoreboard objective is detect:id
The tag is detect:joined
_ _ _ _ _
(_) _ _ | | | | | | |
____ _ _| |_ _| |_ _____ ____ ___| |___| |_____| | |
| \| (_ _|_ _) ___ | _ \ /___)_____ (____ | | |
| | | | | | |_ | |_| ____| | | |___ | | / ___ | | |
|_|_|_|_| \__) \__)_____)_| |_(___/ |_\_____|\_)_)