Xiaomi Weather
The Xiaomi Weather integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides current weather and daily, hourly, and twice-daily forecasts for cities in mainland China. Select a location on the map during setup, and the integration finds a matching city.
You can show the current weather and forecast on your dashboard with a weather forecast card. You can also use the weather in automations, such as the morning rain reminder below, which reminds you to take an umbrella when it rains.
Prerequisites
Your Home Assistant instance needs internet access to retrieve data from Xiaomi Weather. You do not need a Xiaomi device, account, or API key.
Configuration
To add the Xiaomi Weather service to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select Xiaomi Weather.
-
Follow the instructions on screen to complete the setup.
- On Choose a location, select a location in mainland China on the map. The initial selection is your Home Assistant home location.
- If more than one city matches, Choose a city appears. Check the city name, region, and city code, then select the matching city.
- On Review location, check the city and coordinates, then submit to verify weather access and finish setup.
To add another city, add the integration again. Each city can be configured only once, even if you use different coordinates.
Configuration options
The selected coordinates are saved during setup. Moving your Home Assistant home location does not change this weather location. To change a configured location, remove its integration entry and add it again.
Supported functionality
The integration creates one weather entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] per city. Depending on the data available from Xiaomi Weather, it provides:
- Current condition and temperature
- Apparent temperature
- Humidity and pressure
- Wind speed and direction
- UV index
- Visibility
The entity supports these forecast types:
- Daily: High and low temperatures, conditions, wind, and precipitation probability
- Hourly: Temperature, conditions, and wind
- Twice daily: Separate daytime and nighttime temperatures, conditions, and wind
Missing measurements are omitted, but other available measurements for the same forecast period are retained. Forecast periods without a usable date or time are omitted. The number of forecast periods depends on the available data.
Use the standard Get weather forecasts action to retrieve daily, hourly, or twice-daily forecasts.
Xiaomi Weather automation examples
You can use the current weather conditions to create reminders in Home Assistant.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: show a morning rain reminder
At 07:00, check whether your Xiaomi Weather entity’s condition is Rainy and show an umbrella reminder in Home Assistant’s notification panel. This checks the latest reported conditions, not the day’s forecast. The example checks Rainy only; Pouring and Lightning, rainy are separate conditions.
Go to Settings > Automations & scenes and create an automation with these settings:
- Trigger: Time: 07:00
-
Condition: State
- Entity: Your Xiaomi Weather entity
- State: Rainy
-
Action: Create persistent notification
-
Title:
Morning rain reminder -
Message:
Xiaomi Weather reports rain. Remember your umbrella. -
Notification ID:
xiaomi_weather_morning_rain
-
Title:
If you use the YAML example, replace weather.home with your Xiaomi Weather entity’s ID. Its entity ID is based on the city name. You can adjust the time to suit your routine. The notification ID makes subsequent reminders update the same notification.
YAML example for a morning rain reminder
alias: "Show a morning rain reminder"
triggers:
- trigger: time
at: "07:00:00"
conditions:
- condition: state
entity_id: weather.home
state: "rainy"
actions:
- action: persistent_notification.create
data:
title: "Morning rain reminder"
message: "Xiaomi Weather reports rain. Remember your umbrella."
notification_id: "xiaomi_weather_morning_rain"
Data updates
The integration retrieves weather data every 15 minutes. Forecast requests use the most recently retrieved data and do not make an additional request to Xiaomi Weather.
Known limitations
- Only mainland China cities are supported.
- City names and regions returned during setup may appear in Chinese.
- Air quality, weather alerts, and precipitation amounts are not provided by this integration.
- The integration uses an undocumented Xiaomi Weather service. Changes to that service may affect availability.
Troubleshooting
No matching city
Check that the selected location is in mainland China. If no city matches, select a nearby location on the map and try again. When multiple cities are listed, check the region and city code to distinguish cities with similar names.
Weather cannot be retrieved
Check that Home Assistant has internet access, then retry. During setup, your location details are kept when a lookup or weather request fails.
If an existing weather entity becomes unavailable, the integration automatically retries and restores it after a successful update.
Removing the integration
This integration follows standard integration removal.
To remove an integration instance from Home Assistant
- Go to Settings > Devices & services and select the integration card.
- Next to the entry you want to remove, select the three dots
menu. Then, select Delete. - Depending on the integration, the entries are listed under one of the following headings:
- Devices
- Hubs
- Services
- Integration entries
- Depending on the integration, the entries are listed under one of the following headings:
- To confirm, select Delete.
- Home Assistant also deletes the devices and entities of the entry.
- If Home Assistant asks you to restart, restart Home Assistant.
- If Home Assistant asks whether to also delete the application credentials, select Remove or Keep.
- If you keep them, Home Assistant uses them automatically when you add the integration again.
- To delete them later, refer to Deleting application credentials.