Speed control device

Posted on
Wed Jan 18, 2017 11:25 am
mfriedel offline
Posts: 4
Joined: Oct 27, 2016

Speed control device

I am trying to write plugin with a speed control device. (indigo 7)
Try as I might, am am not able to get it to have either a slider for speed (0-100) or more than 4 speed indexes.
The documentation is a little confusing as well.

    Property Type Writable Description
    onState boolean No indicates whether the device is on - shortcut to dev.states['onOffState']
    speedIndex integer No indicates the current speed index for devices that support some fixed # of speeds - shortcut to dev.states['speedIndex']
    speedIndexCount boolean No indicates the number of indexes available for this device
    speedLevel boolean No indicates the level the device is set to (0-100) - shortcut to dev.states['speedLevel']


It says the speedLevel is a boolean.. and then it says it should be 0-100 :?
May I suggest a better naming for the class properties, more in the line with the dimmer devices ?
SupportsSpeedLevel


Anyway, I would be greatful for a hint how to do this.. for now I just made it a dimmer device...
P.S. This is to control a pump motor with variable speed.

Devices.xml

Code: Select all
 <Device type="speedcontrol" id="speed0" address="300">
        <Name>Motor Speed 1</Name>
        <ConfigUI>
        <Field id="address" type="textfield" defaultValue="300" readonly="true">
            <Label>Module Address:</Label>
        </Field>
        </ConfigUI>
        <UiDisplayStateId>speedLevel</UiDisplayStateId>
    </Device>


And plugin.py

Code: Select all

    def deviceStartComm(self, dev):
           self.debugLog(u"deviceStartComm: %s (%s)" % (dev.name, dev.deviceTypeId))
           props = dev.pluginProps
            props["onState"]    = False    # Wether the device is on - shortcut to dev.states['onOffState'
            props["speedLevel"] = 100      # Level the device is set to (0-100) - shortcut to dev.states['speedLevel']
            props["speedIndex"] = 0               # Current speed index for devices that support some fixed # of dev.states['speedIndex']
            props["speedIndexCount"]  = 11 # number of indexes available for this device

         
             dev.replacePluginPropsOnServer(props)

Posted on
Wed Jan 18, 2017 12:58 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Speed control device

SpeedControl devices are meant for ceiling fan type devices which have a limited number of speeds available. For a 0-100 type device, dimmer is your best base class.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Jan 18, 2017 4:34 pm
mfriedel offline
Posts: 4
Joined: Oct 27, 2016

Re: Speed control device

Thanks, that is what I am using (dimmer) , but I would like to be able to use a set amount of speeds, and more than the 4 that seem to be the default.
The question is more on how it can be done, since the docs say it is possible

Posted on
Thu Jan 19, 2017 8:24 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Speed control device

speedIndexCount (which should be documented as an integer not boolean) is currently a read-only property for the speed control device. It is always 4 (0 = off, 3 = highest speed). On our API request list is to further finish out the speed control device to allow for an arbitrary number of discrete speed values.

As a side note, the technique your code snippet of using dev.replacePluginPropsOnServer isn't correct. To change a device state value (onOffState, speedIndex, or speedLevel) you have to use dev.updateStateOnServer. The only one of the four in your example that replacePluginPropsOnServer would work for is speedIndexCount since it is the only one that isn't a state.... but it won't work for that one since it is currently read-only. :?

Image

Posted on
Thu Jan 19, 2017 7:36 pm
mfriedel offline
Posts: 4
Joined: Oct 27, 2016

Re: Speed control device

Thank you very much. I am still learning.

Just to make sure I get the concept correctly

dev.replacePluginPropsOnServer(props)

is to change the class properties and the

dev.updateStateOnServer

to change the device state. Correct ?

I was trying to fix/set the class properties without a configUI.

Posted on
Mon Jan 23, 2017 9:32 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Speed control device

That is correct. If you haven't already then check out the Indigo SDK download. It includes several documented examples of plugin devices. The thermostat is a good example as it includes calls to both replacePluginPropsOnServer and updateStateOnServer.

Image

Posted on
Wed Sep 02, 2020 6:29 am
dclonts offline
Posts: 49
Joined: Nov 05, 2006

Re: Speed control device

Any way to change the 4 to 6? can I do it by updating the pluginProps?

Speedcontrol is better than dimmer for my purposes--have a six speed and that includes reverse.

David Clonts

Posted on
Wed Sep 02, 2020 7:49 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Speed control device

dclonts wrote:
Any way to change the 4 to 6? can I do it by updating the pluginProps?


No and No. The native Indigo device only supports 4 (off/low/medium/high).

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests