Integrate with OpenSprinkler

If you are using my component, update to the latest. Note there has been a domain name change so the configuration is different. There is also a known issue with the timers if you are not using hass.io, see the issues list for a workaround

Hi,

Sorry, ran the update on the custom component and still getting errors as below:

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'
2018-11-13 20:39:16 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of sensor.opensprinkler. Setup failed for dependencies: opensprinkler
2018-11-13 20:39:16 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.opensprinkler: Could not set up all dependencies.

That’s not my component, i changed all my files to hass_opensprinkler.py so it was not to be confused with @philmottin 's component.

You can try change the line from

load_platform(hass, 'scene', DOMAIN)

to

load_platform(hass, 'scene', DOMAIN, {}, config)

There may be multiple similar lines you have to change

Hey there, I’ve tried using this code (not in a package just in my config.yaml file) and I can’t seem to get the Input slider to work. The switch seems to fire correctly (in my case for 300 seconds).

When I change the input slider, nothing happens. Is it supposed to automatically start the specific station for the selected duration? If I change the input slider and then turn the switch on, it still fires for 300 seconds.

Any assistance would be appreciated! Thanks

My code is as follows:
sensor:
- platform: rest
name: “Opensprinkler”
resource: http://10.1.1.243/js?pw=XXXX
value_template: “{{ value_json.sn[0] }}”

switch:
  - platform: command_line
    switches:
        flower:
          command_on: '/usr/bin/curl -X GET "http://10.1.1.243/cm?pw=XXXX&sid=0&en=1&t=300"'
          command_off: '/usr/bin/curl -X GET "http://10.1.1.243/cm?pw=XXXX&sid=0&en=0"'
          command_state: '/usr/bin/curl -X GET "http://10.1.1.243/js?pw=XXXX&sid=0&en=0"'
          friendly_name: Flowers
          value_template: "{{ value_json.sn[0] == 1 }}"

input_number:
  sprinkler_timer_flower:
  name: Timer
  min: 0
  max: 20
  step: 1
  initial: 0
  unit_of_measurement: mins
  icon: mdi:timer
    
automation 7:
hide_entity: false
trigger:
  platform: state
  entity_id: switch.flower
  to: 'on'

action:
  - delay: '00:{{ states.input_number.sprinkler_timer_flower.state | int }}:00'
  - service: homeassistant.turn_off
    entity_id: switch.flower

There’s no “off” command per se, you need to use the timer you have in the “on” command where you have t=300 where 300 is the number of seconds.So replace the 300 with the timer multiple by 60 to get the number of seconds.

I don’t think there is any way of turning it off straight away as far as I know.

Edit: Sorry I was wrong, the problem maybe you should use switch.turn_off service in your action for your automation instead of homeassistant.turn_off

Thanks @vinteo, I don’t think I understand what the input slider is supposed to do - when I set it to say 7mins, nothing happens (i.e. the automation does not trigger to turn the sprinklers on)

BTW… I liked the look of your custom component but couldn’t get it working (The UI panels did not work) Hence reverted to the command_line

Looking at the package you quoted, what’s supposed to happen is you move the input slider to say 2 mins then turn the sprinkler on using the switch, and it should turn off after two minutes. so the input slider is only supposed set the time (up to 5 mins as you have set a limit of 5 mins with t=300), you still need to manually turn it on

Controls

Just wanted to say thanks for this plug in/add on.

I started using it a few months back and the update killed it but your update has fixed it once again. (I thought it was an issue my end until I pulled my finger out and researched the issue and ended up back here)

Keep up the great work mate and thanks again

Hi,

I have now swapped to your component, however I am still getting invalid config… herewith my log entries

The one main difference between yours and the other configuration entry was that I had to remove port from the config.yaml. I assume your component defaults to 8080?

Thanks for any help you are able to provide…

2018-11-30 15:24:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component hass_opensprinkler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f06df57c7f0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.36', port=80): Max retries exceeded with url: /jn?pw=bdcbfd1ba8f8b3301c2dfc94a2209f2a (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f06df57c7f0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/hass_opensprinkler.py", line 88, in stations
    response = requests.get(url, timeout=10)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.36', port=80): Max retries exceeded with url: /jn?pw=bdcbfd1ba8f8b3301c2dfc94a2209f2a (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f06df57c7f0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

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/hass_opensprinkler.py", line 49, in setup
    for station in opensprinkler.stations():
  File "/config/custom_components/hass_opensprinkler.py", line 90, in stations
    _LOGGER.error("No route to device '%s'", self._resource)
AttributeError: 'Opensprinkler' object has no attribute '_resource'

No it defaults to 80. What happens if you put 192.168.1.36 into the browser? the web UI is working fine? Maybe try restarting the opensprinkler device

Hi,

I changed the port to 80 from the default in Opensprinkler (8080) and it works now… Maybe add a config item to specify port? Otherwise, looks good and thanks for all your hard work on this!!

In your config put ‘192.168.1.36:8080’ as your host. That may work if it is not port 80.

Yea, can confirm, adding the default port (:8080) to the end of the IP address works. Thanks

Hi,

I have noticed that with your component the sensor names are not the same as the other, meaning that many of the previous groups, sliders etc are not working 100%…

Do you think you could post your supporting groups, sliders, automations .yaml files so that I can change these over to your config?

Thanks very much for your help

Hi,
I am using @vinteo addon and it is working perfectly, however I am seeing 3 component for each zone, a switch, binary sensor and a sensor. is this the normal behavior?

yes, that’s normal

Hey,

I found this tread … i think to late :smiley:

I make a OpenSprinkler integration with Node-RED and the API of OpenSprinkler

Lovelace - OpenSprinkler with HA and Node-RED

@vinteo
Hi,
I just installed the new .88 and there seems to be an issue. although all component shows in the frontend after fully loaded HA.

Feb 21 11:29:12 homeassistant hass[11454]: 2019-02-21 11:29:12 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.hass_opensprinkler.binary_sensor. Make sure all dependencies are installed
Feb 21 11:29:12 homeassistant hass[11454]: Traceback (most recent call last):
Feb 21 11:29:12 homeassistant hass[11454]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 147, in _load_file
Feb 21 11:29:12 homeassistant hass[11454]:     module = importlib.import_module(path)
Feb 21 11:29:12 homeassistant hass[11454]:   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
Feb 21 11:29:12 homeassistant hass[11454]:     return _bootstrap._gcd_import(name[level:], package, level)
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 986, in _gcd_import
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 969, in _find_and_load
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Feb 21 11:29:12 homeassistant hass[11454]: ImportError: No module named 'custom_components.hass_opensprinkler.binary_sensor'; 'custom_components.hass_opensprinkler' is not a package
Feb 21 11:29:12 homeassistant hass[11454]: 2019-02-21 11:29:12 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.hass_opensprinkler.sensor. Make sure all dependencies are installed
Feb 21 11:29:12 homeassistant hass[11454]: Traceback (most recent call last):
Feb 21 11:29:12 homeassistant hass[11454]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 147, in _load_file
Feb 21 11:29:12 homeassistant hass[11454]:     module = importlib.import_module(path)
Feb 21 11:29:12 homeassistant hass[11454]:   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
Feb 21 11:29:12 homeassistant hass[11454]:     return _bootstrap._gcd_import(name[level:], package, level)
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 986, in _gcd_import
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 969, in _find_and_load
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Feb 21 11:29:12 homeassistant hass[11454]: ImportError: No module named 'custom_components.hass_opensprinkler.sensor'; 'custom_components.hass_opensprinkler' is not a package
Feb 21 11:29:12 homeassistant hass[11454]: 2019-02-21 11:29:12 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.hass_opensprinkler.scene. Make sure all dependencies are installed
Feb 21 11:29:12 homeassistant hass[11454]: Traceback (most recent call last):
Feb 21 11:29:12 homeassistant hass[11454]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 147, in _load_file
Feb 21 11:29:12 homeassistant hass[11454]:     module = importlib.import_module(path)
Feb 21 11:29:12 homeassistant hass[11454]:   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
Feb 21 11:29:12 homeassistant hass[11454]:     return _bootstrap._gcd_import(name[level:], package, level)
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 986, in _gcd_import
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 969, in _find_and_load
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Feb 21 11:29:12 homeassistant hass[11454]: ImportError: No module named 'custom_components.hass_opensprinkler.scene'; 'custom_components.hass_opensprinkler' is not a package
Feb 21 11:29:12 homeassistant hass[11454]: 2019-02-21 11:29:12 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.hass_opensprinkler.switch. Make sure all dependencies are installed
Feb 21 11:29:12 homeassistant hass[11454]: Traceback (most recent call last):
Feb 21 11:29:12 homeassistant hass[11454]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 147, in _load_file
Feb 21 11:29:12 homeassistant hass[11454]:     module = importlib.import_module(path)
Feb 21 11:29:12 homeassistant hass[11454]:   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
Feb 21 11:29:12 homeassistant hass[11454]:     return _bootstrap._gcd_import(name[level:], package, level)
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 986, in _gcd_import
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 969, in _find_and_load
Feb 21 11:29:12 homeassistant hass[11454]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Feb 21 11:29:12 homeassistant hass[11454]: ImportError: No module named 'custom_components.hass_opensprinkler.switch'; 'custom_components.hass_opensprinkler' is not a package

I think the plugin will need an update as I get the following error

Log Details (WARNING)

Thu Feb 21 2019 19:34:31 GMT+1100 (Australian Eastern Daylight Time)

Integrations need to be in their own folder. Change binary_sensor/hass_opensprinkler.py to hass_opensprinkler/binary_sensor.py. This will stop working soon.

I have open a issue at https://github.com/vinteo/hass-opensprinkler/issues/16