Last active
April 1, 2024 07:56
-
-
Save JanM321/b550285713f20231386509b2c227f0b8 to your computer and use it in GitHub Desktop.
LG Template Sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Home Assistant template sensor I use as room temperature sensor with | |
# https://github.com/JanM321/esphome-lg-controller | |
# | |
# It addresses the following problems I had with my LG Multi F units in heating mode: | |
# | |
# 1) Heating range too large: with over heating installer setting 15 set to 3 (-1/+1 °C), | |
# after rounding to 0.5°C, the range is 1.5°C (-0.75/+0.75 °C). Often more because | |
# the unit has to pre-heat etc. These temperature swings are too uncomfortable. | |
# | |
# 2) Under-heating: the unit doesn't try very hard to reach and maintain its setpoint while heating. | |
# It sometimes lets the temperature drop to `setpoint - 1°C` or even less for long periods of time | |
# while heating without requesting more heat. Intermittent and I'm not sure what exactly is causing this, | |
# but other users have reported the same problem. | |
# | |
# To work around 1), the template sensor adjusts the temperature values around the setpoint so that the | |
# effective on/off range is about -0.2°C/+0.8°C in heating mode. | |
# | |
# To work around 2), if the temperature drops below `setpoint - 0.03` and it has been heating for more | |
# than 20 minutes (1200 seconds), it forces the unit to work harder by using `temperature - 0.3` as | |
# temperature. It also uses `setpoint - 2.5` if the temperature drops too far. | |
# | |
# The LG (multi split) units aren't the best at heating, but these tweaks make my unit's behavior a | |
# lot more acceptable. | |
# | |
# Update April 2024: I changed this to be less aggressive than the previous version. | |
# Requires the Home Assistant Uptime integration. Restarting HA resets the `last_changed` timestamp | |
# so it also checks the uptime sensor to work around this. | |
- name: "LG Living Room Sensor" | |
state: > | |
{% set temperature = states.sensor.my_temperature_sensor.state|float %} | |
{% set setpoint = states.climate.lg_living_room.attributes.temperature|float %} | |
{% if (not is_state('climate.lg_living_room', 'heat')) %} | |
{{ temperature }} | |
{% else %} | |
{% if temperature < setpoint - 0.03 and is_state('binary_sensor.lg_living_room_preheat', 'off') and | |
(as_timestamp(now()) - as_timestamp(states.sensor.uptime.state) > 1200 and | |
as_timestamp(now()) - as_timestamp(states.binary_sensor.lg_living_room_preheat.last_changed) > 1200) %} | |
{% set temperature = temperature - 0.3 %} | |
{% endif %} | |
{% if temperature > setpoint + 0.8 %} | |
{{ temperature }} | |
{% elif temperature > setpoint + 0.4 %} | |
{{ setpoint + 0.5 }} | |
{% elif temperature > setpoint + 0.1 %} | |
{{ setpoint }} | |
{% elif temperature > setpoint - 0.2 %} | |
{{ setpoint - 0.5 }} | |
{% elif temperature > setpoint - 0.4 %} | |
{{ setpoint - 1 }} | |
{% elif temperature > setpoint - 2.5 %} | |
{{ setpoint - 2.5 }} | |
{% else %} | |
{{ temperature }} | |
{% endif %} | |
{% endif %} | |
unit_of_measurement: "°C" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment