Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ha thermostat automatization with chinese temp sensor (zigbee 4$) #628

Open
marek9336 opened this issue Oct 27, 2023 · 1 comment
Open

Comments

@marek9336
Copy link

I was frustrated that I couldn't find automation for the heat pump, so I made my own. I recommend adding this to your proposed automation.

I used yaml to add a virtual thermostat that uses a cheap sensor from aliexpress and automated my LG heat pump.

First, I added a virtual thermostat to configuration.yaml, which controls the temperature according to the sensor from aliexpress:

climate:
 - platform: generic_thermostat
   name: Virtual Thermostat
   heater: switch.dummy_switch
   target_sensor: sensor.temperature_humidity_sensor_temperature # Temperature sensor from aliexpress
   min_temp: 15
   max_temp: 25
   initial_hvac_mode: "off"
   precision: 0.1 # The accuracy of the thermostat

I also created two automations, one that increases the temperature, the other that decreases the temperature of the pump.

Temp + :

alias: Termostat +1°C
description: ""
trigger:
  - platform: time_pattern
    enabled: true
    minutes: /30
condition:
  - condition: template
    value_template: >-
      {{ (state_attr('climate.virtual_thermostat', 'temperature') | float) -
      (state_attr('climate.virtual_thermostat', 'current_temperature') | float)
      | abs > 0.2 }}
    enabled: true
action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.tepelne_cerpadlo
      temperature: >
        {% set target_temp = state_attr('climate.tepelne_cerpadlo',
        'temperature') | float %} {% set current_temp =
        state_attr('climate.virtual_thermostat', 'current_temperature') | float
        %} {% if current_temp > target_temp + 0.2 %}
          {{ target_temp - 1 }}
        {% elif current_temp < target_temp - 0.2 %}
          {{ target_temp + 1 }}
        {% else %}
          {{ target_temp }}
        {% endif %}
  - device_id: 49ece7bc804606d0883ec8133d88e4df
    domain: climate
    entity_id: 21a5b74cb87df7742d5c8fd3568eda68
    type: set_hvac_mode
    hvac_mode: heat
mode: single

Temp - :

alias: Termostat -1°C
description: ""
trigger:
  - platform: time_pattern
    enabled: true
    minutes: "30"
condition:
  - condition: template
    value_template: >-
      {{ (state_attr('climate.virtual_thermostat', 'current_temperature') |
      float) - (state_attr('climate.virtual_thermostat', 'temperature') | float)
      | abs > 0.2 }}
    enabled: true
action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.tepelne_cerpadlo
      temperature: >
        {% set target_temp = state_attr('climate.tepelne_cerpadlo',
        'temperature') | float %} {% set current_temp =
        state_attr('climate.virtual_thermostat', 'current_temperature') | float
        %} {% if current_temp < target_temp + 0.2 %}
          {{ target_temp - 1 }}
        {% elif current_temp > target_temp - 0.2 %}
          {{ target_temp + 1 }}
        {% else %}
          {{ target_temp }}
        {% endif %}
mode: single

In addition, temperature + turns on the pump, if I turned off the pump manually, in the future I want to automate the pump shutdown when it heats to less than 25°, because then it heats almost empty. If someone figured out how to improve this script including turning off the pump, I would be happy if they improved it into one automation including both automations.
I know, that my scripts are not perfect, but it works and I'll be happy if someone fixes it, thanks it was a lot of experiments and I'm too lazy to fix it when it works :-)

I wish you a nice day and successful automation!

@ollo69
Copy link
Owner

ollo69 commented Nov 19, 2023

The goal of home-assistant is to use available entities together to create automations.
Integration just provide entities for a specific device, should not provide any automation.
You correctly you create your automation using entities provided by multiple integration, I'm not understanding what you are asking for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants