Plugin for Haiku Fan with SenseME

Posted on
Sun Feb 09, 2020 9:46 pm
mpleeds offline
Posts: 57
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:

Code: Select all
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:

Code: Select all
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: 8335
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: 628
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: 57
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: 628
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: 272
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.

Posted on
Tue Aug 11, 2020 5:47 am
jenkins007 offline
Posts: 113
Joined: Nov 08, 2006
Location: Seguin, TX

Re: Plugin for Haiku Fan with SenseME

This is a great way to automate these fans. I have 3 of them and will make triggers to execute this action group.

I am getting an error on the last line:
Code: Select all
 senseMePlugin.executeAction("fanSpeed", deviceId=fan_id, props={'speed':str(new_fan_speed)})

The error is
Script Error embedded script: Python argument types in
PluginInfo.executeAction(PluginInfo, str)
did not match C++ signature:
executeAction(CPlugin {lvalue}, CCString actionTypeId, unsigned long deviceId=0, boost::python::api::object props=None, bool waitUntilDone=True)
Script Error Exception Traceback (most recent call shown last):

embedded script, line 31, at top level
ArgumentError: Python argument types in
PluginInfo.executeAction(PluginInfo, str)
did not match C++ signature:
executeAction(CPlugin {lvalue}, CCString actionTypeId, unsigned long deviceId=0, boost::python::api::object props=None, bool waitUntilDone=True)


I tried changing the str to integer and continue to get this error. I am using plugin version 0.7.0 and 7.4 Indigo. The plugin works well in getting status of the fans and on/off, but not incrementing speed.
Thanks,
Matthew

Thanks,
Matthew

Posted on
Wed Aug 12, 2020 5:07 am
jenkins007 offline
Posts: 113
Joined: Nov 08, 2006
Location: Seguin, TX

Re: Plugin for Haiku Fan with SenseME

Interesting, I changed the device ID to the Python reference (even though I had fan_id referencing it elsewhere), and it worked. I wonder if that is supposed to happen?

Thanks,
Matthew

Posted on
Wed Aug 12, 2020 11:02 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Plugin for Haiku Fan with SenseME

The error is saying that you are calling executeAction only with a single argument (which is probably the actionTypeId of "fanSpeed"). Maybe the line of code you think is being executed is a different one? You can debug into this more by logging each argument (to log an argument as a string try using: str(type(fan_id)) to see what is actually being passed in. Also add log lines before and after each executeAction() call so you can see which one is actually failing.

Image

Posted on
Sun Aug 16, 2020 5:00 am
jenkins007 offline
Posts: 113
Joined: Nov 08, 2006
Location: Seguin, TX

Re: Plugin for Haiku Fan with SenseME

Thanks Matt. When I change the fan device Id from the referenced one to that actual numbers the error goes away. The script runs and tells me that the fan speed is changing ( I used the code in this thread without changing anything other than the python device reference which was a cut-and-paste).

However, the actual fan speed does not change. I know there have been at least 2 firmware updates this year. Maybe there are other factors involved?

Thanks,
Matthew

Posted on
Wed Aug 19, 2020 5:31 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Plugin for Haiku Fan with SenseME

What does it log when you execute the script? I'm not familiar with the Haiku hardware or firmware updates, so I'm not sure if that might be related or not.

Back to the fan_id argument problem, I'd be curious what this logs if you put it directly before the executeAction() line:

Code: Select all
indigo.server.log("fan_id type: {},  fan_id val: {}".format(type(fan_id),fan_id))

and then execute it use both an integer of the fan_id (which showed the strange error you originally posted above) as well as the device instance (which sounds like it works?). That is, execute the script twice once each with the respective fan_id values.

Image

Posted on
Fri Oct 02, 2020 6:45 am
jenkins007 offline
Posts: 113
Joined: Nov 08, 2006
Location: Seguin, TX

Re: Plugin for Haiku Fan with SenseME

I used this code:
Code: Select all
fan_id = indigo.devices[654330629] # "Mandy Fan"
indigo.server.log("fan_id type: {},  fan_id val: {}".format(type(fan_id),fan_id))

The output:
Code: Select all
   Script                          fan_id type: <class 'indigo.Device'>,  fan_id val: address :
batteryLevel : None
buttonGroupCount : 0
configured : True
description : Also known as Kitana
deviceTypeId : SenseME_fan
displayStateId : statusString
displayStateImageSel : FanOff
displayStateValRaw : off / on
displayStateValUi : off / on
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 674758727
globalProps : MetaProps : (dict)
     com.pennypacker.indigoplugin.senseme : (dict)
          fanIP : 192.168.1.32 (string)
          fanMAC : 20:F8:5E:1E:F0:1F (string)
          fanName : Kitana (string)
          fanTempUnits : F (string)
id : 654330629
lastChanged : 2020-10-02 07:08:38
lastSuccessfulComm : 2020-10-02 07:08:38
model : SenseME fan
name : Mandy Fan
ownerProps : com.pennypacker.indigoplugin.senseme : (dict)
     fanIP : 192.168.1.32 (string)
     fanMAC : 20:F8:5E:1E:F0:1F (string)
     fanName : Kitana (string)
     fanTempUnits : F (string)
pluginId : com.pennypacker.indigoplugin.senseme
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
     beep : ON (string)
     brightness : 14 (integer)
     coolingIdealTemp : 66.2 (real)
     coolingIdealTemp.ui : 66.2 F (string)
     direction : forward (string)
     direction.forward : true (bool)
     direction.reverse : false (bool)
     fan : off (on/off bool)
     fan_motion : ON (string)
     indicators : ON (string)
     light : on (on/off bool)
     light_motion : OFF (string)
     motion : off (on/off bool)
     sleepIdealTemp : 66.2 (real)
     sleepIdealTemp.ui : 66.2 F (string)
     sleepMode : OFF (string)
     smartmode : COOLING (string)
     speed : 0 (integer)
     statusString : off / on (string)
     whoosh : OFF (string)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : None

Thanks,
Matthew

Posted on
Fri Oct 02, 2020 8:19 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Plugin for Haiku Fan with SenseME

Did you put that log line directly before the executeAction() call line?
And did you see after the debug log information in the Event Log window the same error you saw before?

That is, can you copy/paste the entire Event Log results (not just the result of the debug line)?

Image

Posted on
Tue May 17, 2022 9:52 am
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Plugin for Haiku Fan with SenseME

Just opened up the Haiku app on my phone (since my Mac is rebooting with the MacOs 12.4 update) and there's a new Big Ass Fans app that also requires a firmware update (and says the old app will no longer work).

I value my control of these fans with Indigo more than any new feature so will resist the upgrade urge for now.

Update: Thread on this from another platform: https://github.com/home-assistant/core/issues/69370

Looks like this new firmware is a breaking change but other devs have worked out the new protocol.

Posted on
Tue May 17, 2022 11:55 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Plugin for Haiku Fan with SenseME

I meant to post on this as well. I had the same thought as you, and did not upgrade. Breaking my indigo integration would be killer. I’ve gotten it to where my fan speed is 100% controlled by Indigo.

Ramias wrote:
Just opened up the Haiku app on my phone (since my Mac is rebooting with the MacOs 12.4 update) and there's a new Big Ass Fans app that also requires a firmware update (and says the old app will no longer work).

I value my control of these fans with Indigo more than any new feature so will resist the upgrade urge for now.

Update: Thread on this from another platform: https://github.com/home-assistant/core/issues/69370

Looks like this new firmware is a breaking change but other devs have worked out the new protocol.
t

Who is online

Users browsing this forum: No registered users and 8 guests