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: 7038
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: 474
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: 474
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.

Posted on
Sun Apr 12, 2020 11:06 am
Ramias offline
Posts: 169
Joined: Nov 24, 2015

Re: Plugin for Haiku Fan with SenseME

For those having trouble with version 0.70 of this plugin, I think I've had a breakthrough (At least for me) to the KeyError on line 544;

Starting with line 544, comment out these lines from the plugin's plugin.py file:
Code: Select all
        fan = self.allfans[dev.id]

        if tempUnits == 'C':
            temp = int(float(fan['coolingIdealTemp']) / 100.0)
            dev.updateStateOnServer('coolingIdealTemp', temp)

            temp = int(float(fan['sleepIdealTemp']) / 100.0)
            dev.updateStateOnServer('sleepIdealTemp', temp)
        else:
            temp = int((int(fan['coolingIdealTemp']) / 100.0) * 9 / 5) + 32
            dev.updateStateOnServer('coolingIdealTemp', temp)

            temp = int((int(fan['sleepIdealTemp']) / 100.0) * 9 / 5) + 32
            dev.updateStateOnServer('sleepIdealTemp', temp)


Save and reload the plugin. Add new fans. Open and edit and save existing fans.

You can then uncomment those lines, reload the plugin, and open/edit/save should work for all existing fans.

I'm sure there's an actual "code" way to fix this, but this is how I was able to get v 0.70 working for me. It's not every day I buy new fans, so I can probably stick with this for now. Hopefully this helps somebody else.

Who is online

Users browsing this forum: No registered users and 1 guest

cron