Local control?

Unfortunately we do not get the same things that are bought in Europe or the United States. Here come the cheapest brands. I never managed to set the heater to the temperature it says. I always put more and when the heat comes it goes away. I mean, it depends on the day, it’s one temperature or another

Which country you are from?
I have also used cheap Chinese heaters, but some of the Chinese brands are also good.
Some temperature swings are expected in your system due to

  • Different measurement methods, Dallas sensor is in the aquarium and heaters are located in the sump tank.
  • Sump will be at different temperatures compared to the aquarium due to heat losses.
    If you don’t have sensitive fish, just set the temperature to a certain point and let esphome report the data over days.
    Watch the graphs for at least 2-3days before making any changes.

I am from Argentina. The heaters are in the sump below with the entire filtration system. And I have the sensors in the aquarium upstairs. I also have an stc 1000 which I am only using to have another reference.
I have Discus fish and yes they are a bit sensitive to changes in the water. That’s why I have everything redundant to avoid problems

For discus, low pH and High temperature are preferred. So temperature between 28-31C will do, which is quite a large range for such a big tank.

The problem is that I have known a person who stuck the heater and cook them. That’s why I even have alerts on my cell phone to know if I go down or go up more than I should. If so I find out at the moment and I can solve it. But if I activate it with a relay I don’t have the heater problem but I do have the home assistant problem. If I don’t have a connection with HA I can’t control anything. That’s why I wanted everything to be local in the esp32 configured with esphome

I seem obsessive but everything is very expensive for an unforeseen event to happen. And I have fish of many years that I would not want to lose.

Friends could you tell me what you think of the programming of the esphome. Can someone confirm if it’s ok? I don’t want to record it and have it start to fail. Thanks to all for the help

If you want the for condition, it can be accomplished with 2 binary sensors.

esphome:
  name: meteo

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "0664f60f6c5f7f8fe07e26bf0b9e1eac"

wifi:
  ssid: !secret wifi_ssid_ext
  password: !secret wifi_password

  ap:
    ssid: "meteo_ap"
    password: !secret wifi_password
    
    
captive_portal:
    
    
esp32_ble_tracker:

dallas:
  - pin: GPIO23

globals:  
  - id: temp_max
    type: float
    restore_value: yes
    initial_value: '28.5'        
  - id: temp_min
    type: float
    restore_value: yes
    initial_value: '28.3'        

number:
  - platform: template
    name: "Set max temp"
    id: temp_max_set
    optimistic: true
    min_value: 28.0
    max_value: 29.0
    step: 0.1
    on_value:
      - globals.set:
          id: temp_max
          value: !lambda 'return id(temp_max_set).state;'
  - platform: template
    name: "Set min temp"
    id: temp_min_set
    optimistic: true
    min_value: 28.0
    max_value: 29.0
    step: 0.1
    on_value:
      - globals.set:
          id: temp_min
          value: !lambda 'return id(temp_min_set).state;'


binary_sensor:
  - platform: template
    name: max
    id: max
    lambda: |-
      if (id(temp).state >= id(temp_max)) {
        return true;
      } else {
        return false;
      }
    on_state:
      if:
        condition:
          for:
            time: 5min
            condition:
              binary_sensor.is_on: max
        then:
          - switch.turn_off: relay_2
          - switch.turn_off: relay_3
          
  - platform: template
    id: min
    name: min
    lambda: |-
      if (id(temp).state <= id(temp_min)) {
        return true;
      } else {
        return false;
      }
    on_state:
      if:
        condition:
          for:
            time: 5min
            condition:
              binary_sensor.is_on: min
        then:
          - switch.turn_on: relay_2
          - switch.turn_on: relay_3
      
