Integrate with OpenSprinkler

Hi georgeloak,

Do you have any programs setup on opensprinkler? If not try creating one (you can disable it if you don’t want it to run). I think the component right now assumes there is at least one program created.

Yes, I do have programs but I just realized that my system may be running old firmware/software. So I’ve done a git pull and am trying to do some other updates but I ran into a little trouble now accessing the unit so let me sort this out and once it’s back up and running with all the latest code I’ll post again.

OK, I think I found the problem. Looks like a LONG time ago I installed this Dan-in-CA which was out well before the OpenSprinkler software. Seems like he has a different API. I’ve been using the mobile app (OpenSprinkler) for years without a problem.

Odd thing is I got a response before but now I have to use Dan’s format to get a response (which the password is in plain text, not MD5.

So I probably had older firmware and Dan’s code and now that I’ve updated both I’m broken so I’ll continue to search to see what I need to do.

I’ve finished my initial reconfiguration. I decided to buy a new RPi3 and I’ve used a different RPi for my verification while I wait for the new RPI to come in. I went ahead and installed Stretch as the OS and have everything upgraded to the latest (apt-get update, upgrade, and raspi-update) as of today. Once I installed OpenSprinkler and did a quick check (http://192.168.10.84:8080/jc?pw=xxXXxx) I see that I’m getting back more than the firmware version in the JSON response now (I’ve replaced some data with xxXXxx):

{"devt":1519930046,"nbrd":1,"en":1,"rd":1,"rs":0,"rdst":xxXXxx,"loc":"xxXXxx","wtkey":"xxXXxx","sunrise":xxXXxx,"sunset":xxXXxx,"eip":xxXXxx,"lwc":1519928465,"lswc":1519928465,"lupt":0,"lrun":[0,0,0,0],"sbits":[0,0],"ps":[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],"wto":{"d":72},"ifkey":"xxXXxx"}

I have the correct cards displayed now but I’m wondering how often this data is updated. When I first checked it I noticed that I had some old program names that could be changed so I did that through the OpenSprinkler interface but the old program names are still showing up.

You were right, it wasn’t working becuase of old opensprinkler api from old firmware.

It looks like the custom state cards are not loaded. Post the HA log and also the browser’s console log of the picture above.
It also helps if you post your config, if you can.

If you change the name of any program / station, you will have to restart HA. That’s because the component stores the data using the names as keys. I’ll note for a future update to use index instead of keys to solve this issue.

I got the new RPI3 in and everything is configured (except I lost my stations pictures for some reason but that’s an OpenSprinkler problem).

My page looks like this now:

I see this in the log:

2018-03-02 17:47:09 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\asyncio\events.py", line 145, in _run
    self._callback(*self._args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\asyncio\proactor_events.py", line 136, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
2018-03-02 17:47:09 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\asyncio\events.py", line 145, in _run
    self._callback(*self._args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\asyncio\proactor_events.py", line 136, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

Here’s what’s in my configuration.yaml has in it:

  customize_glob:
    light.*:
      custom_ui_state_card: state-card-custom-ui
      state_card_mode: break-slider
      stretch_slider: true
      hide_control: false
      theme: happy
      slider_theme:
        min: 10
        max: 100
        pin: true
        off_when_min: false
        report_when_not_changed: false
    "*.*":
      custom_ui_state_card: state-card-custom-ui

  # Customization file
  customize: !include customize.yaml

frontend:
  extra_html_url:
    - https://raw.githubusercontent.com/andrey-git/home-assistant-custom-ui/master/state-card-custom-ui.html
    - /local/custom_ui/state-card-opensprinkler-control-station.html
    - /local/custom_ui/state-card-opensprinkler-control-program.html
#    - \www\custom_ui\state-card-custom-ui.html
  extra_html_url_es5:
    - https://raw.githubusercontent.com/andrey-git/home-assistant-custom-ui/master/state-card-custom-ui-es5.html
    - /local/custom_ui/state-card-custom-ui-es5.html
#    - \www\custom_ui\state-card-custom-ui-es5.html

customizer:
  custom_ui: hosted

 # OpenSprinkler Pi
opensprinkler:
  host: 192.168.10.230 #Need to change to 230 when ready
  port: 8080
  password: !secret opensprinkler

# Needed for OpenSprinkler (for now)
input_text:
  scene_temp_var:
    initial: 'off:1'

I did just realize that I need to edit my groups since I don’t have a pump or stations 7 & 8

The custom state cards might not be working because of the file paths and Windows. Custom UI is something I just started messing with so it may not be configured correctly.

Great work on the component! I have more than one open sprinkler unit, will your component work with multiple open sprinkler units?

Hi, is there any movement towards getting one of these integrated as an official component in HA?

Would loive to see one

Thanks

1 Like

I’d like to support uiguy’s question/request.

Also, is this working with the “classic” opensprinkler only, or also with the OpenSprinklerBee and other iterations?

Thanks

1 Like

Hey guys, sorry but doing it as an official component is out of my depth with python ATM. I am happy for any one to use my code as a starting point to do it if it helps.

@pizero as long as the API is the same it should work.

Hi
Thanks for the work
Just installed from the github.
Everything seems ok from the gui point of view except that the 3 cards have the name
input number, switch and scene.
Names on the OS device are picked up correctly
Waht can it be due to?
tx

Hi all!, I am planning to buy an OpenSprinkler Bee 2.0 for my garden irrigation as it works with latching solenoids for 3 zones and thus, this seems to be the adequate model. Can anyone confirm that this integration is working fine with Opensprinkler Bee2??. I am asking because I am not sure if all OpenSprinkler versions are using the same APIs. Thank you very much, specially to @philmottin and @vinteo.

Hi again. I still don’t know if opensprinkler bee 2 can or cannot be used with HA. @craigcarps and @pizero , I’ve read you were planning to use an opensprinkler bee, did you manage to use it from home assistant?? Thanks!

Hi. No after reading on the opensprinkler forum that the bee is using a different API I did not look into this idea any further. Sorry.

Thank you anyway. I’ve just installed my opensprinkler bee 2 and it works great with latching valves for my garden.
I’ve been reading the opensprinkler bee API and it is well described and seems quite easy to access and change programs. I may come out with something for home assistant. I’ll let you know because I don’t have much time for this.

Hi Jolaca

I ended up buying the standard open sprinkler 3.0 which has integrated fantastically with Home Assistant using the rest endpoints.

Good to hear that you’ve had a pleasant experience with the opensprinkler bee as well

I am getting mad…
I keep getting this:

2018-07-24 00:16:33 ERROR (MainThread) [homeassistant.setup] Error during setup of component opensprinkler
Traceback (most recent call last):
File “/home/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py”, line 146, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/opensprinkler.py”, line 63, in setup
hass.data[DATA_OPENSPRINKLER].update()
File “/home/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 318, in wrapper
result = method(*args, **kwargs)
File “/home/homeassistant/.homeassistant/custom_components/opensprinkler.py”, line 130, in update
api_dict[‘data’] = parse_api_data(json.loads(response.text, object_pairs_hook=OrderedDict))
File “/home/homeassistant/.homeassistant/custom_components/opensprinkler.py”, line 249, in parse_api_data
programs = response[‘programs’][‘pd’]
KeyError: ‘programs’

OpenSprinkler version 2.1.5

So after removing all comments from opensprinkler.py in custom_components and looking at the log I have :slight_smile:
2018-07-24 22:24:06 WARNING (Thread-20) [custom_components.opensprinkler] response: {“result”:32}

So Opensprinkler API is responding “32” at the first call… not even the right number (hitchikers guide to galaxy whise)

HI,

I am suddenly getting invalid config for this custom component. Herewith the entry in my logs:

ERROR (MainThread) [homeassistant.setup] Error during setup of component opensprinkler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/opensprinkler.py", line 99, in setup
    load_platform(hass, 'scene', DOMAIN)
TypeError: load_platform() missing 2 required positional arguments: 'discovered' and 'hass_config'

Anyone else seeing this?

Yup - It started after I upgraded to 81.6