Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1. Project Overview
Based on the existing IoT open-source project platform, we developed an integration with a third-party weather API and visualized the latest weather data through a frontend component. The main tasks completed are as follows:
1.1 Backend
Integration with HeWeather API
The integration primarily involves three API capabilities provided by HeWeather: current weather, weather forecast for the next 24 hours, and weather forecast for the next 7 days.
Device Entities
temperature
(temperature),precip
(precipitation),humidity
(humidity)auto_refresh
(whether to automatically refresh the weather)get_weather
(get the current weather of the device)get_weather24h
(get the weather forecast for the next 24 hours of the device)get_weather7d
(get the weather forecast for the next 7 days of the device)Devices
The concept of a device here can be understood as the weather of a region being a device. I can add or delete weather information for different regions and display the data through frontend components bound to device entities.
Integration Entities
detect_status
(detection status)api_info.api_url
(HeWeather API address)api_info.api_key
(HeWeather API key)api_info.api_lang
(weather language)benchmark
(synchronize weather information)add_device
(add regional weather)delete_device
(delete regional weather)1.2 Frontend
Weather Component
This component primarily binds to the weather service of a specific region, retrieves the 24-hour weather information, and renders it for display. The component features weather display, automatic refresh, and manual refresh functionalities, and it also has a night mode that automatically switches backgrounds.
Existing Dashboard Components
These can bind to regional weather device entities to display changes in temperature, humidity, and precipitation through existing dashboard components, as well as manually refresh the current weather of some devices.
2. Operation Steps
Set Weather Integration API Information
Create Weather Device
Delete Weather Device
View Weather Device Entities
Bind Weather Device Component
First, select the weather component.
Then, select the entity
get_weather24h
bound to the device.Display Effect
Other Existing Dashboard Components
The steps to add and bind device entities are roughly the same as above. The difference lies in selecting the appropriate components based on your device attributes.