Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add weather-integration #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yuanh0702
Copy link

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

  • Read-only Attribute Entities: temperature (temperature), precip (precipitation), humidity (humidity)
  • Read/Write Attribute Entities: auto_refresh (whether to automatically refresh the weather)
  • Service Entities:
    • 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)
      image

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.
image

Integration Entities

  • Read-only Attribute Entities: detect_status (detection status)
  • Read/Write Attribute Entities:
    • api_info.api_url (HeWeather API address)
    • api_info.api_key (HeWeather API key)
    • api_info.api_lang (weather language)
  • Service Entities:
    • benchmark (synchronize weather information)
    • add_device (add regional weather)
    • delete_device (delete regional weather)
      image
      image

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.
image
image
image

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.
image

2. Operation Steps

Set Weather Integration API Information

  1. Navigate to the integration settings page.
  2. Enter the corresponding API address for HeWeather (https://devapi.qweather.com), the API key you applied for, and the language for the weather data.
    image

Create Weather Device

  1. Go to the device list page.
  2. Click the "Add" button, select the weather integration, fill in the device name and the city you want to create, and click "Confirm."
    image

Delete Weather Device
image

View Weather Device Entities
image

Bind Weather Device Component

  1. First, select the weather component.
    image

  2. Then, select the entity get_weather24h bound to the device.
    image

Display Effect
image

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.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants