OpenSprinkler Forums Third-Party Software Using the OpenSprinkler API to schedule an ad-hoc program

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #50788

    timcharper
    Participant

    Hi!

    I developed the integration for OpenSprinkler and Homekit: https://www.npmjs.com/package/homebridge-opensprinkler . I’d like to make it so that if you manually enable multiple valves, in queues them up in sequence, rather than concurrently. Presently I’m using the manual program with an API call per valve. Apple Home doesn’t give you an option to turn on multiple valves in a single transaction so it needs to be done in sequence. Ideally, an interaction like this would be supported:

    1) User taps Turn on Valve 3 for 20 minutes
    2) Valve 3 turns on
    3) User taps Turn on Valve 2 for 20 minutes
    4) Valve 2 queues up to run after Valve 3 is done
    5) User taps Turn on Valve 1 for 15 minutes
    6) Valve 1 queues up after the last queued valve (valve 2)
    7) User cancels valve 2
    8) User queues up Valve 4 for 30 minutes
    9) Valve 4 queues up after valve 1

    Basically, what I think I need is the ability to schedule a run-once program, with custom durations and start times, and also to be able to modify the program without stopping the existing valve from running.

    If needed, I could do the scheduling in Homebridge plugin itself, instead, but this is a little less ideal as the user would not be able to cancel or see the program in the OpenSprinkler app. So if I can interact with the API and support the above interaction then that would be ideal.

    Advice?

    Thank you!

    #50872

    Samer
    Keymaster

    This is great work, thank you very much for your contribution!! I will try to get this installed soon to test it out 🙂

    #51015

    Ray
    Keymaster

    @timcharper: thanks for sharing your work. If your zones/stations are ‘sequential’ (which is so by default), then when you use the manual program API call, it automatically queues all the stations. Basically the scheduler makes sure the ‘sequential’ attributes are obeyed. What this means is that it you manually turn on zone 1, then zone 2, and so on, zone 2 will be pushed to the queued and will only run after zone 1 finishes.

    #51045

    timcharper
    Participant

    @Ray – This is not what I’m seeing. All valves are turning on simultaneously. I’m running firmware 2.1.6 with hardware version 2.3.

    Maybe I’m not using “manual program API call”? The URI I am using is “/cm?sid={n}&en=1&t={t}”.

    #51050

    timcharper
    Participant

    After updating the firmware, I’m still seeing them turn on in parallel:

    #51052

    timcharper
    Participant

    It looks like an API endpoint was added to manually trigger a program. That would work sufficiently, although it is a bit less natural to use from the Home app.

    #51178

    Ray
    Keymaster

    I checked the source code and I am pretty sure the /cm API observes sequential property of each zone:
    https://github.com/OpenSprinkler/OpenSprinkler-Firmware/blob/master/server.cpp#L1629
    as you can see, it calls the “schedule_all_stations” function, which is here:
    https://github.com/OpenSprinkler/OpenSprinkler-Firmware/blob/master/main.cpp#L1047
    and it definitely distinguishes between sequential and parallel. Are you sure your zones are all sequential? In any case, you are right that manually trigger a program run is now also part of the API.

    #52711

    sloth
    Participant

    This is awesome! Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Third-Party Software Using the OpenSprinkler API to schedule an ad-hoc program