Skip to content

Instantly share code, notes, and snippets.

@mujuzo
Last active April 25, 2026 17:41
Show Gist options
  • Select an option

  • Save mujuzo/5da92d3a4f77df761d82e2ec58d7a528 to your computer and use it in GitHub Desktop.

Select an option

Save mujuzo/5da92d3a4f77df761d82e2ec58d7a528 to your computer and use it in GitHub Desktop.
EnergyHub LED Home Assistant automaatio (WLED + ESP32)
# EnergyHub LED automaatio
# ESP32 + WLED + Home Assistant
# Muokkaa entity_id:t omaan järjestelmääsi sopiviksi.
- alias: EnergyHub - Grid segmentti
id: energyhub_grid_segmentti
mode: restart
trigger:
- platform: state
entity_id: sensor.p1_meter_teho
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
power: "{{ states('sensor.p1_meter_teho') | float(0) }}"
pv_dim: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv_dim < 100 %}
0.5
{% elif pv_dim < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ power > 50 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_6
data:
rgb_color: [0, 120, 255]
brightness: "{{ (35 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ power < -50 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_6
data:
rgb_color: [0, 180, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_6
data:
rgb_color: [255, 255, 255]
brightness: "{{ (15 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub - Load segmentti
id: energyhub_load_segmentti
mode: restart
trigger:
- platform: state
entity_id: sensor.talon_hetkellinen_kulutus
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
load_power: "{{ states('sensor.talon_hetkellinen_kulutus') | float(0) | abs }}"
pv_dim: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv_dim < 100 %}
0.5
{% elif pv_dim < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ load_power < 2000 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_5
data:
rgb_color: [0, 180, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ load_power >= 2000 and load_power < 5000 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_5
data:
rgb_color: [255, 180, 0]
brightness: "{{ (35 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_5
data:
rgb_color: [255, 0, 0]
brightness: "{{ (45 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub - Price segmentti
id: energyhub_price_segmentti
mode: restart
trigger:
- platform: state
entity_id: sensor.ostetun_sahkon_hinta
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
price: "{{ states('sensor.ostetun_sahkon_hinta') | float(0) }}"
pv_dim: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv_dim < 100 %}
0.5
{% elif pv_dim < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ price < 0.07 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_4
data:
rgb_color: [0, 180, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ price >= 0.07 and price <= 0.12 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_4
data:
rgb_color: [255, 180, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_4
data:
rgb_color: [255, 0, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub - PV segmentti
id: energyhub_pv_segmentti
mode: restart
trigger:
- platform: state
entity_id: sensor.sungrow_active_power
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
pv: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv < 100 %}
0.5
{% elif pv < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ pv < 100 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_3
data:
rgb_color: [255, 255, 255]
brightness: "{{ (5 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ pv >= 100 and pv < 2000 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_3
data:
rgb_color: [0, 120, 255]
brightness: "{{ (15 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ pv >= 2000 and pv < 5000 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_3
data:
rgb_color: [0, 200, 180]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ pv >= 5000 and pv < 9000 }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_3
data:
rgb_color: [255, 180, 0]
brightness: "{{ (40 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_3
data:
rgb_color: [255, 235, 180]
brightness: "{{ (55 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub - EV segmentti
id: energyhub_ev_segmentti
mode: restart
trigger:
- platform: state
entity_id:
- switch.shellypro1_ec62608be038_switch_0
- input_boolean.ev_solar_mode
- binary_sensor.ev_safe_to_charge
- input_boolean.ev_safety_lock
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
pv_dim: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv_dim < 100 %}
0.5
{% elif pv_dim < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: state
entity_id: input_boolean.ev_safety_lock
state: "on"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_2
data:
rgb_color: [255, 0, 0]
brightness: "{{ (35 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: state
entity_id: switch.shellypro1_ec62608be038_switch_0
state: "on"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_2
data:
rgb_color: [0, 180, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: state
entity_id: input_boolean.ev_solar_mode
state: "on"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_2
data:
rgb_color: [255, 170, 0]
brightness: "{{ (25 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: state
entity_id: binary_sensor.ev_safe_to_charge
state: "off"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_2
data:
rgb_color: [180, 180, 180]
brightness: "{{ (10 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_2
data:
rgb_color: [255, 255, 255]
brightness: "{{ (6 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub - Heating segmentti
id: energyhub_heating_segmentti
mode: restart
trigger:
- platform: state
entity_id: sensor.wp_operating_mode_text
for: "00:00:10"
- platform: time_pattern
minutes: "/1"
- platform: state
entity_id: input_boolean.energyhub_led_enabled
to: "on"
- platform: state
entity_id: light.wled_gledopto
to: "on"
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.energyhub_led_enabled
state: "on"
action:
- variables:
mode_text: "{{ states('sensor.wp_operating_mode_text') }}"
pv_dim: "{{ states('sensor.sungrow_active_power') | float(0) }}"
dim_factor: >
{% if pv_dim < 100 %}
0.5
{% elif pv_dim < 1000 %}
0.75
{% else %}
1.0
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ 'Käyttövesiajo' in mode_text }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_1
data:
rgb_color: [255, 0, 0]
brightness: "{{ (35 * dim_factor) | round(0) | int }}"
effect: Solid
- conditions:
- condition: template
value_template: "{{ 'Lämmitysajo' in mode_text }}"
sequence:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_1
data:
rgb_color: [255, 140, 0]
brightness: "{{ (28 * dim_factor) | round(0) | int }}"
effect: Solid
default:
- service: light.turn_on
target:
entity_id: light.wled_gledopto_segmentti_1
data:
rgb_color: [255, 255, 255]
brightness: "{{ (6 * dim_factor) | round(0) | int }}"
effect: Solid
- alias: EnergyHub LED enable päivä
id: energyhub_led_enable_paiva
mode: single
trigger:
- platform: time
at: "07:00:00"
- platform: homeassistant
event: start
condition:
- condition: time
after: "07:00:00"
before: "23:00:00"
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.energyhub_led_enabled
- alias: EnergyHub LED yö OFF
id: energyhub_led_yo_off
mode: single
trigger:
- platform: time
at: "23:00:00"
- platform: homeassistant
event: start
condition:
- condition: or
conditions:
- condition: time
after: "23:00:00"
- condition: time
before: "07:00:00"
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.energyhub_led_enabled
- service: light.turn_off
target:
entity_id:
- light.wled_gledopto
- light.wled_gledopto_segmentti_1
- light.wled_gledopto_segmentti_2
- light.wled_gledopto_segmentti_3
- light.wled_gledopto_segmentti_4
- light.wled_gledopto_segmentti_5
- light.wled_gledopto_segmentti_6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment