vault backup: 2026-01-05 13:03:55

This commit is contained in:
windyboy
2026-01-05 13:03:55 +08:00
parent 21460fc35d
commit be7c6cdcc9
589 changed files with 396508 additions and 27 deletions
+13
View File
@@ -0,0 +1,13 @@
# windy-ai
## config
### key
```
MdhX7jL4hPFVOhjHCft46pbCD7chZJY9rkuAXD620BwW32axUMq6JQQJ99ALACHYHv6XJ3w3AAAAACOGH6q1
```
### Location/Region
```
eastus2
```
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,478 @@
---
## **Table of Contents**
1. [Prerequisites](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#prerequisites)
2. [Prepare Your Debian System](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#prepare-your-debian-system)
3. [Install Docker](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#install-docker)
4. [Configure Docker Daemon (Optional: HTTP Proxy)](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#configure-docker-daemon-optional-http-proxy)
5. [Install Home Assistant Supervised](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#install-home-assistant-supervised)
6. [Post-Installation Configuration](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#post-installation-configuration)
7. [Configure Home Assistant](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#configure-home-assistant)
8. [Maintenance and Best Practices](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#maintenance-and-best-practices)
9. [Troubleshooting](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#troubleshooting)
10. [Additional Resources](https://chatgpt.com/c/67563169-1bb8-800b-bea7-edf694617d17#additional-resources)
---
## **1. Prerequisites**
Before you begin, ensure that you have the following:
- **Hardware:**
- A device running Debian (Raspberry Pi 4 recommended for ARM architecture or an x86_64-based server for better performance).
- Reliable storage (SSD recommended over HDD or SD cards for durability and speed).
- Stable internet connection.
- **Software:**
- **Debian:** Ensure you have a fresh installation of Debian 11 (Bullseye) or later.
- **Access:** Root or sudo privileges on the Debian system.
- **Tools:**
- **Terminal Access:** SSH access or direct access to the Debian machine's terminal.
- **Internet Connection:** Required for downloading packages and Docker images.
---
## **2. Prepare Your Debian System**
### **2.1 Install Debian**
If you haven't already installed Debian, follow these steps:
1. **Download Debian ISO:**
- Visit the [official Debian website](https://www.debian.org/distrib/) and download the latest stable release (preferably Debian 11 "Bullseye").
2. **Create Installation Media:**
- Use tools like [Rufus](https://rufus.ie/) (Windows) or `dd` command (Linux/macOS) to create a bootable USB drive.
3. **Install Debian:**
- Boot from the USB drive and follow the on-screen instructions.
- Choose a **Minimal Installation** to reduce unnecessary packages.
- Set up a strong root password and create a user with sudo privileges.
### **2.2 Update the System**
Once Debian is installed, update the package lists and upgrade existing packages:
```bash
sudo apt update && sudo apt upgrade -y
```
### **2.3 Set Hostname and Timezone**
1. **Set Hostname:**
Replace `homeassistant` with your desired hostname.
```bash
sudo hostnamectl set-hostname homeassistant
```
2. **Set Timezone:**
```bash
sudo dpkg-reconfigure tzdata
```
Follow the prompts to select your timezone.
### **2.4 Install Essential Packages**
Install necessary packages required for Home Assistant Supervised:
```bash
sudo apt install -y jq curl avahi-daemon dbus network-manager apparmor-utils
```
---
## **3. Install Docker**
Home Assistant Supervised relies on Docker to manage containers. Follow these steps to install Docker Engine.
### **3.1 Remove Old Docker Versions**
Ensure no older versions of Docker are present:
```bash
sudo apt remove -y docker docker-engine docker.io containerd runc
```
### **3.2 Install Docker Dependencies**
```bash
sudo apt install -y ca-certificates curl gnupg lsb-release
```
### **3.3 Add Dockers Official GPG Key**
```bash
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
```
### **3.4 Set Up the Docker Repository**
```bash
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```
### **3.5 Install Docker Engine**
```bash
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```
### **3.6 Verify Docker Installation**
Check Docker version and status:
```bash
docker --version
sudo systemctl status docker
```
You should see Docker running. Press `q` to exit the status view.
### **3.7 Manage Docker as a Non-Root User (Optional)**
To run Docker commands without `sudo`, add your user to the `docker` group:
```bash
sudo usermod -aG docker $USER
```
Log out and back in for the changes to take effect.
---
## **4. Configure Docker Daemon (Optional: HTTP Proxy)**
If your network requires Docker to use an HTTP proxy, configure it as follows:
### **4.1 Create or Edit Docker Daemon Configuration**
Open `/etc/docker/daemon.json` in a text editor:
```bash
sudo nano /etc/docker/daemon.json
```
### **4.2 Add Proxy Settings**
Replace `http://your-proxy:port` with your actual proxy details. If you don't need a proxy, you can skip this step.
```json
{
"proxies": {
"default": {
"httpProxy": "http://your-proxy:port",
"httpsProxy": "http://your-proxy:port",
"noProxy": "localhost,127.0.0.1"
}
}
}
```
### **4.3 Save and Exit**
Press `CTRL + O` to save and `CTRL + X` to exit.
### **4.4 Restart Docker to Apply Changes**
```bash
sudo systemctl restart docker
```
### **4.5 Verify Proxy Configuration (Optional)**
Run a Docker container to verify proxy settings:
```bash
docker run --rm alpine env | grep -i proxy
```
You should see the proxy variables if configured correctly.
---
## **5. Install Home Assistant Supervised**
Follow these steps to install Home Assistant Supervised on your Debian system.
### **5.1 Download the Supervised Installer Script**
```bash
curl -Lo installer.sh https://raw.githubusercontent.com/home-assistant/supervised-installer/main/installer.sh
```
### **5.2 Make the Script Executable**
```bash
chmod +x installer.sh
```
### **5.3 Run the Installer Script**
Run the installer with the appropriate machine type. Replace `your_machine_type` with your hardware. Common types include:
- `raspberrypi4` for Raspberry Pi 4
- `generic-x86-64` for standard 64-bit PCs
**Example for Raspberry Pi 4:**
```bash
sudo bash installer.sh --machine raspberrypi4
```
**Example for Generic x86_64:**
```bash
sudo bash installer.sh --machine generic-x86-64
```
### **5.4 Follow On-Screen Prompts**
The installer will guide you through the process, including:
- Confirming installation parameters.
- Installing necessary Docker containers (Supervisor, Home Assistant Core, etc.).
**Note:** Ensure your network is stable during the installation to allow the script to download required Docker images.
### **5.5 Verify Installation**
After the installation completes, check the status of Home Assistant Supervisor:
```bash
sudo systemctl status hassio-supervisor.service
```
You should see that the Supervisor is active and running.
---
## **6. Post-Installation Configuration**
### **6.1 Access Home Assistant Web Interface**
1. **Find Your Server's IP Address:**
```bash
hostname -I
```
Note down the IP address (e.g., `192.168.1.100`).
2. **Open Web Browser:**
Navigate to `http://<your-server-ip>:8123` (e.g., `http://192.168.1.100:8123`).
3. **Initial Setup:**
- **Create an Account:** Follow the prompts to create your Home Assistant user account.
- **Configure Location:** Set your location, unit system, and time zone.
- **Set Up Home:** Follow the guided setup to add devices and integrations.
### **6.2 Configure Supervisor Settings**
1. **Navigate to Supervisor Panel:**
- Click on **Supervisor** in the left sidebar.
2. **Update Supervisor and Core:**
- If prompted, update the Supervisor and Home Assistant Core to the latest versions.
3. **Install Add-ons:**
- Click on **Add-on Store**.
- Browse and install desired add-ons (e.g., File Editor, Samba Share, Mosquitto MQTT Broker).
- Configure each add-on as needed.
---
## **7. Configure Home Assistant**
After installation, you can customize and extend Home Assistant to suit your needs.
### **7.1 Basic Configuration**
1. **Integrations:**
- **Automatic Discovery:** Home Assistant can automatically discover devices on your network.
- **Manual Integration:** Go to **Settings > Devices & Services > Add Integration** to add integrations manually.
2. **Dashboard Customization:**
- **Edit Dashboard:** Click on the three dots in the top-right corner of the dashboard and select **Edit Dashboard**.
- **Add Cards:** Use various card types (e.g., entities, glance, gauge) to display information.
- **Organize Views:** Create multiple views for different areas or functionalities in your home.
### **7.2 Adding Users and Permissions**
1. **User Management:**
- Go to **Settings > System > Users**.
- Add new users, assign roles (Administrator or User), and manage permissions.
### **7.3 Automations and Scripts**
1. **Create Automations:**
- Navigate to **Settings > Automations & Scenes > Automations**.
- Use the **Editor** to create triggers, conditions, and actions.
- Example: Turn on lights when motion is detected.
2. **Create Scripts:**
- Navigate to **Settings > Automations & Scenes > Scripts**.
- Define sequences of actions that can be triggered manually or via automations.
### **7.4 Adding Custom Components**
1. **File Editor Add-on:**
- Install the **File Editor** add-on from the **Add-on Store**.
- Use it to edit `configuration.yaml` and other YAML files directly within Home Assistant.
2. **Restart Home Assistant:**
- After making changes to YAML files, restart Home Assistant to apply them.
- Navigate to **Settings > System > Restart**.
### **7.5 Setting Up Backups (Snapshots)**
1. **Create Snapshots:**
- Go to **Supervisor > Snapshots**.
- Click **Create Snapshot** to back up your configuration and add-ons.
2. **Automate Backups:**
- Use add-ons like **Google Drive Backup** or **Samba Share** to store snapshots externally.
- Schedule regular backups to ensure data safety.
---
## **8. Maintenance and Best Practices**
### **8.1 Regular Updates**
- **Home Assistant Core and Supervisor:**
- Regularly update to the latest versions via the Supervisor interface.
- **Add-ons:**
- Keep add-ons up to date to benefit from new features and security patches.
### **8.2 Backup Strategy**
- **Local Backups:**
- Utilize Home Assistant's snapshot feature.
- **Remote Backups:**
- Store backups on external drives or cloud services using add-ons.
### **8.3 Security Measures**
- **Secure Access:**
- Enable SSL/TLS for secure remote access.
- Use strong passwords and enable two-factor authentication (2FA).
- **Firewall Configuration:**
- Limit access to Home Assistant ports to trusted networks.
- **Regular Monitoring:**
- Keep an eye on logs and system performance to detect any anomalies.
### **8.4 Resource Monitoring**
- **Supervisor > System:**
- Monitor CPU, memory, and disk usage to ensure optimal performance.
- **Add-ons:**
- Some add-ons provide their own monitoring tools (e.g., **System Monitor**).
---
## **9. Troubleshooting**
### **9.1 Common Issues**
1. **Supervisor Not Starting:**
- **Check Docker Status:**
```bash
sudo systemctl status docker
```
- **Restart Docker:**
```bash
sudo systemctl restart docker
```
- **Check Logs:**
```bash
sudo journalctl -u docker -f
sudo journalctl -u hassio-supervisor.service -f
```
2. **Add-ons Not Installing:**
- **Verify Network Connectivity:** Ensure your server can access the internet.
- **Check Docker Permissions:** Ensure the user running Docker has the necessary permissions.
- **Review Logs:** Navigate to **Supervisor > System > Logs** for detailed error messages.
3. **Home Assistant Not Accessible:**
- **Check Container Status:**
```bash
docker ps
```
Ensure the `homeassistant` container is running.
- **Verify Port Accessibility:** Ensure port `8123` is open and not blocked by a firewall.
### **9.2 Getting Help**
- **Home Assistant Community Forums:** [Home Assistant Community](https://community.home-assistant.io/)
- **Home Assistant Discord Server:** [Join Discord](https://discord.gg/c5DvZ4e)
- **Official Documentation:** [Home Assistant Docs](https://www.home-assistant.io/docs/)
---
## **10. Additional Resources**
- **Home Assistant Supervised Installer Repository:**
- [GitHub - home-assistant/supervised-installer](https://github.com/home-assistant/supervised-installer)
- **Official Home Assistant Installation Guides:**
- [Home Assistant Installation Overview](https://www.home-assistant.io/installation/)
- **Docker Documentation:**
- [Docker Engine Overview](https://docs.docker.com/engine/)
- **Home Assistant Add-ons Documentation:**
- [Home Assistant Add-ons](https://www.home-assistant.io/addons/)
---
## **Summary**
By following the steps outlined above, you can successfully install Home Assistant Supervised on a Debian Linux server, enabling you to manage Home Assistant and its add-ons via Docker containers effectively. This setup provides a balance between ease of use and the flexibility to customize your Home Assistant environment to meet your specific needs.
**Key Points:**
- **Home Assistant Supervised** combines the power of the Supervisor with the flexibility of a standard Linux environment.
- **Docker** is central to managing Home Assistant Core and its add-ons.
- **Regular Maintenance**, including updates and backups, is crucial for a stable and secure Home Assistant setup.
- **Community Resources** are invaluable for troubleshooting and optimizing your Home Assistant experience.
Feel free to reach out to the Home Assistant community if you encounter any challenges or have specific questions during your setup!
@@ -0,0 +1,10 @@
ewelink token:
```
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI0NmQ0MjA2NGI1MmQ0ZDgwOTM4NDliMzRiZjA2NzJmOSIsImlhdCI6MTczMzgxMjEwNywiZXhwIjoyMDQ5MTcyMTA3fQ.LBpi_uNLKK1FiWGNOm7p5C4w5pSkbCF0t5o_5h_rWFI
```
truenas
```
1-aFFnjLWyRXoF8iNa5ZAG4WUsEqrc9KMbzgSZOZoHeJUBIyRlQ3pEtOMjQj4VQnpP
```
+70
View File
@@ -0,0 +1,70 @@
```python
import os
from datetime import timedelta
from homeassistant import auth, core, config as conf_util
CLIENT_ID = 'long_lived_client'
LIFE_TIME = timedelta(days=3650)
async def create_refresh_token(auth_mgr: auth.AuthManager,
owner: auth.models.User):
"""Create a refresh token for owner."""
refresh_token = auth.models.RefreshToken(
user=owner,
access_token_expiration=LIFE_TIME,
client_id=CLIENT_ID,
)
owner.refresh_tokens[refresh_token.id] = refresh_token
# hack code to save refresh_token
await auth_mgr._store._store.async_save(
auth_mgr._store._data_to_save())
print('Created a new refresh token for {}: {}'.format(
CLIENT_ID, refresh_token.id))
return refresh_token
async def get_long_live_access_token(auth_mgr: auth.AuthManager):
"""Create a bearer token for owner."""
owner = [u for u in await auth_mgr.async_get_users() if u.is_owner][0]
print('Owner name is {}\n'.format(owner.name))
refresh_token = None
for token in owner.refresh_tokens.values():
if token.client_id == CLIENT_ID:
refresh_token = token
break
if not refresh_token:
refresh_token = await create_refresh_token(auth_mgr, owner)
# get access_token, it won't saved
access_token = auth_mgr.async_create_access_token(refresh_token)
print('Add following HTTP header to your REST API'
' and Websocket API request:')
print('Authorization: Bearer {}'.format(access_token))
# change to your config path
config_dir = conf_util.get_default_config_dir()
config_path = conf_util.ensure_config_exists(config_dir)
print('Loading config from {}'.format(config_path))
config_dict = conf_util.load_yaml_config_file(config_path)
core_config = config_dict.get('homeassistant', {})
hass = core.HomeAssistant()
hass.config.config_dir = os.path.abspath(os.path.dirname(config_path))
hass.loop.run_until_complete(
conf_util.async_process_ha_core_config(
hass, core_config, False, False))
hass.loop.run_until_complete(
get_long_live_access_token(hass.auth))
```
@@ -0,0 +1,11 @@
api key:
```
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
```
```bash
docker pull ghcr.io/knoop7/ha-openai-whisper-stt-api/groq-proxy2:20240830
```
@@ -0,0 +1,45 @@
### **什么是 Matter Thread Border Router?**
**Matter Thread Border Router** 是一种连接 **Thread 网络**(低功耗 IoT 设备的自愈网状网络)和 **IP 网络**Wi-Fi/以太网)的网关设备。
- 它允许 **Matter** 协议支持的设备(如传感器、灯具)通过 Thread 网络与其他智能家居设备和平台(如 Google Home、Apple HomeKit)通信。
- **功能**:桥接 Thread 和 IP 网络,支持本地控制和设备间互操作。
---
### **当前推荐的产品(2024 年)**
1. **Google Nest Hub (2nd Gen)** / **Nest Wi-Fi Pro**
- **特点**: 用户友好,自动配置,支持 Thread 和 Matter。
- **适合人群**: Google 生态用户。
- **价格**: $99-199。
2. **Apple HomePod mini** / **Apple TV 4K**
- **特点**: 无缝整合 HomeKit,支持 Thread 和 Matter,极简设计。
- **适合人群**: Apple 生态用户。
- **价格**: $99-129。
3. **Amazon Echo (4th Gen)**
- **特点**: 支持 Alexa 和 Matter,兼容性强。
- **适合人群**: Alexa 生态用户。
- **价格**: $99。
4. **Eero 6+ / Eero Pro 6**
- **特点**: 结合 Thread Border Router 和高性能 Wi-Fi 6 路由器功能。
- **适合人群**: 需要 Wi-Fi 和 Thread 整合的用户。
- **价格**: $139-299。
---
### **推荐购买依据**
- **Apple 生态**:选 HomePod mini 或 Apple TV 4K。
- **Google 生态**:选 Nest Hub (2nd Gen) 或 Nest Wi-Fi Pro。
- **Alexa 生态**:选 Echo 4th Gen。
- **全能路由需求**:选 Eero 系列,兼顾 Wi-Fi 和 Matter/Thread。
这些设备即插即用,适合不同智能家居平台和未来 Matter 生态的扩展需求。
@@ -0,0 +1,11 @@
```
CREATE DATABASE scribe;
CREATE USER scribe WITH PASSWORD 'hass';
GRANT ALL PRIVILEGES ON DATABASE scribe TO scribe;
\c scribe
CREATE EXTENSION IF NOT EXISTS timescaledb;
GRANT ALL ON SCHEMA public TO scribe;
```
@@ -0,0 +1,18 @@
login with google windyboy
90 days, 12/12 2025
Mar 12, 2026 expired
api key
```
tskey-api-kWRsSNyq8s11CNTRL-LWc27MXNgjMBKZ9rVauriMb5QS1RkWrZ
```
auth key:
Mar 12, 2026 expired
```
tskey-auth-kwEwVkec3721CNTRL-nX7noqZbMWdZYXPbkCFKXdjLf6B6CMW7D
```
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,61 @@
To flash the Sonoff ZBDongle-E, follow these detailed steps using the web-based flashing tool. This guide assumes you want to enable the device for use with Zigbee and potentially Thread functionalities.
## Step-by-Step Flashing Guide
### 1. **Gather Required Materials**
- **Sonoff ZBDongle-E**: Ensure you have the dongle ready.
- **Computer**: A PC or Mac with a USB port.
- **Firmware File**: Download the appropriate firmware for the ZBDongle-E from a reliable source (e.g., GitHub repository).
- **Web Browser**: Use a Chromium-based browser like Chrome or Edge.
### 2. **Download Firmware**
- Go to the GitHub page for Sonoff firmware and download the latest firmware for the ZBDongle-E, such as the Ember firmware or any other desired version ([GitHub Repository](https://github.com/itead/Sonoff_Zigbee_Dongle_Firmware/tree/master/Dongle-E/NCP_7.4.3)).
### 3. **Connect the Dongle**
- Disconnect the ZBDongle-E from any device.
- Plug it into your computer's USB port.
### 4. **Access the Flashing Tool**
- Open your web browser and navigate to the [Silicon Labs Firmware Builder](https://darkxst.github.io/silabs-firmware-builder/).
### 5. **Connect to the Dongle**
- Scroll down to find the section for ZBDongle-E.
- Click on the **Connect** button.
- In the dialog that appears, select your Sonoff dongle from the list and click on the blue **Connect** button.
### 6. **Select Firmware for Flashing**
- After connecting, click on **Change Firmware**.
- Choose the option to **Upload Your Own Firmware**.
- Select the firmware file you downloaded earlier.
### 7. **Start Flashing Process**
- Click on **Install** to begin flashing the firmware onto your ZBDongle-E.
- Wait for the process to complete; do not disconnect or close your browser until flashing is finished.
### 8. **Completion and Power Cycle**
- Once flashing is complete, a dialog will indicate success. Click on **Continue**.
- It is recommended to power cycle your dongle by unplugging it and then reattaching it to the USB port.
### 9. **Verify Installation**
- After reconnecting, check if your ZBDongle-E is recognized by your system.
- You can also verify its functionality within your smart home setup (e.g., Home Assistant).
### Additional Notes
- If you encounter issues connecting or flashing, ensure that you have installed any necessary drivers for your operating system.
- Make sure that no other applications are trying to access the dongle during this process.
By following these steps, you should successfully flash your Sonoff ZBDongle-E, enabling it for use in various smart home applications, including Zigbee and potentially Thread networks.
Citations:
[1] https://www.creatingsmarthome.com/index.php/2024/06/14/guide-flashing-sonoff-zigbee-usb-3-0-zbdongle-e-to-use-ember-firmware-with-z2m/
[2] https://docs.homeseer.com/products/updating-firmware-for-sonoff-zbdongle-e-zigbee-usb
[3] https://dialedin.com.au/blog/sonoff-zbdongle-e-rcp-firmware
[4] https://www.youtube.com/watch?v=3mlu4YluJRs
[5] https://www.reddit.com/r/homeassistant/comments/19b6a3d/zigstar_help_flashing_sonoff_usb_dongle_pluse_as/
[6] https://community.home-assistant.io/t/which-firmware-for-sonoff-dongle-e-router/621819
[7] https://community.hubitat.com/t/how-to-flash-sonoff-usb-dongle-to-be-a-zigbee-repeater-router-set-transmit-power/103284
[8] https://www.smarthomejunkie.net/update-the-sonoff-zigbee-dongle-e-easily-how-to/
[9] https://community.home-assistant.io/t/flashing-sonoff-zbdongle-e-to-router-question/725973
+814
View File
@@ -0,0 +1,814 @@
```sql
CREATE DATABASE hass;
CREATE USER hass WITH PASSWORD 'hass';
GRANT ALL PRIVILEGES ON DATABASE hass TO hass;
```
```
recorder:
db_url: postgresql://hass:hass@store.local/hass
```
Migrating your Home Assistant instance from SQLite to PostgreSQL involves a few steps. The process ensures all your historical state and event data from the existing SQLite database is preserved.
---
### **Step 1: Backup Your Current Home Assistant Instance**
1. **Stop Home Assistant**:
```bash
sudo systemctl stop home-assistant
```
2. **Create a Backup of Your SQLite Database**:
- The database is typically located in the Home Assistant configuration directory (e.g., `/config/` or `/home/homeassistant/.homeassistant`).
```bash
cp home-assistant_v2.db home-assistant_v2.db.backup
```
3. **Backup Your Configuration Files**:
```bash
tar -czvf home_assistant_config_backup.tar.gz /path/to/home-assistant/config
```
---
### **Step 2: Install and Configure PostgreSQL**
1. **Install PostgreSQL**:
```bash
sudo apt update
sudo apt install postgresql
```
2. **Create a Database for Home Assistant**:
- Switch to the `postgres` user:
```bash
sudo -i -u postgres
```
- Create the database and user:
```bash
psql
CREATE DATABASE hass;
CREATE USER hass WITH PASSWORD 'hass';
GRANT ALL PRIVILEGES ON DATABASE hass TO hass;
\q
```
- Exit the `postgres` user:
```bash
exit
```
3. **Test the Connection**: Use the `psql` client to connect:
```bash
psql -h localhost -U hass -d hass
```
Enter the password you set earlier. If successful, you're ready to proceed.
---
### **Step 3: Install Required Tools**
1. **Install SQLite and PostgreSQL Clients**:
```bash
sudo apt install sqlite3 postgresql-client
```
2. **Install `pgloader`**: `pgloader` is a tool for migrating data between SQLite and PostgreSQL.
```bash
sudo apt install pgloader
```
---
### **Step 4: Migrate Data from SQLite to PostgreSQL**
1. **Prepare the `pgloader` Command**: Create a file called `migrate.load` with the following content:
```lisp
LOAD DATABASE
FROM sqlite://./home-assistant_v2.db.bak
INTO postgresql://hass:hass@localhost/hass
WITH data only,
drop indexes,
reset sequences,
truncate;
ALTER SCHEMA "main" RENAME TO "public";
```
Replace `/path/to/home-assistant_v2.db` with the actual path to your SQLite database file.
2. **Run the Migration**:
```bash
pgloader migrate.load
```
3. **Verify the Data in PostgreSQL**:
- Log in to PostgreSQL:
```bash
psql -h localhost -U hass -d homeassistant
```
- Check the tables:
```sql
\dt
```
---
### **Step 5: Configure Home Assistant to Use PostgreSQL**
1. **Edit `configuration.yaml`**: Add the PostgreSQL database URL:
```yaml
recorder:
db_url: postgresql://hass:hass@192.168.55.53/hass
```
Replace `yourpassword` and `localhost` as needed.
2. **Restart Home Assistant**:
```bash
sudo systemctl start home-assistant
```
3. **Verify the Integration**:
- Check the logs in Home Assistant for any database-related errors.
- Confirm new data is being written to PostgreSQL by querying the `states` table:
```sql
SELECT * FROM states ORDER BY last_updated DESC LIMIT 10;
```
---
### **Step 6: Clean Up**
1. **Remove Old SQLite Database**: Once you confirm PostgreSQL is working, you can safely remove the SQLite database:
```bash
rm home-assistant_v2.db
```
2. **Optimize PostgreSQL**:
- Configure PostgreSQL to improve performance: Edit `/etc/postgresql/<version>/main/postgresql.conf`:
```plaintext
shared_buffers = 256MB
work_mem = 16MB
maintenance_work_mem = 64MB
```
- Restart PostgreSQL:
```bash
sudo systemctl restart postgresql
```
---
### **Final Notes**
- Keep monitoring Home Assistant's logs during the first few days after migration to ensure the PostgreSQL setup is stable.
- If needed, adjust the recorder settings in `configuration.yaml` to exclude entities or domains that generate excessive data:
```yaml
recorder:
include:
domains:
- sensor
- switch
exclude:
entities:
- sensor.unnecessary_metric
```
Let me know if you need assistance with any specific step!
```
```sql
LOAD DATABASE
FROM mysql://root:数据库密码@localhost:3306/homeassistant
INTO pgsql://homeassistant:数据库密码@localhost:5432/homeassistant
WITH data only, workers = 8, concurrency = 1
CAST type datetime to timestamp drop default drop not null using zero-dates-to-null
;
```
```bash
sqlite3 home-assistant_v2.db.bak .dump > ha_dump.sql
```
```bash
sed -i 's/DATETIME/TIMESTAMP/g' ha_dump.sql
```
```bash
sed -i 's/BLOB/BYTEA/g' ha_dump.sql
```
```bash
psql -h localhost -U hass -d hass -f ha_dump.sql -W > load.log 2>&1
```
```
pgloader sqlite://./home-assistant_v2.db.bak postgresql://hass:hass@localhost/hass
```
```sql
CREATE SEQUENCE event_types_event_type_id_seq;
CREATE SEQUENCE state_attributes_attributes_id_seq;
CREATE SEQUENCE event_data_data_id_seq;
CREATE SEQUENCE states_meta_metadata_id_seq;
CREATE SEQUENCE statistics_meta_id_seq;
CREATE SEQUENCE events_event_id_seq;
CREATE SEQUENCE recorder_runs_run_id_seq;
CREATE SEQUENCE schema_changes_change_id_seq;
CREATE SEQUENCE statistics_runs_run_id_seq;
CREATE SEQUENCE states_state_id_seq;
CREATE SEQUENCE statistics_id_seq;
CREATE SEQUENCE statistics_short_term_id_seq;
SELECT setval('event_types_event_type_id_seq', MAX(event_type_id)) FROM event_types;
SELECT setval('state_attributes_attributes_id_seq', MAX(attributes_id)) FROM state_attributes;
SELECT setval('event_data_data_id_seq', MAX(data_id)) FROM event_data;
SELECT setval('states_meta_metadata_id_seq', MAX(metadata_id)) FROM states_meta;
SELECT setval('statistics_meta_id_seq', MAX(id)) FROM statistics_meta;
SELECT setval('events_event_id_seq', MAX(event_id)) FROM events;
SELECT setval('recorder_runs_run_id_seq', MAX(run_id)) FROM recorder_runs;
SELECT setval('schema_changes_change_id_seq', MAX(change_id)) FROM schema_changes;
SELECT setval('statistics_runs_run_id_seq', MAX(run_id)) FROM statistics_runs;
SELECT setval('states_state_id_seq', MAX(state_id)) FROM states;
SELECT setval('statistics_id_seq', MAX(id)) FROM statistics;
SELECT setval('statistics_short_term_id_seq', MAX(id)) FROM statistics_short_term;
```
```
recorder:
db_url: postgresql://hass:hass@192.168.55.53/hass
```
```
influxdb:
host: 192.168.55.53
port: 8428
database: hass
default_measurement: state
```
mysql:
```sql
CREATE DATABASE hass;
CREATE USER 'hass'@'%' IDENTIFIED BY 'hass';
GRANT ALL PRIVILEGES ON homeassistant.* TO 'hass'@'%';
FLUSH PRIVILEGES;
```
```
sqlite3mysql --sqlite-file home-assistant_v2.db --mysql-user hass --mysql-password hass --mysql-database hass
```
```
recorder:
db_url: mysql://hass:hass@192.168.55.53/hass?charset=utf8mb4
```
```
influxdb:
api_version: 1
host: 192.168.55.53
port: 8428
max_retries: 3
measurement_attr: entity_id
tags_attributes:
- friendly_name
- unit_of_measurement
ignore_attributes:
- icon
- source
- options
- editable
- min
- max
- step
- mode
- marker_type
- preset_modes
- supported_features
- supported_color_modes
- effect_list
- attribution
- assumed_state
- state_open
- state_closed
- writable
- stateExtra
- event
- friendly_name
- device_class
- state_class
- ip_address
- device_file
- unit_of_measurement
- unitOfMeasure
include:
domains:
- sensor
- binary_sensor
- light
- switch
- cover
- climate
- input_boolean
- input_select
- number
- lock
- weather
exclude:
entity_globs:
- sensor.clock*
- sensor.date*
- sensor.glances*
- sensor.time*
- sensor.uptime*
- sensor.dwd_weather_warnings_*
- weather.weatherstation
- binary_sensor.*_smartphone_*
- sensor.*_smartphone_*
- sensor.adguard_home_*
- binary_sensor.*_internet_access
```
get sqlite schema
```
sqlite3 home-assistant_v2.db <<EOF
.output sqlite-schema.sql
.schema
.exit
EOF
```
postgresql create:
```sql
-- Drop all tables and references to ensure a clean slate
DROP TABLE IF EXISTS event_data CASCADE;
DROP TABLE IF EXISTS event_types CASCADE;
DROP TABLE IF EXISTS state_attributes CASCADE;
DROP TABLE IF EXISTS states_meta CASCADE;
DROP TABLE IF EXISTS statistics_meta CASCADE;
DROP TABLE IF EXISTS recorder_runs CASCADE;
DROP TABLE IF EXISTS migration_changes CASCADE;
DROP TABLE IF EXISTS schema_changes CASCADE;
DROP TABLE IF EXISTS statistics_runs CASCADE;
DROP TABLE IF EXISTS events CASCADE;
DROP TABLE IF EXISTS states CASCADE;
DROP TABLE IF EXISTS statistics CASCADE;
DROP TABLE IF EXISTS statistics_short_term CASCADE;
DROP TABLE IF EXISTS sqlite_stat1 CASCADE;
-- Enable TimescaleDB extension
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Create tables with appropriate data types and constraints
CREATE TABLE event_data (
data_id SERIAL PRIMARY KEY,
hash BIGINT,
shared_data TEXT
);
CREATE INDEX ix_event_data_hash ON event_data (hash);
CREATE TABLE event_types (
event_type_id SERIAL PRIMARY KEY,
event_type VARCHAR(64) UNIQUE
);
CREATE TABLE state_attributes (
attributes_id SERIAL PRIMARY KEY,
hash BIGINT,
shared_attrs TEXT
);
CREATE INDEX ix_state_attributes_hash ON state_attributes (hash);
CREATE TABLE states_meta (
metadata_id SERIAL PRIMARY KEY,
entity_id VARCHAR(255) UNIQUE
);
CREATE TABLE statistics_meta (
id SERIAL PRIMARY KEY,
statistic_id VARCHAR(255),
source VARCHAR(32),
unit_of_measurement VARCHAR(255),
has_mean BOOLEAN,
has_sum BOOLEAN,
name VARCHAR(255)
);
CREATE TABLE recorder_runs (
run_id SERIAL PRIMARY KEY,
start TIMESTAMPTZ NOT NULL,
"end" TIMESTAMPTZ,
closed_incorrect BOOLEAN NOT NULL,
created TIMESTAMPTZ NOT NULL
);
CREATE INDEX ix_recorder_runs_start_end ON recorder_runs (start, "end");
CREATE TABLE migration_changes (
migration_id VARCHAR(255) PRIMARY KEY,
version SMALLINT NOT NULL
);
CREATE TABLE schema_changes (
change_id SERIAL PRIMARY KEY,
schema_version INTEGER,
changed TIMESTAMPTZ NOT NULL
);
CREATE TABLE statistics_runs (
run_id SERIAL PRIMARY KEY,
start TIMESTAMPTZ NOT NULL
);
CREATE INDEX ix_statistics_runs_start ON statistics_runs (start);
-- Create hypertable for time-series data
CREATE TABLE events (
event_id SERIAL NOT NULL,
event_type VARCHAR(64),
event_data TEXT,
origin VARCHAR(64),
origin_idx SMALLINT,
time_fired TIMESTAMPTZ NOT NULL, -- Partitioning column
time_fired_ts DOUBLE PRECISION,
context_id UUID,
context_user_id UUID,
context_parent_id UUID,
data_id INTEGER,
context_id_bin BYTEA,
context_user_id_bin BYTEA,
context_parent_id_bin BYTEA,
event_type_id INTEGER,
PRIMARY KEY (event_id, time_fired), -- Composite primary key
FOREIGN KEY (data_id) REFERENCES event_data (data_id),
FOREIGN KEY (event_type_id) REFERENCES event_types (event_type_id)
);
SELECT create_hypertable('events', 'time_fired');
-- Add time_fired to all unique indexes on hypertables
CREATE INDEX ix_events_data_id ON events (data_id);
CREATE UNIQUE INDEX ix_events_event_type_id_time_fired_ts ON events (event_type_id, time_fired, time_fired_ts);
CREATE INDEX ix_events_time_fired_ts ON events (time_fired_ts);
CREATE INDEX ix_events_context_id_bin ON events (context_id_bin);
CREATE TABLE states (
state_id SERIAL PRIMARY KEY,
entity_id VARCHAR(255),
state VARCHAR(255),
attributes TEXT,
event_id INTEGER,
last_changed TIMESTAMPTZ,
last_changed_ts DOUBLE PRECISION,
last_reported_ts DOUBLE PRECISION,
last_updated TIMESTAMPTZ,
last_updated_ts DOUBLE PRECISION,
old_state_id INTEGER,
attributes_id INTEGER,
context_id UUID,
context_user_id UUID,
context_parent_id UUID,
origin_idx SMALLINT,
context_id_bin BYTEA,
context_user_id_bin BYTEA,
context_parent_id_bin BYTEA,
metadata_id INTEGER,
FOREIGN KEY(old_state_id) REFERENCES states (state_id),
FOREIGN KEY(attributes_id) REFERENCES state_attributes (attributes_id),
FOREIGN KEY(metadata_id) REFERENCES states_meta (metadata_id)
);
CREATE INDEX ix_states_last_updated_ts ON states (last_updated_ts);
CREATE INDEX ix_states_context_id_bin ON states (context_id_bin);
CREATE INDEX ix_states_attributes_id ON states (attributes_id);
CREATE INDEX ix_states_old_state_id ON states (old_state_id);
CREATE INDEX ix_states_metadata_id_last_updated_ts ON states (metadata_id, last_updated_ts);
-- Drop the existing table if necessary
DROP TABLE IF EXISTS statistics CASCADE;
-- Create the statistics table
CREATE TABLE statistics (
id SERIAL not NULL, -- Simple primary key
created TIMESTAMPTZ,
created_ts DOUBLE PRECISION,
metadata_id INTEGER,
start TIMESTAMPTZ NOT NULL, -- Partitioning column
start_ts DOUBLE PRECISION,
mean DOUBLE PRECISION,
min DOUBLE PRECISION,
max DOUBLE PRECISION,
last_reset TIMESTAMPTZ,
last_reset_ts DOUBLE PRECISION,
state DOUBLE PRECISION,
sum DOUBLE PRECISION,
PRIMARY KEY (id, start),
FOREIGN KEY(metadata_id) REFERENCES statistics_meta (id) ON DELETE CASCADE
);
-- Create the hypertable with 'start' as the partitioning column
SELECT create_hypertable('statistics', 'start');
-- Create a unique index that includes the partitioning column
CREATE UNIQUE INDEX ix_statistics_statistic_id_start_ts ON statistics (metadata_id, start_ts, start);
-- Additional non-unique index for querying by start_ts
CREATE INDEX ix_statistics_start_ts ON statistics (start_ts);
CREATE TABLE statistics_short_term (
id SERIAL not null,
created TIMESTAMPTZ,
created_ts DOUBLE PRECISION,
metadata_id INTEGER,
start TIMESTAMPTZ NOT NULL, -- Partitioning column
start_ts DOUBLE PRECISION,
mean DOUBLE PRECISION,
min DOUBLE PRECISION,
max DOUBLE PRECISION,
last_reset TIMESTAMPTZ,
last_reset_ts DOUBLE PRECISION,
state DOUBLE PRECISION,
sum DOUBLE PRECISION,
primary key(id, start),
FOREIGN KEY(metadata_id) REFERENCES statistics_meta (id) ON DELETE CASCADE
);
SELECT create_hypertable('statistics_short_term', 'start');
CREATE UNIQUE INDEX ix_statistics_short_term_statistic_id_start_ts ON statistics_short_term (metadata_id, start_ts, start);
CREATE INDEX ix_statistics_short_term_start_ts ON statistics_short_term (start_ts);
-- Drop unsupported SQLite-specific table
DROP TABLE IF EXISTS sqlite_stat1 CASCADE;
```
+273
View File
@@ -0,0 +1,273 @@
Congratulation, your registration already validated.
Your token is
761ba9c8b1745baed8d667f036d6ab46a843b962
You can now try, for instance, to get the beijing feed using:
[https://api.waqi.info/feed/here/?token=761ba9c8b1745baed8d667f036d6ab46a843b962](https://api.waqi.info/feed/here/?token=761ba9c8b1745baed8d667f036d6ab46a843b962)
And you will get this result:
```json
{
"status": "ok",
"data": {
"aqi": 38,
"idx": 1451,
"attributions": [
{
"url": "http://www.bjmemc.com.cn/",
"name": "Beijing Environmental Protection Monitoring Center (北京市环境保护监测中心)"
},
{
"url": "https://waqi.info/",
"name": "World Air Quality Index Project"
}
],
"city": {
"geo": [
39.954592,
116.468117
],
"name": "Beijing (北京)",
"url": "https://aqicn.org/city/beijing",
"location": ""
},
"dominentpol": "pm25",
"iaqi": {
"co": {
"v": 3.7
},
"h": {
"v": 33
},
"no2": {
"v": 9.2
},
"o3": {
"v": 19.9
},
"p": {
"v": 1035
},
"pm10": {
"v": 21
},
"pm25": {
"v": 38
},
"so2": {
"v": 1.6
},
"t": {
"v": -1
},
"w": {
"v": 4.6
}
},
"time": {
"s": "2024-12-13 23:00:00",
"tz": "+08:00",
"v": 1734130800,
"iso": "2024-12-13T23:00:00+08:00"
},
"forecast": {
"daily": {
"o3": [
{
"avg": 1,
"day": "2024-12-12",
"max": 1,
"min": 1
},
{
"avg": 7,
"day": "2024-12-13",
"max": 14,
"min": 1
},
{
"avg": 2,
"day": "2024-12-14",
"max": 10,
"min": 1
},
{
"avg": 4,
"day": "2024-12-15",
"max": 13,
"min": 1
},
{
"avg": 1,
"day": "2024-12-16",
"max": 6,
"min": 1
},
{
"avg": 1,
"day": "2024-12-17",
"max": 5,
"min": 1
},
{
"avg": 1,
"day": "2024-12-18",
"max": 1,
"min": 1
}
],
"pm10": [
{
"avg": 67,
"day": "2024-12-12",
"max": 73,
"min": 58
},
{
"avg": 27,
"day": "2024-12-13",
"max": 72,
"min": 7
},
{
"avg": 29,
"day": "2024-12-14",
"max": 46,
"min": 11
},
{
"avg": 39,
"day": "2024-12-15",
"max": 58,
"min": 19
},
{
"avg": 45,
"day": "2024-12-16",
"max": 58,
"min": 24
},
{
"avg": 41,
"day": "2024-12-17",
"max": 57,
"min": 16
},
{
"avg": 69,
"day": "2024-12-18",
"max": 73,
"min": 57
},
{
"avg": 95,
"day": "2024-12-19",
"max": 116,
"min": 72
}
],
"pm25": [
{
"avg": 168,
"day": "2024-12-12",
"max": 174,
"min": 159
},
{
"avg": 86,
"day": "2024-12-13",
"max": 173,
"min": 30
},
{
"avg": 91,
"day": "2024-12-14",
"max": 138,
"min": 42
},
{
"avg": 116,
"day": "2024-12-15",
"max": 158,
"min": 68
},
{
"avg": 130,
"day": "2024-12-16",
"max": 158,
"min": 80
},
{
"avg": 122,
"day": "2024-12-17",
"max": 158,
"min": 60
},
{
"avg": 170,
"day": "2024-12-18",
"max": 174,
"min": 158
},
{
"avg": 203,
"day": "2024-12-19",
"max": 238,
"min": 172
}
],
"uvi": [
{
"avg": 0,
"day": "2024-12-13",
"max": 1,
"min": 0
},
{
"avg": 0,
"day": "2024-12-14",
"max": 1,
"min": 0
},
{
"avg": 0,
"day": "2024-12-15",
"max": 1,
"min": 0
},
{
"avg": 0,
"day": "2024-12-16",
"max": 1,
"min": 0
},
{
"avg": 0,
"day": "2024-12-17",
"max": 1,
"min": 0
},
{
"avg": 0,
"day": "2024-12-18",
"max": 0,
"min": 0
}
]
}
},
"debug": {
"sync": "2024-12-14T01:26:38+09:00"
}
}
}
```
+88
View File
@@ -0,0 +1,88 @@
Yes, **pgloader** can work with a **MySQL dump file**, but it is not the most common or optimal way to use pgloader. By default, pgloader is designed to connect directly to the MySQL or MariaDB database and migrate the schema and data to PostgreSQL in one seamless operation. However, it does have support for importing data from SQL dump files.
---
### **How to Use pgloader with a MySQL Dump File**
#### **1. Prepare the MySQL Dump File**
Generate a dump file from MariaDB/MySQL that is compatible with PostgreSQL:
```bash
mysqldump --compatible=postgresql --default-character-set=utf8 --no-create-db --skip-lock-tables --extended-insert --quote-names -u hass -p hass > hass.sql
```
- `--compatible=postgresql`: Ensures basic compatibility with PostgreSQL.
- `--skip-lock-tables`: Prevents table locking during dump.
- `--extended-insert`: Creates multi-row insert statements, which are efficient.
- `--quote-names`: Ensures column names are quoted, reducing syntax conflicts.
#### **2. Adjust the Dump File (If Needed)**
MySQL dump files may still include syntax incompatible with PostgreSQL, such as:
- **AUTO_INCREMENT** → Replace with PostgreSQL `SERIAL`.
- **Backticks (`)** → Replace with double quotes (`"`).
- **Engine and Charset Options**:
```sql
ENGINE=InnoDB DEFAULT CHARSET=utf8;
```
Remove or ignore these lines.
Tools like `sed` or manual editing can handle these adjustments.
#### **3. Use pgloader to Import the Dump File**
Create a pgloader configuration file to handle the dump file import. Here's an example configuration:
```lisp
LOAD DATABASE
FROM FILE 'hass.sql'
INTO postgresql://hass:hass@localhost/hass
WITH include no drop, create tables, create indexes, reset sequences
SET work_mem to '128MB',
maintenance_work_mem to '512MB'
ALTER SCHEMA 'hass' RENAME TO 'public';
```
- **FROM FILE**: Specifies the path to the MySQL dump file.
- **INTO**: Defines the PostgreSQL database connection string.
- **ALTER SCHEMA**: Optionally maps schemas.
Run pgloader:
```bash
pgloader /path/to/config_file.load
```
---
### **Caveats**
- **Dump File Complexity**: If the dump file includes MariaDB/MySQL-specific functions or features, these might not be translated properly.
- **Manual Adjustments**: Even with `--compatible=postgresql`, dump files often need manual cleanup.
- **Direct Connection Preferred**: When possible, connect pgloader directly to the MariaDB database for a smoother migration:
```bash
pgloader mysql://user:password@host/dbname postgresql://user:password@host/dbname
```
---
### **Best Practice**
If your dump file requires significant manual adjustment, consider alternatives:
- Use a direct pgloader connection.
- Opt for an ETL tool or custom migration script if your schema is complex.
Let me know if youd like help fine-tuning a configuration for pgloader or alternatives! 🚀
+6
View File
@@ -0,0 +1,6 @@
windy-esp
key
```
kVH0VWBT1R6h9npUIQKWqmmrcpjhtzpywniDWutjwhQ=
```
+6
View File
@@ -0,0 +1,6 @@
token:
```
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiNjVjMzgyZDdiMGE0Yjk3OWJmZjhjYTk4NmRmMjFmMyIsImlhdCI6MTczNDY4NjkxNSwiZXhwIjoyMDUwMDQ2OTE1fQ.A69RTqVKSs4fMzzAuO6NRF8UXEXjgKNvz5fhrdYAl6Y
```
+5
View File
@@ -0,0 +1,5 @@
tuya local
@@ -0,0 +1,16 @@
default user: homeassistant
default password:
```
__**password_not_changed**__
```
```
mqtt:
broker: "192.168.55.53"
port: 1883
username: "hass"
password: "hass"
discovery: true
```
+26
View File
@@ -0,0 +1,26 @@
login by wexin qrcode
login id generate:
```python
def generate_qr_login_id():
"""
Generate a unique id for qr code login
word-by-word copied from js code
"""
rand_str = f"{int(time.time() * 1000)}{random.random()}"
return md5(rand_str.encode()).hexdigest()
```
generated:
```id
607d21bf2f06142e52d2057de49eed8d
```
@@ -0,0 +1,230 @@
```
type: vertical-stack
cards:
- type: horizontal-stack
title: 用电状态
cards:
- type: sensor
entity: sensor.0800041935246530_this_month_total_usage
name: 本月用电
icon: mdi:home-lightning-bolt-outline
- hours_to_show: 24
graph: none
type: sensor
entity: sensor.0800041935246530_latest_day_kwh
name: 昨天用电
icon: mdi:home-lightning-bolt-outline
detail: 1
- hours_to_show: 24
graph: none
type: sensor
entity: sensor.0800041935246530_arrears
detail: 1
icon: mdi:currency-jpy
unit: 元
name: 应交电费
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_last_month_total_usage
name: 上月用电
icon: mdi:home-lightning-bolt-outline
- hours_to_show: 24
graph: none
type: sensor
entity: sensor.airpowerheatertemperature
name: 上月电费
detail: 1
icon: mdi:currency-jpy
unit: 元
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_this_year_total_usage
name: 本年用电
icon: mdi:home-lightning-bolt-outline
- hours_to_show: 24
graph: none
type: sensor
entity: sensor.0800041935246530_this_year_total_cost
name: 本年电费
detail: 1
icon: mdi:currency-jpy
unit: 元
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_last_year_total_usage
icon: mdi:home-lightning-bolt-outline
name: 上年用电
- hours_to_show: 24
graph: none
type: sensor
entity: sensor.0800041935246530_last_year_total_cost
name: 上年电费
detail: 1
icon: mdi:currency-jpy
unit: 元
- type: horizontal-stack
cards:
- type: custom:apexcharts-card
header:
show: true
title: 30天用电与费用趋势图
graph_span: 30d
span:
start: day
offset: '-30d'
series:
- entity: sensor.history_day
type: column
name: 用电功率
color: rgb(51,153,255)
attribute: history_day_value
data_generator: |
return entity.attributes.history_day_value.map(entry => {
return {
x: entry.date,
y: entry.kwh
};
});
- entity: sensor.history_day
name: 用电费用
color: rgb(255,153,0)
attribute: history_day_value
data_generator: |
return entity.attributes.history_day_value.map(entry => {
return {
x: entry.date,
y: entry.kwh*0.65886875
};
});
```
```
type: grid
cards:
- type: vertical-stack
cards:
- type: horizontal-stack
title: 用电状态
cards:
- graph: none
type: sensor
entity: sensor.0800041935246530_this_month_total_usage
name: 本月用电
icon: mdi:home-lightning-bolt-outline
hours_to_show: 24
detail: 1
- type: sensor
entity: sensor.0800041935246530_latest_day_kwh
name: 昨天用电
icon: mdi:home-lightning-bolt-outline
detail: 1
hours_to_show: 24
graph: none
- type: sensor
entity: sensor.0800041935246530_arrears
detail: 1
icon: mdi:currency-jpy
unit: 元
name: 应交电费
grid_options:
columns: 12
rows: 4
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_last_month_total_usage
name: 上月用电
icon: mdi:home-lightning-bolt-outline
hours_to_show: 24
graph: none
- type: sensor
entity: sensor.airpowerheatertemperature
name: 上月电费
detail: 1
icon: mdi:currency-jpy
unit: 元
grid_options:
columns: 12
rows: 2
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_this_year_total_usage
name: 本年用电
icon: mdi:home-lightning-bolt-outline
hours_to_show: 24
graph: none
- type: sensor
entity: sensor.0800041935246530_this_year_total_cost
name: 本年电费
detail: 1
icon: mdi:currency-jpy
unit: 元
grid_options:
columns: 12
rows: 2
- type: horizontal-stack
cards:
- type: sensor
entity: sensor.0800041935246530_last_year_total_usage
icon: mdi:home-lightning-bolt-outline
name: 上年用电
hours_to_show: 24
graph: none
- type: sensor
entity: sensor.0800041935246530_last_year_total_cost
name: 上年电费
detail: 1
icon: mdi:currency-jpy
unit: 元
grid_options:
columns: 12
rows: 2
- type: horizontal-stack
cards:
- type: custom:apexcharts-card
header:
show: true
title: 30天用电与费用趋势图
graph_span: 30d
span:
start: day
offset: "-30d"
series:
- entity: sensor.history_day
type: column
name: 用电功率
color: rgb(51,153,255)
attribute: history_day_value
data_generator: |
return entity.attributes.history_day_value.map(entry => {
return {
x: entry.date,
y: entry.kwh
};
});
- entity: sensor.history_day
name: 用电费用
color: rgb(255,153,0)
attribute: history_day_value
data_generator: |
return entity.attributes.history_day_value.map(entry => {
return {
x: entry.date,
y: entry.kwh*0.65886875
};
});
grid_options:
columns: 12
rows: 5
column_span: 1
```
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,6 @@
api key:
```
36602152f76cae66841cd3c94d99405b.nhlX0m8dCtBOxB8S
```