Weather Station

The Weather Station knows the weather and the time of day where it stands. Use it to switch lights on at night, close roofs in the rain or show the weather on a screen.
How to get it
Section titled “How to get it”
Weather StationPlace and connect
Section titled “Place and connect”Place it anywhere in the dimension you care about and link it to a Network Repeater.
Weather is the same for a whole dimension; only wet, whether rain falls on the station itself, depends on where it
stands.
Configure
Section titled “Configure”Its form shows its name, network status and the current readings. It has no other settings.
Readings
Section titled “Readings”read() gives a dictionary:
| Field | Meaning |
|---|---|
dimension |
such as minecraft:overworld |
hasWeather |
false in dimensions without weather, such as the Nether and the End |
raining, thundering, clear |
the dimension’s weather |
rainLevel, thunderLevel |
0 to 1 |
precipitation |
none, rain or snow for the station’s biome |
wet |
rain or snow is falling on the station right now |
dayTime |
0 to 23,999; 0 is sunrise and 6,000 is noon |
day, gameTime |
days and ticks since the world began |
isDay, isNight, fixedTime |
time of day, and whether the time is frozen |
There are no forecasts: the values are Minecraft’s current state.
Drive programs
Section titled “Drive programs”Yes. A drive program uses device.read(), device.weather() and the other methods, and handles device.rainStart,
device.nightStart and the other events.
Program API
Section titled “Program API”Getting it
Section titled “Getting it”weather.named(alias)
Refer to a Weather Station by its name. Use it in a constant, then handle its events with on NAME.event(...).
const sky = weather.named("sky")weather.from(alias)
Resolve a weather station by name.
station, err = weather.from("roof")Methods
Section titled “Methods”Properties: sky.connected, sky.id, sky.kind, sky.name. They are read-only.
sky.clear()
True when it is not raining in this dimension.
sunny, err = station.clear()sky.raining()
True while it rains or snows in this dimension.
wet, err = station.raining()sky.read()
Read global weather (raining, thundering, clear, rain and thunder levels), local precipitation and wet at the station, and time of day.
now, err = station.read()sky.thundering()
True during a thunderstorm in this dimension.
storm, err = station.thundering()sky.time()
Read dayTime (0–23999, 0 is sunrise), day, gameTime, isDay, isNight and fixedTime.
clock, err = station.time()sky.weather()
Read the weather in this dimension: Weather.CLEAR, Weather.RAIN or Weather.THUNDER. Use read() for rain at the station itself.
if station.weather() is Weather.RAIN { print("Rain!") }Events
Section titled “Events”| Event | When it runs |
|---|---|
rainStart | Runs when it starts raining or snowing. |
rainStop | Runs when rain or snow stops. |
thunderStart | Runs when a thunderstorm starts. |
thunderStop | Runs when a thunderstorm ends. |
dayStart | Runs at sunrise. |
nightStart | Runs at nightfall. |
weatherChanged(weather, previous) | Runs when the weather changes between Weather.CLEAR, Weather.RAIN and Weather.THUNDER. |
connected | Runs when the device becomes reachable, for example after its area loads. |
disconnected | Runs when the device stops being reachable: unloaded, unlinked or removed. |
programStarted | Runs when the device's own program starts. |
programStopped | Runs when the device's own program stops. |
programFailed(message) | Runs when the device's own program stops on an error. |
Weather is sampled every 20 ticks, once per dimension for every listening station.
Example
Section titled “Example”const sky = weather.named("sky")
on sky.nightStart { print("Night falls. Day " + str(sky.time().day))}
on sky.thunderStart { print("Thunderstorm! Stay indoors.")}