Repository navigation
Description
Hello everyone,
I’m Peter from the Netherlands. Like many others, I’m trying to control all the major energy consumers in our house—especially heating—so I can activate them when energy prices are lowest or when solar power is available. To start, I’m focusing on controlling the electric heating in our garage.
Since I’m not a programmer, I asked ChatGPT and Mistral to help me create a script. While it looks good, it doesn’t work as intended. First, the heating doesn’t start automatically. And when I turn it on manually, it doesn’t turn off automatically either.
I’ve checked all the sensors, and they’re working correctly. I apologize for the YAML code containing many symbols; I added them to make it more readable for myself.
Project Overview:
I have a Shelly 1 Mini connected to the plus and minus terminals of the normal thermostat input on the electric heater. The Shelly 1 Mini is controlled by Home Assistant (HA) using the script below.
The heating can activate in two ways:
Solar power mode: It turns on when net solar output exceeds 2000 watts and turns off when it drops below 400 watts.
Winter mode: If the remote thermostat drops below 10°C, the heating starts during the cheapest hourly energy prices of the day and turns off once 11°C is reached.
I also have an override switch to turn the heating on immediately and a season switch to disable heating in summer.
Errors:
The following lines in the script generate a PatternWarning:
service: switch.turn_on
service: switch.turn_off
platform: numeric_state
platform: state
These are the only errors I can see in the Home Assistant Code Studio.
Troubleshooting Steps:
Initially, Home Assistant showed the garage heating status as "waiting on temperature." I asked Mistral (Euro Chat GTP) to fix the issue, and it made some changes to the script. However, it feels like relying on AI to get this right is a dead end. Maybe I’m not asking the right questions or providing the right input, but I hope someone here can spot why the script isn’t working.
(Note: Most of the additional text in the script is in Dutch.)
############################################
🔥 GARAGE VERWARMING SLIM PAKKET (GEOPTIMALISEERD)
############################################
############################
⚙️ HELPERS (Dashboard)
############################
input_boolean:
garage_verwarming_seizoen:
name: "Verwarming Garage Seizoen"
icon: mdi:radiator
garage_override:
name: "Garage Verwarming Override"
icon: mdi:hand-back-right
############################
📊 TEMPLATE SENSORS & BINARY SENSORS
############################
template:
-
sensor:
⚡ Netto vermogen (P1 omgedraaid)
- name: "Netto Vermogen"
unit_of_measurement: "W"
state: >
{% if states('sensor.p1_meter_power') not in ['unavailable', 'unknown'] %}
{{ states('sensor.p1_meter_power') | float * -1 }}
{% else %}
0
{% endif %}
📊 Garage Verwarming Status
- name: "Garage Verwarming Status"
state: >
{% if is_state('input_boolean.garage_override', 'on') %}
Override actief
{% elif is_state('switch.verwarming_garage', 'on') %}
Verwarmen actief
{% elif is_state('binary_sensor.pv_overschot_hysterese', 'on') and states('sensor.wifi_temperature_garage_temperatuur') | float < 15 %}
Wacht op PV-overschot
{% else %}
Uit
{% endif %}
- name: "Netto Vermogen"
-
binary_sensor:
☀️ PV overschot hysterese + filtering
- name: "PV overschot hysterese"
state: >
{% set current_power = states('sensor.netto_vermogen') | float(0) %}
{% set was_on = is_state('binary_sensor.pv_overschot_hysterese', 'on') %}
{{ current_power > 2000 or (was_on and current_power > 400) }}
💶 Stroom goedkoop (onder daggemiddelde)
- name: "Stroom goedkoop"
state: >
{% if states('sensor.nordpool_energyprices') not in ['unavailable', 'unknown'] %}
{{ states('sensor.nordpool_energyprices') | float <
state_attr('sensor.nordpool_energyprices', 'average') | float(0) }}
{% else %}
false
{% endif %}
- name: "PV overschot hysterese"
############################
📊 STATISTICS (PIEKFILTER)
############################
sensor:
- platform: statistics
name: "Netto Vermogen 2min Gemiddeld"
entity_id: sensor.netto_vermogen
state_characteristic: mean
max_age:
minutes: 2
############################
🔥 HOOFD AUTOMATION
############################
automation:
-
alias: "Garage verwarming slim totaal"
mode: restarttrigger:
- platform: state
entity_id:- sensor.wifi_temperature_garage_temperatuur
- sensor.netto_vermogen_2min_gemiddeld
- binary_sensor.pv_overschot_hysterese
- input_boolean.garage_verwarming_seizoen
- input_boolean.garage_override
condition:
- condition: state
entity_id: input_boolean.garage_verwarming_seizoen
state: "on"
action:
-
choose:
##################################🟢 HANDMATIGE OVERRIDE
##################################
- conditions:
- condition: state
entity_id: input_boolean.garage_override
state: "on"
sequence: - service: switch.turn_on
target:
entity_id: switch.verwarming_garage
- condition: state
##################################
☀️ PV VERWARMEN
##################################
- conditions:
- condition: and
conditions:- condition: state
entity_id: binary_sensor.pv_overschot_hysterese
state: "on" - condition: numeric_state
entity_id: sensor.wifi_temperature_garage_temperatuur
below: 15 - condition: state
entity_id: switch.verwarming_garage
state: "off"
sequence:
- condition: state
- delay: "00:00:10"
- service: switch.turn_on
target:
entity_id: switch.verwarming_garage
- condition: and
##################################
❄️ VORST + GOEDKOOPSTE UREN
##################################
- conditions:
- condition: and
conditions:- condition: numeric_state
entity_id: sensor.wifi_temperature_garage_temperatuur
below: 10 - condition: state
entity_id: binary_sensor.stroom_goedkoop
state: "on" - condition: state
entity_id: switch.verwarming_garage
state: "off"
sequence:
- condition: numeric_state
- delay: "00:02:00"
- service: switch.turn_on
target:
entity_id: switch.verwarming_garage
- condition: and
##################################
🔴 UIT LOGICA
##################################
- conditions:
- condition: or
conditions:- condition: state
entity_id: binary_sensor.pv_overschot_hysterese
state: "off" - condition: numeric_state
entity_id: sensor.wifi_temperature_garage_temperatuur
above: 14.9
sequence:
- condition: state
- condition: state
entity_id: switch.verwarming_garage
state: "on" - delay: "00:05:00"
- service: switch.turn_off
target:
entity_id: switch.verwarming_garage
- condition: or
- conditions:
- platform: state
-
alias: "Garage verwarming uitschakelen bij laag vermogen"
trigger:- platform: numeric_state
entity_id: sensor.netto_vermogen
below: 800
condition: - condition: state
entity_id: switch.verwarming_garage
state: "on"
action: - delay: "00:05:00"
- service: switch.turn_off
target:
entity_id: switch.verwarming_garage
- platform: numeric_state
It would help me a lot if this one was working so I can use this at a base line of the heating in our house and the warm water supply.
Thank you in advance!
Greetings Peter
Activity