jeroenvdwaal / underfloor_heating_pump_controller

Floor heating pump switch.
MIT License
14 stars 5 forks source link

Pump frequently switching on/off for 1 second for about an hour around 01:00 hrs every day #1

Open davidoff62 opened 2 years ago

davidoff62 commented 2 years ago

Seems like the anti-corrosion functions does something strange. At 0100 hrs the pump switches on and off every second for around an hour. It looks to me that something strange happens in the calculation if the anti corrosion should run or not....

Pompje

jeroenvdwaal commented 2 years ago

Hi @davidoff62, yes, thank you for the feedback. This got the same message from another user. And I don't know yet what is happening. This switching is not good for the pump, so don't use the switch for now. One way of dealing with this is to disable the corrosion run inside the ESP Home script until it is fixed.

You could help me out, finding the cause if you like. I could create an updated script with some additional logging. Let me know if you like help.

This is how it should look like:

image

davidoff62 commented 2 years ago

Hi @jeroenvdwaal ,

Altough my guess is that you are a Dutch native speaker (so am I), let's stick to English so the world can follow.

Of course i like to help, no doubt on that! I'm an electrical engineer, so software isn't really my thing (a.k.a. i'm learning), but uploading a modified script is well within my capabilities.

In the mean time some more info: i checked and crosschecked the availability of the NTP server server for the SonOFF (as my tought was that this could be of importance), this is the case.

In your screenshot it clearly shows a continued operation of the pump :) but not at around 01:00 hrs, is this also normal behavior? .... from the documentaion i understood that if the pump did not run in the last 24 hrs because of high water temp the pump will run for 10 min at 01:00 local time (hence the NTP service).

BR David

jeroenvdwaal commented 2 years ago

@davidoff62 Yes, you guessed right, I am a Dutch native speaker. And, yes, we should stick to English, so others can follow the discussion. I studied electrical engineering as well, but my career headed quite fast in the direction of software development. So I did a second study on software engineering. Both worlds are very interesting and are quite connected.

Nice that you like to cooperate! Let's see if we can fix the bug.

By the way, the problem you mention is reported earlier, see this conversation: https://community.home-assistant.io/t/diy-underfloor-heating-pump-controller-in-home-assistant/362954

Are you using the S20 or the S26?

In response to your remarks.

In the mean time some more info: i checked and crosschecked the availability of the NTP server server for the SonOFF (as my tought was that this could be of importance), this is the case.

I suspect something goes wrong with the timer (NTP section). In the discussion on the home assistant forum, Martin removed the entire section of the corrosion run and moved that to an HA automation. That fixed the problem. Personally, I like to have the section in, because it makes the solution 'stand-alone' and can operate without HA being online/available.

In your screenshot it clearly shows a continued operation of the pump :) but not at around 01:00 hrs, is this also normal behavior?

sensor_and_water_temperature

The pump runs when warm water enters. There is a very small spike at one o'clock, that's the corrosion cycle. And that's indeed why the NTP service is configured for.

Maybe the first test you can do is to remove or put in comments the section of the timer. See below. In this section, a timer is started for the duration of 60 seconds. And this will happen independently if the pump has been used during the daytime or not. I'll check the documentation to see for any errors. Is that something you can do and check for a day or so, what the behavior is of the system?

This section sets a global variable, called g_pump_demand_anti_corr to true for one minute and calls the controller to process if the pump should run or not. What maybe is wrong, is that this timer is started over and over again during one hour, instead of running only once.

  time:
  - platform: sntp
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller
          - delay: 60s
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller
davidoff62 commented 2 years ago

@jeroenvdwaal

I'm using the S26.

I adjusted the code as per your instructions, copy of commented out section see below. Let's see what we get tonight....

#time:
#  - platform: sntp
#    servers:  [172.16.10.1]
#    on_time:
#      # schedule anti corrosion action, once a day
#      - hours: 1
#        then:
#          - globals.set:
#              id: g_pump_demand_anti_corr
#              value: "true"
#          - script.execute: controller
#          - delay: 60s
#          - globals.set:
#              id: g_pump_demand_anti_corr
#              value: "false"
#          - script.execute: controller
davidoff62 commented 2 years ago

Thinking of this code; If the above is the issue, could the following be a solution?

time:
  - platform: sntp
    servers:  [172.16.10.1]
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller

      - hours: 1 minute: 2
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller
davidoff62 commented 2 years ago

Last night the pump did't freak out :) So i guess we can conclude the bug is in the above passage.

pompje

I tried to adjust the code myself, see below. What i've done is: create two timers, one @ 01:01 to switch the pump on, and one @ 01:02 to switch the pump off again. I've tried this code just now (with adjusted trigger times) and it worked perfectly.

time:
  - platform: sntp
    servers:  [172.16.10.1]
    on_time:
      # schedule anti corrosion action, switch on once a day
      - hours: 1
        minutes: 1
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller

      # schedule anti corrosion action, switch off once a day
      - hours: 1
        minutes: 2
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller
jeroenvdwaal commented 2 years ago

That's great to hear. Great that you changed the script successfully!! I'm curious if the servers: line is still needed, or does it work fine without? Could you check that?

  time:
  - platform: sntp
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        minutes: 0
        seconds: 0
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller
          - delay: 60s
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller

I had also a solution prepared, I am not sure if it will solve the problem as well.

davidoff62 commented 2 years ago

Just checked without the servers: line. The automation does not work without the line, best is to keep it in i guess.....

Like said: i'm not a software guy, can you therefore explain why in your revised code you use - before hour, minutes and seconds? i only use it at the first line of the time definition (conform the example: https://esphome.io/components/time.html

I feel confident now and i connected the pump. Tonight we'll (hopefully) see the code in action :)

jeroenvdwaal commented 2 years ago

If it isn't working without the servers: line in the code, I must be included in the script. But I don't feel very reliable. By default, the time component uses these three addresses:

3 NTP servers that are used for the clock source. Defaults to 0.pool.ntp.org, 1.pool.ntp.org and 2.pool.ntp.org

Somehow, these are not found in your environment. By hard coding the IP address, the host resolve step is skipped. For example, the 0.pool.ntp.org resolves to:

0.pool.ntp.org has address 5.200.6.34
0.pool.ntp.org has address 162.159.200.1
0.pool.ntp.org has address 40.119.148.38
0.pool.ntp.org has address 149.210.142.45

These DNS entries are mapped to specific IP addresses. The mapping may change over time. For example, 0.pool.ntp.org has address 5.200.6.34 could be mapped (e.g.) to 5.201.6.23. Using the DNS name, this change is not a problem for looking up the servers. If the servers use the hardcoded 5.200.6.34, it possible could go wrong. I am not sure why it is not working in your environment.

Like said: i'm not a software guy, can you therefore explain why in your revised code you use - before hour, minutes and seconds? i only use it at the first line of the time definition (conform the example: https://esphome.io/components/time.html

Sorry, made a mistake in my edit. The script in the post is updated, and now according to the documentation.

I think you are in good shape to give it a try!

jeroenvdwaal commented 2 years ago

I have one option in my sleeve to fix it in a more easy way. It is not important to run the anti-corrosion at one o'clock. A minute every 24 hours, approximately suffices. So instead of using the time section, I just create a loop, which just waits 24 hours and runs for a minute. Which could be any time of the day. Which is fine by this automation. What do you think about that approach?

interval:
  - interval: 24h
    # schedule anti corrosion action, once a day
    then:
      - logger.log: "Anti-corrosion run started"
      - globals.set:
          id: g_pump_demand_anti_corr
          value: "true"
      - script.execute: controller
      - delay: 60s
      - globals.set:
          id: g_pump_demand_anti_corr
          value: "false"
      - script.execute: controller
      - logger.log: "Anti-corrosion run finished" 

I tried the above script. It does work and removes the timer component completely. The only drawback is that the anti-corrosion run will not take place at one o'clock, but at intervals of 24 hours (approximately).

davidoff62 commented 2 years ago

@jeroenvdwaal Hi Jeroen,

Thanks for the addition! i guess we have two flafours now;

1: you latest version making sure the pump runs at least once every 24hrs on a undifined time and does not need a NTP server. 2: my version that runs on a pre-defined time, but does need a reachable NTP server.

As a response to your latest remark: I do run my own NTP server within my IoT network segment. In this way hosts in this network can be (and are!) separated from the internet, but still have access to a NTP server. That's the reason you only see a local IP in my code. I would like to run the pump at a pre defined time because my pump makes noise (and thus i run it at 10:00, not disburbing my sleep). Im my use case, i'll stick to flavour 2.......in other cases flavour 1 might be more practical!

jeroenvdwaal commented 2 years ago

Hi @davidoff62,

I am sorry for my late response. I posted something earlier, but I think didn't hit the submit button. It's nice to know that there is a preference for running it at a specific point in time. Thanks for the valuable feedback. I have only one question to ask.

  time:
  - platform: sntp
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        minutes: 0
        seconds: 0
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller
          - delay: 60s
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller

Did you test the script above? Do the minute and second entries solve the issue?

davidoff62 commented 2 years ago

Hi Jeroen,

Been busy lately so dind't had time to check. I was busy fixing my homeassistant installation since the ssd crashed :P ....i'll start this weekend with the pump controller again. When i get ESPhome running again, i give the code a go.....

jeroenvdwaal commented 2 years ago

Thanks!

Op vr 11 mrt. 2022 22:30 schreef davidoff62 @.***>:

Hi Jeroen,

Been busy lately so dind't had time to check. I was busy fixing my homeassistant installation since the ssd crashed :P ....i'll start this weekend with the pump controller again. When i get ESPhome running again, i give the code a go.....

— Reply to this email directly, view it on GitHub https://github.com/jeroenvdwaal/underfloor_heating_pump_controller/issues/1#issuecomment-1065544981, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMUMBQHRJBSDWXHL2E6ZYDU7O3OBANCNFSM5NOUIE3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: <jeroenvdwaal/underfloor_heating_pump_controller/issues/1/1065544981@ github.com>

EddyK69 commented 1 year ago

Hi @davidoff62,

I am sorry for my late response. I posted something earlier, but I think didn't hit the submit button. It's nice to know that there is a preference for running it at a specific point in time. Thanks for the valuable feedback. I have only one question to ask.

  time:
  - platform: sntp
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        minutes: 0
        seconds: 0
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller
          - delay: 60s
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller

Did you test the script above? Do the minute and second entries solve the issue?

Yes, the minutes & seconds addition fixes the issue

ricovangenugten commented 7 months ago

Hi @davidoff62, I am sorry for my late response. I posted something earlier, but I think didn't hit the submit button. It's nice to know that there is a preference for running it at a specific point in time. Thanks for the valuable feedback. I have only one question to ask.

  time:
  - platform: sntp
    on_time:
      # schedule anti corrosion action, once a day
      - hours: 1
        minutes: 0
        seconds: 0
        then:
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "true"
          - script.execute: controller
          - delay: 60s
          - globals.set:
              id: g_pump_demand_anti_corr
              value: "false"
          - script.execute: controller

Did you test the script above? Do the minute and second entries solve the issue?

Yes, the minutes & seconds addition fixes the issue

A bit late to the party, but I can confirm I also don't have the issue with the minutes and seconds specified.