Initial commit: Add Pstryk Energy Card v4.1.0
- Add main card implementation with full/compact/super_compact modes - Support for sparkline and bars widgets with effects - Price color coding based on best/worst price ranges - Alert system for high/low price thresholds - Polish/English translations support - HACS integration configuration - Development guidelines in AGENTS.md
This commit is contained in:
27
AGENTS.md
Normal file
27
AGENTS.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Agent Guidelines for Pstryk Energy Card
|
||||
|
||||
## Build/Test Commands
|
||||
- No build system - single JavaScript file (`pstryk-card.js`)
|
||||
- Test by adding card to Home Assistant dashboard
|
||||
- Debug mode: set `debug: true` in card config
|
||||
- No linting/formatting tools configured
|
||||
|
||||
## Code Style Guidelines
|
||||
- **Language**: Vanilla JavaScript ES6+ (no frameworks)
|
||||
- **File structure**: Single file with embedded CSS in template literals
|
||||
- **Class naming**: PascalCase (e.g., `PstrykCard`)
|
||||
- **Method naming**: camelCase with underscore prefix for private methods (e.g., `_getTranslations`)
|
||||
- **Variables**: camelCase, use const/let appropriately
|
||||
- **Comments**: Polish comments for user-facing text, English for technical notes
|
||||
- **Error handling**: Throw descriptive Error objects in `setConfig()` for validation
|
||||
- **Translations**: Support PL/EN via `_getTranslations()` method
|
||||
- **CSS**: Use CSS custom properties for theming, embed in `<style>` tags
|
||||
- **SVG**: Inline SVG for charts, use viewBox for responsiveness
|
||||
- **Home Assistant**: Follow custom card conventions, register with `customElements.define()`
|
||||
|
||||
## Key Patterns
|
||||
- Shadow DOM for encapsulation
|
||||
- Lifecycle methods: `connectedCallback()`, `disconnectedCallback()`
|
||||
- Config validation in `setConfig()`
|
||||
- Performance optimization in `set hass()` with change detection
|
||||
- Timer management for hourly refreshes
|
||||
94
README.md
Normal file
94
README.md
Normal file
@ -0,0 +1,94 @@
|
||||
# 🏠 Pstryk Energy Card dla Home Assistant
|
||||
|
||||
  
|
||||
|
||||
---
|
||||
|
||||
## ✨ Co potrafi?
|
||||
|
||||
* 🎨 Trzy tryby wyświetlania: **pełny**, **kompaktowy**, **super kompaktowy**
|
||||
* 📊 Widgety: słupki lub linia z animacją
|
||||
* 🚨 Alerty: ostrzeżenia, gdy cena przekracza ustalone progi
|
||||
* 🔴🟢 Zmiana koloru na czerwony/zielony w zależności od ustawień cen w integracji
|
||||
* 🌍 Obsługa PL i EN – karta sama wykryje język
|
||||
* 🎯 Efekty i zbędne bajery
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## 📦 Jak zainstalować?
|
||||
|
||||
**1. HACS (najprościej)**
|
||||
|
||||
1. Otwórz HACS → **+**
|
||||
2. Wybierz **Custom repositories**
|
||||
3. Wklej URL: `https://github.com/balgerion/ha_Pstryk_card`
|
||||
4. W kategorii zaznacz **Dashboard** i kliknij **Add**
|
||||
5. Zainstaluj **Pstryk Energy Card**
|
||||
6. Zrestartuj Home Assistant
|
||||
|
||||
**2. Ręcznie**
|
||||
|
||||
1. Ściągnij plik `pstryk-card.js` i wrzuć do `/www/community/pstryk-card`
|
||||
2. W Home Assistant: **Settings → Dashboards → Resources → Add Resource**
|
||||
|
||||
* URL: `/local/community/pstryk-card/pstryk-card.js`
|
||||
* Typ: **JavaScript Module**
|
||||
3. Zrestartuj
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Szybki start - przykłady
|
||||
|
||||
##full
|
||||
|
||||
```yaml
|
||||
type: custom:pstryk-card
|
||||
buy_entity: sensor.pstryk_current_buy_price
|
||||
sell_entity: sensor.pstryk_current_sell_price
|
||||
card_mode: full # full | compact | super_compact
|
||||
show_title: true # true | false
|
||||
show_legend: true # true | false
|
||||
show_widget: sparkline # none | bars | sparkline
|
||||
widget_effect: pulse # none | pulse (sparkline) | fill (bars)
|
||||
widget_hours: 24 # 1-48
|
||||
alert_buy_above: 1.15 # liczba lub null
|
||||
alert_sell_below: 0.25 # liczba lub null
|
||||
hover_effect: lift # none | lift | glow | shake | pulse
|
||||
click_action: none # none | more-info
|
||||
```
|
||||
##Kompaktowy z słupkami
|
||||
```yaml
|
||||
type: custom:pstryk-card
|
||||
buy_entity: sensor.pstryk_current_buy_price
|
||||
sell_entity: sensor.pstryk_current_sell_price
|
||||
card_mode: compact # full | compact | super_compact
|
||||
show_widget: bars # none | bars | sparkline
|
||||
widget_effect: fill # none | fill (bars) | pulse (sparkline)
|
||||
widget_hours: 12 # 1-48
|
||||
hover_effect: glow # none | lift | glow | shake | pulse
|
||||
attribute_config: average_24 # next_hour | average_remaining | average_24 | null | custom_attribute
|
||||
```
|
||||
|
||||
##Super kompaktowy (minimalny)
|
||||
```yaml
|
||||
type: custom:pstryk-card
|
||||
buy_entity: sensor.pstryk_current_buy_price
|
||||
sell_entity: sensor.pstryk_current_sell_price
|
||||
card_mode: super_compact # full | compact | super_compact
|
||||
alert_buy_above: 1.0 # liczba lub null
|
||||
alert_sell_below: 0.1 # liczba lub null
|
||||
```
|
||||
|
||||
## ⚙️ Wszystkie opcje
|
||||
|
||||
* **buy\_entity** (`string`) – encja z ceną zakupu (np. `sensor.pstryk_current_buy_price`)
|
||||
* **sell\_entity** (`string`) – encja z ceną sprzedaży
|
||||
* **card\_mode** (`full`/`compact`/`super_compact`) – wybierz wygląd karty
|
||||
* **title** (`string`) – tekst nagłówka (domyślnie "Energy Prices")
|
||||
* **show\_title** (`true`/`false`) – wyświetl tytuł
|
||||
* **show\_legend** (`true`/`false`) – legenda kolorów (tylko w `full`)
|
||||
* **attribute\_config** (`next_hour`/`average_remaining`/`average_24`/`null`/`custom`) – dodatkowy atrybut
|
||||
* **show\_widget** (`none`/`bars`/`sparkline`) – typ wykresu
|
||||
* **widget\_effect** (`none`/`pulse`/`fill`) – animacja wykresu (pulse (sparkline), fill (bars))
|
||||
5
hacs.json
Normal file
5
hacs.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Pstryk Energy Card",
|
||||
"filename": "pstryk-card.js",
|
||||
"render_readme": true
|
||||
}
|
||||
1230
pstryk-card.js
Normal file
1230
pstryk-card.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user