mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 13:23:41 +00:00
1 line
No EOL
20 KiB
JavaScript
1 line
No EOL
20 KiB
JavaScript
"use strict";(globalThis.webpackChunkdocs_split_user=globalThis.webpackChunkdocs_split_user||[]).push([[1945],{2283:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>l,contentTitle:()=>o,default:()=>h,frontMatter:()=>r,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"automation-examples","title":"Automation Examples","description":"Note: This guide is under construction.","source":"@site/docs/automation-examples.md","sourceDirName":".","slug":"/automation-examples","permalink":"/hass.tibber_prices/user/automation-examples","draft":false,"unlisted":false,"editUrl":"https://github.com/jpawlowski/hass.tibber_prices/tree/main/docs/user/docs/automation-examples.md","tags":[],"version":"current","lastUpdatedAt":1764985026000,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Chart Examples","permalink":"/hass.tibber_prices/user/chart-examples"},"next":{"title":"FAQ - Frequently Asked Questions","permalink":"/hass.tibber_prices/user/faq"}}');var s=n(4848),a=n(8453);const r={},o="Automation Examples",l={},c=[{value:"Table of Contents",id:"table-of-contents",level:2},{value:"Price-Based Automations",id:"price-based-automations",level:2},{value:"Volatility-Aware Automations",id:"volatility-aware-automations",level:2},{value:"Use Case: Only Act on High-Volatility Days",id:"use-case-only-act-on-high-volatility-days",level:3},{value:"Use Case: Absolute Price Threshold",id:"use-case-absolute-price-threshold",level:3},{value:"Use Case: Combined Volatility and Price Check",id:"use-case-combined-volatility-and-price-check",level:3},{value:"Use Case: Ignore Period Flips During Active Period",id:"use-case-ignore-period-flips-during-active-period",level:3},{value:"Use Case: Per-Period Day Volatility",id:"use-case-per-period-day-volatility",level:3},{value:"Best Hour Detection",id:"best-hour-detection",level:2},{value:"ApexCharts Cards",id:"apexcharts-cards",level:2},{value:"Prerequisites",id:"prerequisites",level:3},{value:"Installation",id:"installation",level:3},{value:"Example: Fixed Day View",id:"example-fixed-day-view",level:3},{value:"Example: Rolling 48h Window",id:"example-rolling-48h-window",level:3},{value:"Features",id:"features",level:3}];function d(e){const i={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.header,{children:(0,s.jsx)(i.h1,{id:"automation-examples",children:"Automation Examples"})}),"\n",(0,s.jsxs)(i.blockquote,{children:["\n",(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Note:"})," This guide is under construction."]}),"\n"]}),"\n",(0,s.jsxs)(i.blockquote,{children:["\n",(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Tip:"})," For dashboard examples with dynamic icons and colors, see the ",(0,s.jsx)(i.strong,{children:(0,s.jsx)(i.a,{href:"/hass.tibber_prices/user/dynamic-icons",children:"Dynamic Icons Guide"})})," and ",(0,s.jsx)(i.strong,{children:(0,s.jsx)(i.a,{href:"/hass.tibber_prices/user/icon-colors",children:"Dynamic Icon Colors Guide"})}),"."]}),"\n"]}),"\n",(0,s.jsx)(i.h2,{id:"table-of-contents",children:"Table of Contents"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#price-based-automations",children:"Price-Based Automations"})}),"\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#volatility-aware-automations",children:"Volatility-Aware Automations"})}),"\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#best-hour-detection",children:"Best Hour Detection"})}),"\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#apexcharts-cards",children:"ApexCharts Cards"})}),"\n"]}),"\n",(0,s.jsx)(i.hr,{}),"\n",(0,s.jsx)(i.h2,{id:"price-based-automations",children:"Price-Based Automations"}),"\n",(0,s.jsx)(i.p,{children:"Coming soon..."}),"\n",(0,s.jsx)(i.hr,{}),"\n",(0,s.jsx)(i.h2,{id:"volatility-aware-automations",children:"Volatility-Aware Automations"}),"\n",(0,s.jsx)(i.p,{children:"These examples show how to handle low-volatility days where period classifications may flip at midnight despite minimal absolute price changes."}),"\n",(0,s.jsx)(i.h3,{id:"use-case-only-act-on-high-volatility-days",children:"Use Case: Only Act on High-Volatility Days"}),"\n",(0,s.jsx)(i.p,{children:'On days with low price variation (< 15% volatility), the difference between "cheap" and "expensive" periods is minimal. This automation only runs appliances when the savings are meaningful:'}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:'automation:\n - alias: "Dishwasher - Best Price (High Volatility Only)"\n description: "Start dishwasher during Best Price period, but only on days with meaningful price differences"\n trigger:\n - platform: state\n entity_id: binary_sensor.tibber_home_best_price_period\n to: "on"\n condition:\n # Only act if volatility > 15% (meaningful savings)\n - condition: numeric_state\n entity_id: sensor.tibber_home_volatility_today\n above: 15\n # Optional: Ensure dishwasher is idle and door closed\n - condition: state\n entity_id: binary_sensor.dishwasher_door\n state: "off"\n action:\n - service: switch.turn_on\n target:\n entity_id: switch.dishwasher_smart_plug\n - service: notify.mobile_app\n data:\n message: "Dishwasher started during Best Price period ({{ states(\'sensor.tibber_home_current_interval_price_ct\') }} ct/kWh, volatility {{ states(\'sensor.tibber_home_volatility_today\') }}%)"\n'})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Why this works:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"On high-volatility days (e.g., 25% span), Best Price periods save 5-10 ct/kWh"}),"\n",(0,s.jsx)(i.li,{children:"On low-volatility days (e.g., 8% span), savings are only 1-2 ct/kWh"}),"\n",(0,s.jsx)(i.li,{children:"User can manually start dishwasher on low-volatility days without automation interference"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"use-case-absolute-price-threshold",children:"Use Case: Absolute Price Threshold"}),"\n",(0,s.jsx)(i.p,{children:"Instead of relying on relative classification, check if the absolute price is cheap enough:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:'automation:\n - alias: "Water Heater - Cheap Enough"\n description: "Heat water when price is below absolute threshold, regardless of period classification"\n trigger:\n - platform: state\n entity_id: binary_sensor.tibber_home_best_price_period\n to: "on"\n condition:\n # Absolute threshold: Only run if < 20 ct/kWh\n - condition: numeric_state\n entity_id: sensor.tibber_home_current_interval_price_ct\n below: 20\n # Optional: Check water temperature\n - condition: numeric_state\n entity_id: sensor.water_heater_temperature\n below: 55 # Only heat if below 55\xb0C\n action:\n - service: switch.turn_on\n target:\n entity_id: switch.water_heater\n - delay:\n hours: 2 # Heat for 2 hours\n - service: switch.turn_off\n target:\n entity_id: switch.water_heater\n'})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Why this works:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Period classification can flip at midnight on low-volatility days"}),"\n",(0,s.jsx)(i.li,{children:"Absolute threshold (20 ct/kWh) is stable across midnight boundary"}),"\n",(0,s.jsx)(i.li,{children:'User sets their own "cheap enough" price based on local rates'}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"use-case-combined-volatility-and-price-check",children:"Use Case: Combined Volatility and Price Check"}),"\n",(0,s.jsx)(i.p,{children:"Most robust approach: Check both volatility and absolute price:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:'automation:\n - alias: "EV Charging - Smart Strategy"\n description: "Charge EV using volatility-aware logic"\n trigger:\n - platform: state\n entity_id: binary_sensor.tibber_home_best_price_period\n to: "on"\n condition:\n # Check battery level\n - condition: numeric_state\n entity_id: sensor.ev_battery_level\n below: 80\n # Strategy: High volatility OR cheap enough\n - condition: or\n conditions:\n # Path 1: High volatility day - trust period classification\n - condition: numeric_state\n entity_id: sensor.tibber_home_volatility_today\n above: 15\n # Path 2: Low volatility but price is genuinely cheap\n - condition: numeric_state\n entity_id: sensor.tibber_home_current_interval_price_ct\n below: 18\n action:\n - service: switch.turn_on\n target:\n entity_id: switch.ev_charger\n - service: notify.mobile_app\n data:\n message: >\n EV charging started: {{ states(\'sensor.tibber_home_current_interval_price_ct\') }} ct/kWh\n (Volatility: {{ states(\'sensor.tibber_home_volatility_today\') }}%)\n'})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Why this works:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"On high-volatility days (> 15%): Trust the Best Price classification"}),"\n",(0,s.jsx)(i.li,{children:"On low-volatility days (< 15%): Only charge if price is actually cheap (< 18 ct/kWh)"}),"\n",(0,s.jsx)(i.li,{children:"Handles midnight flips gracefully: Continues charging if price stays cheap"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"use-case-ignore-period-flips-during-active-period",children:"Use Case: Ignore Period Flips During Active Period"}),"\n",(0,s.jsx)(i.p,{children:"Prevent automations from stopping mid-cycle when a period flips at midnight:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:'automation:\n - alias: "Washing Machine - Complete Cycle"\n description: "Start washing machine during Best Price, ignore midnight flips"\n trigger:\n - platform: state\n entity_id: binary_sensor.tibber_home_best_price_period\n to: "on"\n condition:\n # Only start if washing machine is idle\n - condition: state\n entity_id: sensor.washing_machine_state\n state: "idle"\n # And volatility is meaningful\n - condition: numeric_state\n entity_id: sensor.tibber_home_volatility_today\n above: 15\n action:\n - service: button.press\n target:\n entity_id: button.washing_machine_eco_program\n # Create input_boolean to track active cycle\n - service: input_boolean.turn_on\n target:\n entity_id: input_boolean.washing_machine_auto_started\n\n # Separate automation: Clear flag when cycle completes\n - alias: "Washing Machine - Cycle Complete"\n trigger:\n - platform: state\n entity_id: sensor.washing_machine_state\n to: "finished"\n condition:\n # Only clear flag if we auto-started it\n - condition: state\n entity_id: input_boolean.washing_machine_auto_started\n state: "on"\n action:\n - service: input_boolean.turn_off\n target:\n entity_id: input_boolean.washing_machine_auto_started\n - service: notify.mobile_app\n data:\n message: "Washing cycle complete"\n'})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Why this works:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["Uses ",(0,s.jsx)(i.code,{children:"input_boolean"})," to track auto-started cycles"]}),"\n",(0,s.jsx)(i.li,{children:"Won't trigger multiple times if period flips during the 2-3 hour wash cycle"}),"\n",(0,s.jsx)(i.li,{children:'Only triggers on "off" \u2192 "on" transitions, not during "on" \u2192 "on" continuity'}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"use-case-per-period-day-volatility",children:"Use Case: Per-Period Day Volatility"}),"\n",(0,s.jsx)(i.p,{children:"The simplest approach: Use the period's day volatility attribute directly:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:"automation:\n - alias: \"Heat Pump - Smart Heating\"\n trigger:\n - platform: state\n entity_id: binary_sensor.tibber_home_best_price_period\n to: \"on\"\n condition:\n # Check if the PERIOD'S DAY has meaningful volatility\n - condition: template\n value_template: >\n {{ state_attr('binary_sensor.tibber_home_best_price_period', 'day_volatility_%') | float(0) > 15 }}\n action:\n - service: climate.set_temperature\n target:\n entity_id: climate.heat_pump\n data:\n temperature: 22 # Boost temperature during cheap period\n"})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Available per-period attributes:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"day_volatility_%"}),": Percentage volatility of the period's day (e.g., 8.2 for 8.2%)"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"day_price_min"}),": Minimum price of the day in minor currency (ct/\xf8re)"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"day_price_max"}),": Maximum price of the day in minor currency (ct/\xf8re)"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"day_price_span"}),": Absolute difference (max - min) in minor currency (ct/\xf8re)"]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:["These attributes are available on both ",(0,s.jsx)(i.code,{children:"binary_sensor.tibber_home_best_price_period"})," and ",(0,s.jsx)(i.code,{children:"binary_sensor.tibber_home_peak_price_period"}),"."]}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Why this works:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Each period knows its day's volatility"}),"\n",(0,s.jsx)(i.li,{children:"No need to query separate sensors"}),"\n",(0,s.jsx)(i.li,{children:"Template checks if saving is meaningful (> 15% volatility)"}),"\n"]}),"\n",(0,s.jsx)(i.hr,{}),"\n",(0,s.jsx)(i.h2,{id:"best-hour-detection",children:"Best Hour Detection"}),"\n",(0,s.jsx)(i.p,{children:"Coming soon..."}),"\n",(0,s.jsx)(i.hr,{}),"\n",(0,s.jsx)(i.h2,{id:"apexcharts-cards",children:"ApexCharts Cards"}),"\n",(0,s.jsxs)(i.blockquote,{children:["\n",(0,s.jsxs)(i.p,{children:["\u26a0\ufe0f ",(0,s.jsx)(i.strong,{children:"IMPORTANT:"})," The ",(0,s.jsx)(i.code,{children:"tibber_prices.get_apexcharts_yaml"})," service generates a ",(0,s.jsx)(i.strong,{children:"basic example configuration"})," as a starting point. It is NOT a complete solution for all ApexCharts features."]}),"\n",(0,s.jsxs)(i.p,{children:["This integration is primarily a ",(0,s.jsx)(i.strong,{children:"data provider"}),". Due to technical limitations (segmented time periods, service API usage), many advanced ApexCharts features require manual customization or may not be compatible."]}),"\n",(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"For advanced customization:"})," Use the ",(0,s.jsx)(i.code,{children:"get_chartdata"})," service directly to build charts tailored to your specific needs. Community contributions with improved configurations are welcome!"]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:["The ",(0,s.jsx)(i.code,{children:"tibber_prices.get_apexcharts_yaml"})," service generates basic ApexCharts card configuration examples for visualizing electricity prices."]}),"\n",(0,s.jsx)(i.h3,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Required:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.a,{href:"https://github.com/RomRider/apexcharts-card",children:"ApexCharts Card"})," - Install via HACS"]}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Optional (for rolling window mode):"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.a,{href:"https://github.com/iantrich/config-template-card",children:"Config Template Card"})," - Install via HACS"]}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"installation",children:"Installation"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsx)(i.li,{children:"Open HACS \u2192 Frontend"}),"\n",(0,s.jsx)(i.li,{children:'Search for "ApexCharts Card" and install'}),"\n",(0,s.jsx)(i.li,{children:'(Optional) Search for "Config Template Card" and install if you want rolling window mode'}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"example-fixed-day-view",children:"Example: Fixed Day View"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:'# Generate configuration via automation/script\nservice: tibber_prices.get_apexcharts_yaml\ndata:\n entry_id: YOUR_ENTRY_ID\n day: today # or "yesterday", "tomorrow"\n level_type: rating_level # or "level" for 5-level view\nresponse_variable: apexcharts_config\n'})}),"\n",(0,s.jsx)(i.p,{children:"Then copy the generated YAML into your Lovelace dashboard."}),"\n",(0,s.jsx)(i.h3,{id:"example-rolling-48h-window",children:"Example: Rolling 48h Window"}),"\n",(0,s.jsx)(i.p,{children:"For a dynamic chart that automatically adapts to data availability:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:"service: tibber_prices.get_apexcharts_yaml\ndata:\n entry_id: YOUR_ENTRY_ID\n day: rolling_window # Or omit for same behavior (default)\n level_type: rating_level\nresponse_variable: apexcharts_config\n"})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Behavior:"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"When tomorrow data available"})," (typically after ~13:00): Shows today + tomorrow"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"When tomorrow data not available"}),": Shows yesterday + today"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Fixed 48h span:"})," Always shows full 48 hours"]}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.strong,{children:"Auto-Zoom Variant:"})}),"\n",(0,s.jsx)(i.p,{children:"For progressive zoom-in throughout the day:"}),"\n",(0,s.jsx)(i.pre,{children:(0,s.jsx)(i.code,{className:"language-yaml",children:"service: tibber_prices.get_apexcharts_yaml\ndata:\n entry_id: YOUR_ENTRY_ID\n day: rolling_window_autozoom\n level_type: rating_level\nresponse_variable: apexcharts_config\n"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Same data loading as rolling window"}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Progressive zoom:"})," Graph span starts at ~26h in the morning and decreases to ~14h by midnight"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Updates every 15 minutes:"})," Always shows 2h lookback + remaining time until midnight"]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Note:"})," Rolling window modes require Config Template Card to dynamically adjust the time range."]}),"\n",(0,s.jsx)(i.h3,{id:"features",children:"Features"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Color-coded price levels/ratings (green = cheap, yellow = normal, red = expensive)"}),"\n",(0,s.jsx)(i.li,{children:"Best price period highlighting (semi-transparent green overlay)"}),"\n",(0,s.jsx)(i.li,{children:"Automatic NULL insertion for clean gaps"}),"\n",(0,s.jsx)(i.li,{children:"Translated labels based on your Home Assistant language"}),"\n",(0,s.jsx)(i.li,{children:"Interactive zoom and pan"}),"\n",(0,s.jsx)(i.li,{children:"Live marker showing current time"}),"\n"]})]})}function h(e={}){const{wrapper:i}={...(0,a.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); |