How to work with indigo.sprinkler zoneCount property

Posted on
Mon Apr 27, 2020 3:30 pm
Idurz offline
Posts: 5
Joined: Sep 01, 2015

How to work with indigo.sprinkler zoneCount property

Team

I am working on my second plugin. This will work with the sprinkler device to have a weather-dependant system based on default on/off devices for the valves. I have a workable version but cannot understand some of the properties of the indigo.sprinkler class. Take dev.zoneCount as an example. It defaults to 8, but here I want to work with 3 zones Trying
Code: Select all
dev.zoneCount = 3

throws AttributeError: the attribute "zoneCount" is read-only on this instance

Trying
Code: Select all
localPropsCopy = dev.pluginProps
localPropsCopy['zoneCount'] = 3
dev.replacePluginPropsOnServer(localPropsCopy)

seems to work OK. Checking the device, I see that the ownerProps have changed. But reading the zoneCount
Code: Select all
print (dev.zoneCount)

still shows 8 to me, which is the default value.

What am I missing here. Looking at the device documentation or the Rachio examples brought me to the above trials but did not give me the wanted answer.
Can you guide me please how I can update these properties like zoneCount, zoneNames etc?

Thanks Rudi

Posted on
Mon Apr 27, 2020 3:46 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: How to work with indigo.sprinkler zoneCount property

Hi Rudi,

Take a look at the Indigo SDK Plugins available here. There is an Example Sprinkler plugin that is fairly well commented. The Devices.xml explains the properties in a bit more detail:
Code: Select all
         <!-- By default sprinkler type devices automatically inherit these
         device properties which describe the characteristics of a specific
         sprinkler instance:

            NumZones         (integer)   UI currently supports up to 16 zones.
            ZoneNames         (string)   optional comma delimited list of names.
            MaxZoneDurations   (string)   optional comma delimited list of maximum zone durations.
            PumpControlOn      (bool)      True if the last zone really controls a pump.

         Plugins can update these properties either in device ConfigUI
         (like below), or can update them from python by using the
         dev.replacePluginPropsOnServer() method, most likely inside your
         deviceStartComm method. Both will trigger the Indigo Server to
         automatically rebuild the device's states list based on the needed
         changes.
         -->

So the answer in this case is to change the property NumZones which will then internally (and automatically) update the dev.zoneCount attribute. It would be nice if there was more consistency in the naming used. :roll:

Image

Posted on
Tue Apr 28, 2020 1:16 pm
Idurz offline
Posts: 5
Joined: Sep 01, 2015

Re: How to work with indigo.sprinkler zoneCount property

Hmmm so it was under my nose the whole week. 8)
I was looking at the examples but somewhere I got confused. I noticed the "ZoneNames" usage in the Device.xml and that was different from "zoneNames" in the device. So neglected that, thinking this was a plugin specific property and I really wanted the proper one....I did not read or understood the trick that Indigo takes care of that.

Thanks @Matt for your fast response. I tried again with your hints and it does the trick. "zoneCount" and "zoneNames" are updated as I wanted.

Downside is that this changes my way of thinking and will cause rework. Never mind, it will improve the plugin and we are stuck at home anyway.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest