Integrate with OpenSprinkler

Hi all, newbie here :wave:ā€¦Iā€™m looking to replace my old-school dumb controller with a smart controllerā€¦I think Iā€™m leaning towards opensprinklerā€¦altho Iā€™m somewhat worried about how wife-friendly it will be. Once itā€™s all set up can it feed through to HomeKit in a nice usable way? Can you refer to the zones by nameā€¦like ā€œhey Siri, turn on the sprinklers in the back yardā€ or, say, adhoc timed watering like ā€œhey Siri, water the flower beds for 7 minutesā€?

Thx :slight_smile:

EDIT:
Oh my God, all this is in the examplesā€¦

Questions on setting up manual zone operations. Iā€™m trying to do the following. I can get it to work by hard coding an integer value for run_seconds but Iā€™d rather use an input_number slider for versatility. Two questions:

  1. How can I have the input_number slider be in minutes and convert it into seconds for the service?
  2. How do I pass the input_number slider value as an argument into the opensprinkler.run service? Iā€™ve tried:
service_data:
  entity_id: sensor.front_1_4_n_station_status
  run_seconds: '{{ states(''input_number.front_1_4_n_timer'') | int }}'

but it throws Failed to call service opensprinkler/run. expected a list for dictionary value @ data['run_seconds']

and

service_data_tempalte:
  entity_id: sensor.front_1_4_n_station_status
  run_seconds: '{{ states(''input_number.front_1_4_n_timer'') | int }}'

but it throws Failed to call service opensprinkler/run. must contain at least one of entity_id, area_id.

My card:
image

entities:
  - action_name: Run zone
    icon: 'mdi:sprinkler'
    name: Front 1/4 (N)
    service: opensprinkler.run
    service_data:
      entity_id: sensor.front_1_4_n_station_status
      run_seconds:
        - input_number.front_1_4_n_timer
    type: call-service
  - entity: input_number.front_1_4_n_timer
title: Run Once Program
type: entities

I could only get it working with input_number by converting it to a float then and int, take a look at a README on https://github.com/vinteo/hass-opensprinkler, there is an example there.

Your second example has a typo, service_data_tempalte -> service_data_template

MQTT has now been integrated on opensprinkler.

1 Like

I tried the second option and only have the sensor entities in HA. How can I get also the switch entities?

Update to the latest version 1.0.x with at least 0.110 of HA and it has multiple device support.

Please read the upgrade info in the README.

It works perfectly now. Thanks!

Helloā€¦ I canā€™t figure out how to manually run my zones. Iā€™ve been stuck for days !
Running latest OpenSprinkler (the one that supports MQTT) with the latest integration installed from HACS.

I keep getting this error when clicking the Run Zone link :

Failed to call service opensprinkler/run. expected int @ data[ā€˜run_secondsā€™][0]

Here is my card :

and my code :

entities:
  - entity: switch.s01_station_enabled
  - entity: binary_sensor.s01_station_running
  - entity: sensor.s01_station_status
  - entity: input_number.runtime_zone1
    name: Runtime
    type: 'custom:slider-entity-row'
  - action_name: Run zone
    icon: 'mdi:sprinkler'
    name: Zone 1
    service: opensprinkler.run
    service_data:
      entity_id: switch.s01_station_enabled
      run_seconds:
        - '{{ ((states("input_number.runtime_zone1") | float) * 60) | int }}'
    type: call-service
title: Zone 1
type: entities

Any help would be greatly appreciated !

Thanks

When targeting a single station the run_seconds should be a single integer so change:

run_seconds:
  - '{{ ((states("input_number.runtime_zone1") | float) * 60) | int }}'

to

run_seconds: '{{ ((states("input_number.runtime_zone1") | float) * 60) | int }}'

Thanks.
I now get a slightly different error but one that I have seen before in my many different prior attempts.

Failed to call service opensprinkler/run. expected a list for dictionary value @ data['run_seconds']

I think it has to do with the single quotes. I know the formula return the right value and if I just plug a hard coded number there, it works.

But when I remove the single quotes and save, I get this error :

Failed to call service opensprinkler/run. Run seconds should be an integer value for station

and when I go back in my code, the line has been replaced by :

'[object Object]': null

Try switch the quotes around so:

run_seconds: "{{ ((states('input_number.runtime_zone1') | float) * 60) | int }}"

Same thing.
I get this error :

Failed to call service opensprinkler/run. expected a list for dictionary value @ data['run_seconds']

and why I go back to edit my code, it was replaced with this :

run_seconds: '{{ ((states(''input_number.runtime_zone1'') | float) * 60) | int }}'

I read something about creating a sensor ? Or a template ? Not sure whichā€¦

I just realised you are doing it in the lovelace ui, I donā€™t think that supports templates. So you need to create a script and call that.

Go to Configuration -> Scripts to add a new script. For the sequence edit as YAML (select ā€œEdit as YAMLā€ from the ā€¦ dropdown) and add:

data_template:
  run_seconds: "{{ ((states('input_number.runtime_zone1') | float) * 60) | int }}"
entity_id: switch.s01_station_enabled
service: opensprinkler.run

then your UI config should be (assuming you named your script ā€œRun Zone 1ā€):

...
- action_name: Run zone
  icon: 'mdi:sprinkler'
  name: Zone 1
  entity: script.run_zone_1
1 Like

Wow ! Thanks so much ! Itā€™s finally working !!

How should I implement something along the lines of your last example on your github ?
i.e. if not running and I click the link, run the zoneā€¦ if running, then turn it off.

Iā€™m not sure where the if condition should be ? the lovelace card, the script itself ? In your github you mention a switch ?

Thanks

WOW! I was juste looking at opensprinkler today. Im happy that its working with HA.

Im going to order one tomorrow :slight_smile:

I donā€™t think you can add those in the UI yet, you will need to add the examples in the configuration.yaml file in your config folder and restart HA

What firmware version do you have running on your OpenSprinkler ?

Everything works A1 now. Many thanks @vinteo

I have the MQTT feature and hereā€™s what Iā€™m running :
App Version: 2.2.0
Firmware: 2.1.9 (4)
Hardware Version: OSPi