Refactor Personal folder structure for improved organization
Consolidated 16+ top-level categories into 8 clear functional groups (AI, Development, Home-Automation, Infrastructure, Lifestyle, PKM, Professional, Backup). Merged duplicate files (OpenRouter.md, Github.md) and archived originals. This simplifies navigation and improves long-term maintainability. (vault changes by Claude Code)
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
|
||||
# windy-ai
|
||||
|
||||
## config
|
||||
### key
|
||||
```
|
||||
MdhX7jL4hPFVOhjHCft46pbCD7chZJY9rkuAXD620BwW32axUMq6JQQJ99ALACHYHv6XJ3w3AAAAACOGH6q1
|
||||
```
|
||||
### Location/Region
|
||||
```
|
||||
eastus2
|
||||
```
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
|
||||
|
||||
```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))
|
||||
|
||||
```
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
api key:
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/knoop7/ha-openai-whisper-stt-api/groq-proxy2:20240830
|
||||
```
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,814 +0,0 @@
|
||||
|
||||
```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;
|
||||
```
|
||||
@@ -1,273 +0,0 @@
|
||||
|
||||
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,88 +0,0 @@
|
||||
|
||||
|
||||
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 you’d like help fine-tuning a configuration for pgloader or alternatives! 🚀
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
windy-esp
|
||||
key
|
||||
```
|
||||
kVH0VWBT1R6h9npUIQKWqmmrcpjhtzpywniDWutjwhQ=
|
||||
```
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
token:
|
||||
```
|
||||
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiNjVjMzgyZDdiMGE0Yjk3OWJmZjhjYTk4NmRmMjFmMyIsImlhdCI6MTczNDY4NjkxNSwiZXhwIjoyMDUwMDQ2OTE1fQ.A69RTqVKSs4fMzzAuO6NRF8UXEXjgKNvz5fhrdYAl6Y
|
||||
```
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
tuya local
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
default user: homeassistant
|
||||
default password:
|
||||
```
|
||||
__**password_not_changed**__
|
||||
```
|
||||
|
||||
```
|
||||
mqtt:
|
||||
broker: "192.168.55.53"
|
||||
port: 1883
|
||||
username: "hass"
|
||||
password: "hass"
|
||||
discovery: true
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
|
||||
```
|
||||
|
||||
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
@@ -1,6 +0,0 @@
|
||||
|
||||
api key:
|
||||
```
|
||||
36602152f76cae66841cd3c94d99405b.nhlX0m8dCtBOxB8S
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user