Automation for Irrigation System with ESP Home

Hello everyone,

I’m still fairly new to the Home Assistant or ESP Home world. Nevertheless, I am currently desperately trying to set up an irrigation system for my plants. Admittedly, I’ve stuck to existing projects for the time being in order to get to grips with Home Assistant and learn how it works and the code structure.

This is designed so that I can use an input/select field in Home Assistant to select a predefined time period (18:15, 18:30, …) at which the system starts watering the respective zone.

Now I have the problem that the automation doesn’t work, but I don’t get any error codes either, so I think it could be because I’m probably comparing two different types. In the log the time is displayed as “has_time has sent ‘XX:XX’ ”. However, nothing happens at the time I set.

Does anyone have an idea or suggestion to nudge me in the right direction. My solution is probably very cumbersome anyway. Any help would be greatly appreciated!

These are the code snippets i am trying to compare:
1.

time:
  - platform: homeassistant
    id: hass_time
    timezone: Europe/Amsterdam

text_sensor:
  - platform: template
    id: has_time
    name: "has time"
    lambda: |-
      char float[6];
      time_t currTime = id(hass_time).now().timestamp;
      strftime(float, sizeof(float), "%H:%M", localtime(&currTime));
      return  { float };
    update_interval: 10s

and the code that should activate the automation:
2.

# Time automations
#

interval:
  - interval: 1sec
    then:
      - lambda: |-
          if (!id(automation_enabled).state) return;

          int current_day = id(hass_time).now().timestamp / 86400;
          if ((current_day - id(var_skip_start_day)) % ((int)id(skip_days).state + 1) != 0) return;

          if (id(zone1_enabled).state &&
            !id(irrigation_zone1).state &&
            id(id(has_time).state) == id(zone1_start).state)
              id(irrigation_zone1).turn_on();
          

Hi!

I did not checked your code but why not use the sprinkler component from ESPHome?

Hi,
first of all Thanks for your reply!
I am familiar with the site you mentioned, but I am currently trying to concentrate on a solution that suits me, as I am planning to integrate extensions such as a rain sensor etc. in the near future. I would therefore like to try to stick with my idea first. But I’ll keep the site in mind.

I have again written the two important points individually in the post, perhaps this will make it easier to understand where I think the problem should be.

VG