Irrigation Hunter X-Core remote control using REM pin

Hi!

I have a Hunter X-Core irrigation controller (8 zones) and I wanted to integrate it into homeassistant for better control.
I had planned to add a relay to open the valves and bypass the controller (turned off) but I found out that there is a pin exposed for remote control.
I found this project and I want to build it using ESPHome.
https://www.loullingen.lu/projekte/Hunter/index.php?language=EN

Can anybody point me to the right direction?
One idea is to import the ardruino files and write the YAML for custom switches.
I have almost none programming knowledge so there might be an easier way to accomplish what I want that I don’t know about.

Thank you!

Have a read of this and see if you can make sense of it:

https://esphome.io/custom/custom_component.html

1 Like

This is where I started!

My first problem is that the ardruino files have no class but only void.
So I started from here
https://www.w3schools.com/cpp/cpp_classes.asp

but I think I need to start earlier!

I think I need to define a (or more) class.
The available functions are the following. I only need to operate through a switch HunterStop, HunterStart and HunterProgram. The rest is internal as I understand it.


void HunterStop(byte zone);

void HunterStart(byte zone, byte time);

void HunterProgram(byte num);

void HunterBitfield(vector <byte>& bits, byte pos, byte val, byte len);

void HunterWrite(vector<byte> buffer, bool extrabit);

void HunterLow(void);

void HunterHigh(void);


I have spent several hours with no result.
I don’t know anything about C++ so I will try to create custom switches in HomeAssistant.

Any idea how to import this API?

2 Commands
START
GET /api/start/zone/[ZONE-NUMBER]?time=[TIME-MINUTES]&result=[WEBHOOK]
STOP
GET /api/stop/zone/[ZONE-NUMBER]?result=[WEBHOOK]

Don’t use ESPHome for this HTTP: GET function.
Use Home Assistant rest_command: instead.
This goes in your configuration.yaml file.

rest_command:
  start_irrigation:
    url:'http://{{ target }}/api/start/zone/{{ zone_number}}?time={{ time_minutes }}&result={{ webhook }}
    method: 'GET'
    content_type: 'text/plain'
  stop_irrigation:
    url:'http://{{ target }}/api/stop/zone/{{ zone_number}}&result={{ webhook }}
    method: 'GET'
    content_type: 'text/plain'

Then you can use the service: item in your automations as

    service: rest_command.start_irrigation

You’ll need to use a service_template definition to pass the values for target , zone_number , and webhook.

  action:
  - service_template: rest_command.start_irrigation
  - data_template: 
    target: "192.168.1.123"
    zone_number: "3"
    time_minutes: "8" 
    webhook:  "http://i_dont_know/something/something_else"
1 Like

Thank you very much for your time.
I successfully found a similar solution two nights ago.

switch:
  - platform: template
    switches:
      hunterirrigation:
        friendly_name: "Irrigation On/Off"
        turn_on:
            -  service: rest_command.startzone
        turn_off:
            -  service: rest_command.stopzone
        icon_template: >-
               {% if is_state('switch.hunterirrigation', 'on') %}
               mdi:water-pump
               {% else %}
               mdi:water-pump-off
               {% endif %}

rest_command:
  startzone:
    url: "http://192.168.1.199/api/start/zone/{{ states('input_select.zonenumber') }}?time={{states('input_number.zone_' ~ states('input_select.zonenumber') ~ '_timer')}}"
  stopzone:
    url: "http://192.168.1.199/api/stop/zone/{{ states('input_select.zonenumber') }}"

And I use 2 helpers
input_select.zonenumber = Dropdown menu to select specific zone to water
input_number.zone_1 - 6_timer = Where I have 6 sliders to select time for each zone.

I think your approach is more clever but didn’t know how to send data through your service.

rest_command.start_irrigation

Anyway, it’s working and I learned some things about templates for next time :slight_smile:

My only problem with the above is the icon change because it errors with

Template loop detected while processing event:

I think I could either set a variable or add the change of the icon in the Automation I have set to “turn off” the irrigation only in HomeAssistant like a timer (as the interaction with the hunter controller is one-way).

- id: '1626945764401'
  alias: Irrigation timer
  description: ''
  trigger:
  - platform: state
    entity_id: switch.hunterirrigation
    from: 'off'
    to: 'on'
  condition: []
  action:
  - delay:
      hours: 0
      minutes: '{{ states(''input_number.zone_'' ~ states(''input_select.zonenumber'')
        ~ ''_timer'') | int }}'
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    target:
      entity_id: switch.hunterirrigation
  mode: single