Plugin for Haiku Fan with SenseME

Posted on
Sun Feb 09, 2020 9:46 pm
mpleeds offline
Posts: 28
Joined: Jul 02, 2012

Re: Plugin for Haiku Fan with SenseME

One more thing, -- To increment fan light brightness, I have tried the following script:

fan_id = 11175177
bright_change = 1

senseMeID = "com.pennypacker.indigoplugin.senseme"
senseMePlugin = indigo.server.getPlugin(senseMeID)
office_fan = indigo.devices[fan_id].name

try:
current_fan_bright = int(indigo.devices[fan_id].states["brightness"])
except:
indigo.server.log("could not read the current fan brightness")
return

new_fan_bright = current_fan_bright + bright_change

if new_fan_bright > 7:
indigo.server.log("could not change the fan brightness beyond level 16")
return
elif new_fan_bright < 0:
indigo.server.log("could not change the fan brightness below level 0")
return

output_str = ""

if new_fan_bright > current_fan_bright:
output_str = "increasing "
else:
output_str = "decreasiong "

indigo.server.log(output_str + "'" + office_fan + "' brightness from " + str(current_fan_bright) + " to " + str(new_fan_bright))
senseMePlugin.executeAction("fanLightBrightness", deviceId=fan_id, props={'brightness':str(new_fan_bright)})

When I run this script, the event log reports:

Feb 9, 2020 at 7:38:04 PM
Script increasing 'Haiku Office Fan' brightness from 0 to 1
SenseME Fan Debug set brightness to None this:

I think there is a problem with the last line of script?

Posted on
Sun Feb 09, 2020 11:06 pm
kw123 offline
User avatar
Posts: 6823
Joined: May 12, 2013
Location: Dallas, TX

Plugin for Haiku Fan with SenseME

I believe you get a string as brightness from reading the state
You need an integer when you add

Also
It is better to post code as [ code ]
Then you can see the proper indents etc

Karl




Sent from my iPhone using Tapatalk
Last edited by kw123 on Mon Feb 10, 2020 8:02 am, edited 1 time in total.

Posted on
Mon Feb 10, 2020 7:55 am
vtmikel offline
Posts: 461
Joined: Aug 31, 2012
Location: Boston, MA

Re: Plugin for Haiku Fan with SenseME

The fan light can go from 0 to 16, so adjust the boundary check appropriately.

Then, try this (note that the parameter that the Plugin Action expects is called "lightLevel"):

Code: Select all
senseMePlugin.executeAction("fanLightBrightness", deviceId=fan_id, props={'lightLevel':str(new_fan_bright)})


Or, also try removing the str() on the new brightness level and passing the integer value:

Code: Select all
senseMePlugin.executeAction("fanLightBrightness", deviceId=fan_id, props={'lightLevel':new_fan_bright})

Posted on
Mon Feb 10, 2020 9:42 am
mpleeds offline
Posts: 28
Joined: Jul 02, 2012

Re: Plugin for Haiku Fan with SenseME

Yes, simply changing the parameter from "brightness" to "lightLevel" corrected the problem and it now functions with passing either the string or integer value.

For future reference, is there a resource available from within Indigo which provides access the correct parameter nomenclature for a given device or plugin?

For example:

fanLightBrighness/lightLevel
fanSpeed/speed

Thanks to both of you for helping sort this out.

Posted on
Mon Feb 10, 2020 9:44 am
vtmikel offline
Posts: 461
Joined: Aug 31, 2012
Location: Boston, MA

Re: Plugin for Haiku Fan with SenseME

In this case I looked at the ways to call the plugin's supported actions for setting the brightness and fan level. If you look at Actions.XML for the plugin, it has the method names and parameters. Glad it is working for you.

Who is online

Users browsing this forum: No registered users and 1 guest