Looks like the relevant section is around line 540:
- Code: Select all
elif id in self.fans:
fan = self.fans[id]
if level == '0.00':
fan.updateStateOnServer("onOffState", False)
else:
fan.updateStateOnServer("onOffState", True)
if level == '25.10':
fan.updateStateOnServer("speedIndex", 1)
elif level == '50.20':
fan.updateStateOnServer("speedIndex", 2)
elif level == '75.30':
fan.updateStateOnServer("speedIndex", 2)
else:
fan.updateStateOnServer("speedIndex", 3)
indigo.server.log(u"Received: Fan " + fan.name + " speed set to " + str(level))
return
I think the issue is the very precise level checks being made. From what I've seen, the Lutron API returns somewhat random decimal points for dimmer brightness, etc. Perhaps they are encoding some information in there... anyway, looking at the integration protocol, the following % correspond to the following levels:
Levels:
0 =Off
1–25%=Low
26–50%=Medium
56–75%=Medium High
76–100%=High
So perhaps best to change the logic in the code to more like the following:
- Code: Select all
elif id in self.fans:
fan = self.fans[id]
if level == '0.00':
fan.updateStateOnServer("onOffState", False)
else:
fan.updateStateOnServer("onOffState", True)
if level <= 25:
fan.updateStateOnServer("speedIndex", 1)
elif level <= 50.:
fan.updateStateOnServer("speedIndex", 2)
elif level <= 75:
fan.updateStateOnServer("speedIndex", 2)
else:
fan.updateStateOnServer("speedIndex", 3)
indigo.server.log(u"Received: Fan " + fan.name + " speed set to " + str(level))
return
I guess we also have to make a judgment on how to map 4 fan speeds to 3, unless there is a way to customize the fan object type in Indigo to add an additional speed... But I'd be inclined to do it this way, mapping as follows, and basically ignoring the Medium High speed....
Indigo --> Lutron
Low -> Low
Med -> Medium
High -> High
EDIT:
Should probably also change this, around line 968:
- Code: Select all
if action.speedControlAction == indigo.kSpeedControlAction.SetSpeedIndex:
if dev.deviceTypeId == RA_FAN:
newSpeed = action.actionValue
fan = dev.pluginProps[PROP_FAN]
if newSpeed == 0:
self._sendCommand("#OUTPUT," + fan + ",1,0")
elif newSpeed == 1:
self._sendCommand("#OUTPUT," + fan + ",1,25.10")
elif newSpeed == 2:
self._sendCommand("#OUTPUT," + fan + ",1,75.30")
else:
self._sendCommand("#OUTPUT," + fan + ",1,100")
indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "set fan speed", newSpeed))
Medium should be set to 50%, not 75%, to be consistent,,, And I would probably not do the weird decimals, so newSpeed 1 -> 25, NewSpeed 2 -> 50...