sensor:
  - platform: dallas
    address: 0x630516b54fc2ff28
    name: "Temperatura Sump"
    id: temp
    filters:
      - offset: 1.0
        


  - platform: dht
    pin: GPIO33
    temperature:
      name: "Temperatura Comedor"
    humidity:
      name: "Humedad Comedor"
    update_interval: 60s   
  - platform: pvvx_mithermometer
    mac_address: "A4:C1:38:7B:D2:35"
    temperature:
      name: "Temperatura cuarto principal"
      accuracy_decimals: 1
    humidity:
      name: "Humedad cuarto principal"
      accuracy_decimals: 0
    battery_level:
      name: "Nivel de Bateria cuarto principal"

switch:
  - platform: gpio
    name: "Relay 1"
    pin: GPIO27
    inverted: true
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 2"
    id: relay_2
    pin: GPIO26
    inverted: true
    restore_mode: ALWAYS_OFF 
  - platform: gpio
    name: "Relay 3"
    id: relay_3
    pin: GPIO25
    inverted: true    
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 4"
    pin: GPIO5
    inverted: true
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 5"
    pin: GPIO18
    inverted: true
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 6"
    pin: GPIO19
    inverted: true    
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 7"
    pin: GPIO21
    inverted: true
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "Relay 8"
    pin: GPIO22
    inverted: true
    restore_mode: ALWAYS_OFF

Hello. I’m still having a hard time understanding it. The global variables are taken from HA? Why should I have a binary variable?
When I try to record the code it shows me many errors. Could you help me? Thank you

INFO Reading configuration /config/esphome/meteo.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing meteo (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <WiFi> 1.0
|-- <FS> 1.0
|-- <Update> 1.0
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <AsyncTCP-esphome> 1.2.2
|-- <DNSServer> 1.1.0
|-- <ESPmDNS> 1.0
Compiling /data/meteo/.pioenvs/meteo/src/main.cpp.o
src/main.cpp:30:34: error: 'esphome::template_::TemplateBinarySensor* max' redeclared as different kind of symbol
 template_::TemplateBinarySensor *max;
                                  ^
In file included from /data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/char_traits.h:39:0,
                 from /data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/string:40,
                 from src/esphome/core/component.h:3,
                 from src/esphome/components/api/api_connection.h:3,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
/data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:219:5: note: previous declaration 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
     max(const _Tp& __a, const _Tp& __b)
     ^
src/main.cpp:36:34: error: 'esphome::template_::TemplateBinarySensor* min' redeclared as different kind of symbol
 template_::TemplateBinarySensor *min;
                                  ^
In file included from /data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/char_traits.h:39:0,
                 from /data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/string:40,
                 from src/esphome/core/component.h:3,
                 from src/esphome/components/api/api_connection.h:3,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
/data/cache/platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:195:5: note: previous declaration 'template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)'
     min(const _Tp& __a, const _Tp& __b)
     ^
src/main.cpp: In function 'void setup()':
src/main.cpp:337:7: error: overloaded function with no contextual type information
   max = new template_::TemplateBinarySensor();
       ^
src/main.cpp:338:33: error: no matching function for call to 'esphome::Application::register_binary_sensor(<unresolved overloaded function type>)'
   App.register_binary_sensor(max);
                                 ^
In file included from src/esphome/components/api/api_connection.h:4:0,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h:68:8: note: candidate: void esphome::Application::register_binary_sensor(esphome::binary_sensor::BinarySensor*)
   void register_binary_sensor(binary_sensor::BinarySensor *binary_sensor) {
        ^
src/esphome/core/application.h:68:8: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/main.cpp:339:6: error: overloaded function with no contextual type information
   max->set_name("max");
      ^
src/main.cpp:339:6: error: base operand of '->' is not a pointer
src/main.cpp:340:6: error: overloaded function with no contextual type information
   max->set_disabled_by_default(false);
      ^
src/main.cpp:340:6: error: base operand of '->' is not a pointer
src/main.cpp:341:67: error: no matching function for call to 'esphome::binary_sensor::StateTrigger::StateTrigger(<unresolved overloaded function type>)'
   binary_sensor_statetrigger = new binary_sensor::StateTrigger(max);
                                                                   ^
In file included from src/esphome.h:15:0,
                 from src/main.cpp:3:
src/esphome/components/binary_sensor/automation.h:124:12: note: candidate: esphome::binary_sensor::StateTrigger::StateTrigger(esphome::binary_sensor::BinarySensor*)
   explicit StateTrigger(BinarySensor *parent) {
            ^
src/esphome/components/binary_sensor/automation.h:124:12: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/esphome/components/binary_sensor/automation.h:122:7: note: candidate: constexpr esphome::binary_sensor::StateTrigger::StateTrigger(const esphome::binary_sensor::StateTrigger&)
 class StateTrigger : public Trigger<bool> {
       ^
src/esphome/components/binary_sensor/automation.h:122:7: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const esphome::binary_sensor::StateTrigger&'
src/esphome/components/binary_sensor/automation.h:122:7: note: candidate: constexpr esphome::binary_sensor::StateTrigger::StateTrigger(esphome::binary_sensor::StateTrigger&&)
src/esphome/components/binary_sensor/automation.h:122:7: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::StateTrigger&&'
src/main.cpp:343:93: error: no matching function for call to 'esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(<unresolved overloaded function type>, bool)'
   binary_sensor_binarysensorcondition = new binary_sensor::BinarySensorCondition<>(max, true);
                                                                                             ^
In file included from src/esphome.h:15:0,
                 from src/main.cpp:3:
src/esphome/components/binary_sensor/automation.h:131:3: note: candidate: esphome::binary_sensor::BinarySensorCondition<Ts>::BinarySensorCondition(esphome::binary_sensor::BinarySensor*, bool) [with Ts = {}]
   BinarySensorCondition(BinarySensor *parent, bool state) : parent_(parent), state_(state) {}
   ^
src/esphome/components/binary_sensor/automation.h:131:3: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/esphome/components/binary_sensor/automation.h:129:32: note: candidate: constexpr esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(const esphome::binary_sensor::BinarySensorCondition<>&)
 template<typename... Ts> class BinarySensorCondition : public Condition<Ts...> {
                                ^
src/esphome/components/binary_sensor/automation.h:129:32: note:   candidate expects 1 argument, 2 provided
src/esphome/components/binary_sensor/automation.h:129:32: note: candidate: constexpr esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(esphome::binary_sensor::BinarySensorCondition<>&&)
src/esphome/components/binary_sensor/automation.h:129:32: note:   candidate expects 1 argument, 2 provided
src/main.cpp:381:7: error: overloaded function with no contextual type information
   min = new template_::TemplateBinarySensor();
       ^
src/main.cpp:382:33: error: no matching function for call to 'esphome::Application::register_binary_sensor(<unresolved overloaded function type>)'
   App.register_binary_sensor(min);
                                 ^
In file included from src/esphome/components/api/api_connection.h:4:0,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h:68:8: note: candidate: void esphome::Application::register_binary_sensor(esphome::binary_sensor::BinarySensor*)
   void register_binary_sensor(binary_sensor::BinarySensor *binary_sensor) {
        ^
src/esphome/core/application.h:68:8: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/main.cpp:383:6: error: overloaded function with no contextual type information
   min->set_name("min");
      ^
src/main.cpp:383:6: error: base operand of '->' is not a pointer
src/main.cpp:384:6: error: overloaded function with no contextual type information
   min->set_disabled_by_default(false);
      ^
src/main.cpp:384:6: error: base operand of '->' is not a pointer
src/main.cpp:385:69: error: no matching function for call to 'esphome::binary_sensor::StateTrigger::StateTrigger(<unresolved overloaded function type>)'
   binary_sensor_statetrigger_2 = new binary_sensor::StateTrigger(min);
                                                                     ^
In file included from src/esphome.h:15:0,
                 from src/main.cpp:3:
src/esphome/components/binary_sensor/automation.h:124:12: note: candidate: esphome::binary_sensor::StateTrigger::StateTrigger(esphome::binary_sensor::BinarySensor*)
   explicit StateTrigger(BinarySensor *parent) {
            ^
src/esphome/components/binary_sensor/automation.h:124:12: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/esphome/components/binary_sensor/automation.h:122:7: note: candidate: constexpr esphome::binary_sensor::StateTrigger::StateTrigger(const esphome::binary_sensor::StateTrigger&)
 class StateTrigger : public Trigger<bool> {
       ^
src/esphome/components/binary_sensor/automation.h:122:7: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const esphome::binary_sensor::StateTrigger&'
src/esphome/components/binary_sensor/automation.h:122:7: note: candidate: constexpr esphome::binary_sensor::StateTrigger::StateTrigger(esphome::binary_sensor::StateTrigger&&)
src/esphome/components/binary_sensor/automation.h:122:7: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::StateTrigger&&'
src/main.cpp:387:95: error: no matching function for call to 'esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(<unresolved overloaded function type>, bool)'
   binary_sensor_binarysensorcondition_2 = new binary_sensor::BinarySensorCondition<>(min, true);
                                                                                               ^
In file included from src/esphome.h:15:0,
                 from src/main.cpp:3:
src/esphome/components/binary_sensor/automation.h:131:3: note: candidate: esphome::binary_sensor::BinarySensorCondition<Ts>::BinarySensorCondition(esphome::binary_sensor::BinarySensor*, bool) [with Ts = {}]
   BinarySensorCondition(BinarySensor *parent, bool state) : parent_(parent), state_(state) {}
   ^
src/esphome/components/binary_sensor/automation.h:131:3: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'esphome::binary_sensor::BinarySensor*'
src/esphome/components/binary_sensor/automation.h:129:32: note: candidate: constexpr esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(const esphome::binary_sensor::BinarySensorCondition<>&)
 template<typename... Ts> class BinarySensorCondition : public Condition<Ts...> {
                                ^
src/esphome/components/binary_sensor/automation.h:129:32: note:   candidate expects 1 argument, 2 provided
src/esphome/components/binary_sensor/automation.h:129:32: note: candidate: constexpr esphome::binary_sensor::BinarySensorCondition<>::BinarySensorCondition(esphome::binary_sensor::BinarySensorCondition<>&&)
src/esphome/components/binary_sensor/automation.h:129:32: note:   candidate expects 1 argument, 2 provided
src/main.cpp:812:6: error: overloaded function with no contextual type information
   max->set_component_source("template.binary_sensor");
      ^
src/main.cpp:812:6: error: base operand of '->' is not a pointer
src/main.cpp:813:29: error: no matching function for call to 'esphome::Application::register_component(<unresolved overloaded function type>)'
   App.register_component(max);
                             ^
In file included from src/esphome/components/api/api_connection.h:4:0,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h:122:24: note: candidate: template<class C> C* esphome::Application::register_component(C*)
   template<class C> C *register_component(C *c) {
                        ^
src/esphome/core/application.h:122:24: note:   template argument deduction/substitution failed:
src/main.cpp:813:29: note:   couldn't deduce template parameter 'C'
   App.register_component(max);
                             ^
src/main.cpp:818:6: error: overloaded function with no contextual type information
   min->set_component_source("template.binary_sensor");
      ^
src/main.cpp:818:6: error: base operand of '->' is not a pointer
src/main.cpp:819:29: error: no matching function for call to 'esphome::Application::register_component(<unresolved overloaded function type>)'
   App.register_component(min);
                             ^
In file included from src/esphome/components/api/api_connection.h:4:0,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h:122:24: note: candidate: template<class C> C* esphome::Application::register_component(C*)
   template<class C> C *register_component(C *c) {
                        ^
src/esphome/core/application.h:122:24: note:   template argument deduction/substitution failed:
src/main.cpp:819:29: note:   couldn't deduce template parameter 'C'
   App.register_component(min);
                             ^
/config/esphome/meteo.yaml:72:6: error: overloaded function with no contextual type information
     name: max
      ^
/config/esphome/meteo.yaml:72:6: error: base operand of '->' is not a pointer
/config/esphome/meteo.yaml:81:6: error: overloaded function with no contextual type information
       if:
      ^
/config/esphome/meteo.yaml:81:6: error: base operand of '->' is not a pointer
*** [/data/meteo/.pioenvs/meteo/src/main.cpp.o] Error 1
========================== [FAILED] Took 6.62 seconds ==========================

you are compiling it on the rpi4?

You can discuss the error in esphome discord channel

No. Now I have a NUC
Okay. Oh post. Thank you

The problem was in the variable names. Replace max with maxs and min with mins as if max and min were reserved words.

1 Like

This is to declare variables inside the esphome?

globals:
  - id: temp_max
    type: float
    restore_value: yes
    initial_value: '28.5'
  - id: temp_min
    type: float
    restore_value: yes
    initial_value: '28.3'

I don’t understand why this is

number:
  - platform: template
    name: "Set max temp"
    id: temp_max_set
    optimistic: true
    min_value: 28.0
    max_value: 29.0
    step: 0.1
    on_value:
      - globals.set:
          id: temp_max
          value: !lambda 'return id(temp_max_set).state;'
  - platform: template
    name: "Set min temp"
    id: temp_min_set
    optimistic: true
    min_value: 28.0
    max_value: 29.0
    step: 0.1
    on_value:
      - globals.set:
          id: temp_min
          value: !lambda 'return id(temp_min_set).state;'

I don’t understand why this is

binary_sensor:
  - platform: template
    name: maxs
    id: maxs
    lambda: |-
      if (id(temp).state >= id(temp_max)) {
        return true;
      } else {
        return false;
      }
    on_state:
      if:
        condition:
          for:
            time: 5min
            condition:
              binary_sensor.is_on: maxs
        then:
          - switch.turn_off: relay_2
          - switch.turn_off: relay_3
          
  - platform: template
    id: mins
    name: mins
    lambda: |-
      if (id(temp).state <= id(temp_min)) {
        return true;
      } else {
        return false;
      }
    on_state:
      if:
        condition:
          for:
            time: 5min
            condition:
              binary_sensor.is_on: mins
        then:
          - switch.turn_on: relay_2
          - switch.turn_on: relay_3          

This happens to HA the sensor values?

sensor:
  - platform: dallas
    address: 0x630516b54fc2ff28
    name: "Temperatura Sump"
    id: temp
    filters:
      - offset: 1.0

Help me understand this code well. In HA I want to be able to save the minimum and maximum values ​​and have these passed to esphome so that it can work with those values. From what I see globals serves to have those values ​​by default but not those of HA that is good in case you do not have communication with HA. There are a couple of things that I marked in the code that I don’t fully understand. If someone explains it to me, I will be able to do other things that I have pending. Thank you all very much for the help of this post.

Globals store the last value. On boot or if there is a power failure there is a better chance of retaining the last value set.

It also lets you set a default value should the last state be lost due to a restart.

This creates a slider that will allow you to adjust the max and min temperature.

When the temperature reaches the set point it turns on. Once it turns on, it starts a timer. That timer checks that it is on for 5 minutes then triggers the action.

I’m not sure what your question is.

Bad translation in my last text. I understood everything you explained to me. I am really grateful for the help everyone gave me. Thank you

1 Like

Hello friends. Automation is not working. Last night I saw that the high temperature did not cut and today when I looked it was 26 degrees and relays 2 and 3 were off. Is there a way I can debug to see why it doesn’t worng

Is this ok or is temp_max id missing the .state?

if (id(temp).state >= id(temp_max)) {

Globals do not use state. Go to the esp integration for this node and click log. Pull out the dallas and use a cup of hot and cold water to manipulate the temp. You may need to turn the debug level up.

After a good time of use I can tell you that the temperature control works very well. The only problem I found is that the binary variables when I modify them in HA do not change in esphome. If I select a maximum temperature in HA, it continues to turn off the switch at 28.5 degrees that are configured in the global variables. What is this about?

Have you tried looking at the esphome log? Start the log, on the addon page. You may need to adjust adjust the log level.

No. But I’m going to add it to see what happens. Thank you