Integrate with OpenSprinkler

Hello

Has anybody successfully integrated HASS with OpenSprinkler?

https://opensprinkler.com/

Thanks

I would also be very interested to know if somebody integrated opensprinkler into HA

Got my Opensprinkler today, made some tests to try HASS integration with the following result:

  • REST switch was not properly working, every 20 to 30 sec valves where switched on for 5sec??
  • command line switch works nicely with the REST API of Opensprinkler, see example below:
switch 20:
  - platform: command_line
    switches:
      salat:
        command_on: '/usr/bin/curl -X GET "http://192.168.0.22/cm?pw=xxx&sid=0&en=1&t=15"'
        command_off: '/usr/bin/curl -X GET "http://192.168.0.22/cm?pw=xxx&sid=0&en=0"'
        friendly_name: Salat
switch 21:
  - platform: command_line
    switches:
      tomaten:
        command_on: '/usr/bin/curl -X GET "http://192.168.0.22/cm?pw=xxx&sid=1&en=1&t=15"'
        command_off: '/usr/bin/curl -X GET "http://192.168.0.22/cm?pw=xxx&sid=1&en=0"'
        friendly_name: Tomaten

So at least a manual trigger from HASS is possible!

:wink:

…and with a REST sensor you can monitor the valve status (time delay of approx 15 secs, but works fine):

? "sensor 60"
: 
  name: "Opensprinkler V1"
  platform: rest
  resource: http://192.168.0.22/js?pw=xxx
  value_template: "{{ value_json.sn[0] }}"
? "sensor 61"
: 
  name: "Opensprinkler V2"
  platform: rest
  resource: http://192.168.0.22/js?pw=xxx
  value_template: "{{ value_json.sn[1] }}"

thanks Joe - this worked for me as well!

…and played arround with a bit of automations and input_sliders to manually run sprinklers for some minutes (via input_slider):

input_slider:

input_slider:
  target_timer_salat:
    name: Minuten Salat
    min: 5
    max: 60
    step: 1
    initial: 15
    unit_of_measurement: step
    icon: mdi:target
  target_timer_tomaten:
    name: Minuten Tomaten
    min: 5
    max: 60
    step: 1
    initial: 15
    unit_of_measurement: step
    icon: mdi:target

automation:

  - alias: Opensprinkler V1 Timer
    trigger: 
      platform: state
      entity_id: switch.salat
      state: 'on'
    action:
      - delay: '00:{{ states.input_slider.target_timer_salat.state | int }}:00'
      - service: homeassistant.turn_off
        entity_id: switch.salat
  - alias: Opensprinkler V2 Timer
    trigger: 
      platform: state
      entity_id: switch.tomaten
      state: 'on'
    action:
      - delay: '00:{{ states.input_slider.target_timer_tomaten.state | int }}:00'
      - service: homeassistant.turn_off
        entity_id: switch.tomaten

My OpenSprinkler is coming soon so maybe I could help with a platform for it in HA if that would interest anyone.

1 Like

that would be great if this becomes a standard component. Just fyi…the password needs to be in MD5 Hash format…use an online tool to convert your opensprinkler password to this format.

I found this earlier and it looks like it’s got a bunch of functionality built in.

I got my OpenSprinkler installed and have it manually triggering a zone via an Amazon Dash button.

hi @joe , thanks for the code, i have aquestion for you. if i have 4 or 5 valve how can i have the status for each valve as and individual sensor that return me the info that a valve is open or not, and also how can i know what valve is open?
now i am using this code:
- platform: rest
name: opensprinkler
resource: http://192.168.0.0:0/sn/js?pw=xxx
value_template: “{{ value_json.sn[0] }}”

i use the “sn” code before the “/js?pw=xxx” becouse by the official api info it would return me the state of the valve.
am i wrong?
thanks

i will post here if someone had my problem. from the 2.1.3 firmware the password is changed.
now you have to write the password in md5 hash.

hi @nebbiadigiorno,

it´s easy to get the status of induvidual valves, use value_templates like shown below:

valve 1 is value_template: “{{ value_json.sn[0] }}”

valve 2 is value_template: “{{ value_json.sn[1] }}”

valve 3 is value_template: “{{ value_json.sn[2] }}”

and so on…

and this rest command requests the status of all valves:

resource: http://192.168.0.22/js?pw=xxx

try this in your browser: “http://192.168.0.0/js?pw=xxx” (use your opensprikler IP and your hashed password)

kr josef

This is awesome! Thank you very much, Finally, my plants are talking to my irrigation system and getting themselves watered!

@uiguy,

What kind of hardware are you using to make your plants talk with Hass?

Kr
J

Hi,

I am using this HA component https://home-assistant.io/components/sensor.miflora/

Very happy with the sensors, ÂŁ8 from ebay: available here: http://www.ebay.co.uk/itm/Xiaomi-Mi-Plant-Flower-Test-for-pH-Soil-Moisture-Humidity-Temperature-Light/201948414464?_trkparms=aid%3D222007%26algo%3DSIM.MBE%26ao%3D2%26asc%3D20140122125356%26meid%3Ddca8991811564304a61679a05071485c%26pid%3D100005%26rk%3D4%26rkt%3D6%26sd%3D142455488465&_trksid=p2047675.c100005.m1851

Thank you very much, will give it a try!
kr
j

Hi,

Just FYI, with the latest release “state” trigger has a breaking change.

This should therefore be changed as follows:

  - alias: Opensprinkler V1 Timer
    trigger: 
      platform: state
      entity_id: switch.salat
      state: 'on'

Should be

  - alias: Opensprinkler V1 Timer
    trigger: 
      platform: state
      entity_id: switch.salat
      to: 'on'

Otherwise, thanks again for an awesome integration

having some trouble with current state and OpenSprinkler-

the following works for ON and OFF… even over Google Home… but current state is NOT working. this is for first station/valve on OpenSprinkler.
any tips?

switch 20:
  - platform: command_line
    switches:
      sprinkler_front:
        command_on: '/usr/bin/curl -X GET "hxxp://10.0.50.188/cm?pw=xxx&sid=0&en=1&t=120"'
        command_off: '/usr/bin/curl -X GET "hxxp://10.0.50.188/cm?pw=xxx&sid=0&en=0"'
        command_state: '/usr/bin/curl -X GET "hxxp://10.0.50.188/js?pw=xxx"'
        value_template: "{{ value_json.sn[0] }}"
        friendly_name: Front Sprinklers

The output from URL hxxp://10.0.50.188/js?pw=xxx … when station 1 is ON -
{“sn”:[1,0,0,0,0,0,0,1],“nstations”:8}

note -

  • the 8th station ON is master. ignore this as opensprinkler open and closes this valve automatically
  • also changed http to hxxp because new users cant post links :slight_smile:

EDIT, so i’ve gone with
value_template: '{{ value_json.sn[0] == 1 }}'

which seems to work :slight_smile: as mentioned above 10-15 second delay on polling. but good enough for automation etc

Hi UIGuy

Just wanted to check how you got on integrating the Mi Flora sensor with Home Assistant, and then using home automation rules to control Open Sprinkler via REST calls?

I’m looking at doing exactly the same thing with the Open Sprinkler Bee model (3 zones) which is based on the ESP8266 module.

Any advice integrating Home Assistant with Open Sprinkler?

Regards
Craig

HI, How far along are you? Have you got the Sensors integrated? Have you got the Sprinklers integrated?