Closed bpennypacker closed 5 years ago
As a followup to the above, I just re-enabled the debug
action on my local copy which invokes the function debugState()
that sends the current state of the entire fan dict to the Indigo log. I enabled logging, then restarted the control. This is what the Indigo log looks like after doing all this:
Starting plugin "SenseME Fan 0.7.0" (pid 74683)
Started plugin "SenseME Fan 0.7.0"
SenseME Fan Debug startup called
SenseME Fan Debug Starting device 'Living Room Fan'
SenseME Fan Debug query <Living Room;DEVICE;ID;GET> returned: 20:F8:5E:AB:31:1B
SenseME Fan Debug starting runConcurrentThread()
SenseME Fan Debug Living Room : Thread connecting to 172.16.1.18
SenseME Fan Debug processing message (Living Room Fan;DEVICE;BEEPER;ON)
SenseME Fan Debug Changing beep to ON (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;DEVICE;INDICATORS;ON)
SenseME Fan Debug Changing indicators to ON (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;DEVICE;LIGHT;PRESENT)
SenseME Fan Debug processing message (Living Room Fan;DEVICE;SERVER;PRODUCTION)
SenseME Fan Debug processing message (Living Room Fan;ERRORLOG;ENTRIES;NUM;10)
SenseME Fan Debug processing message (Living Room Fan;ERRORLOG;ENTRIES;MAX;10)
SenseME Fan Debug processing message (Living Room Fan;FAN;AUTO;OFF)
SenseME Fan Debug Changing fan motion to OFF (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;SNSROCC;STATUS;OCCUPIED)
SenseME Fan Debug Changing motion to OCCUPIED (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;FAN;DIR;FWD)
SenseME Fan Debug Changing direction to forward (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;FAN;PWR;OFF)
SenseME Fan Debug Changing fan to OFF (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;FAN;SPD;ACTUAL;0)
SenseME Fan Debug Changing fan speed to 0 (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;FAN;SPD;MAX;7)
SenseME Fan Debug processing message (Living Room Fan;FAN;SPD;MIN;1)
SenseME Fan Debug processing message (Living Room Fan;FAN;BOOKENDS;1;7)
SenseME Fan Debug processing message (Living Room Fan;FAN;TIMER;CURR;0)
SenseME Fan Debug processing message (Living Room Fan;FAN;TIMER;MAX;7)
SenseME Fan Debug processing message (Living Room Fan;FAN;TIMER;MIN;1)
SenseME Fan Debug processing message (Living Room Fan;FAN;WHOOSH;STATUS;OFF)
SenseME Fan Debug Changing whoosh to OFF (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;FW;NAME;FW000003)
SenseME Fan Debug processing message (Living Room Fan;FW;FW000003;2.5.0)
SenseME Fan Debug processing message (Living Room Fan;GROUP;LIST;Living Room)
SenseME Fan Debug processing message (Living Room Fan;GROUP;ROOM;TYPE;6)
SenseME Fan Debug processing message (Living Room Fan;LEARN;MAXSPEED;7)
SenseME Fan Debug processing message (Living Room Fan;LEARN;MINSPEED;0)
SenseME Fan Debug processing message (Living Room Fan;LEARN;ZEROTEMP;2111)
SenseME Fan Debug Changing cooling ideal temperature 69.8 F (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;AUTO;OFF)
SenseME Fan Debug Changing light motion to OFF (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;LEVEL;ACTUAL;16)
SenseME Fan Debug Changing light level to 16 (trigger:False)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;BOOKENDS;1;16)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;LEVEL;MAX;16)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;LEVEL;MIN;1)
SenseME Fan Debug processing message (Living Room Fan;LIGHT;PWR;ON)
SenseME Fan Debug Changing light to ON (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;NAME;VALUE;Living Room Fan)
SenseME Fan Debug processing message (Living Room Fan;NW;AP;STATUS;OFF)
SenseME Fan Debug processing message (Living Room Fan;NW;DHCP;OFF)
SenseME Fan Debug processing message (Living Room Fan;NW;PARAMS;ACTUAL;172.16.1.18;255.255.255.0;172.16.1.1)
SenseME Fan Debug processing message (Living Room Fan;NW;SSID;THLegacy)
SenseME Fan Debug processing message (Living Room Fan;NW;TOKEN;9b673be6-86c8-49e7-9ac9-35c7c69e785d)
SenseME Fan Debug processing message (Living Room Fan;SCHEDULE;CAP;MAX EVENTS,29)
SenseME Fan Debug processing message (Living Room Fan;SCHEDULE;EVENT;LIST;0)
SenseME Fan Debug processing message (Living Room Fan;SLEEP;EVENT;OFF)
SenseME Fan Debug processing message (Living Room Fan;SLEEP;EVENT;ON)
SenseME Fan Debug processing message (Living Room Fan;SLEEP;STATE;OFF)
SenseME Fan Debug Changing sleep mode to OFF (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;SMARTMODE;ACTUAL;HEATING)
SenseME Fan Debug Changing smartmode to HEATING (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;SMARTMODE;STATE;HEATING)
SenseME Fan Debug processing message (Living Room Fan;SMARTSLEEP;IDEALTEMP;2111)
SenseME Fan Debug Changing sleep ideal temperature 69.8 F (trigger: False)
SenseME Fan Debug processing message (Living Room Fan;SMARTSLEEP;MAXSPEED;6)
SenseME Fan Debug processing message (Living Room Fan;SMARTSLEEP;MINSPEED;0)
SenseME Fan Debug processing message (Living Room Fan;SNSROCC;TIMEOUT;CURR;1200000)
SenseME Fan Debug processing message (Living Room Fan;SNSROCC;TIMEOUT;MAX;86400000)
SenseME Fan Debug processing message (Living Room Fan;SNSROCC;TIMEOUT;MIN;60000)
SenseME Fan Debug processing message (Living Room Fan;TIME;VALUE;2018-12-06T18:49:36Z)
SenseME Fan Debug processing message (Living Room Fan;WINTERMODE;HEIGHT;213)
SenseME Fan Debug processing message (Living Room Fan;WINTERMODE;STATE;ON)
SenseME Fan Debug processing message (Living Room Fan;SCHEDULE;EVENT;INDEX;0;SUN+MON+TUE+WED+THU+FRI+SAT;1:00;LIGHT,PWR,OFF)
SenseME Fan Debug dumping fan dict:
SenseME Fan Debug Fan name : Living Room Fan
SenseME Fan Debug MAC : 20:F8:5E:AB:31:1B
SenseME Fan Debug light : ON
SenseME Fan Debug fan : OFF
SenseME Fan Debug light level : 16
SenseME Fan Debug fan level : 0
SenseME Fan Debug light auto : OFF
SenseME Fan Debug fan auto : OFF
SenseME Fan Debug smart mode : HEATING
SenseME Fan Debug motion : OCCUPIED
SenseME Fan Debug whoosh : OFF
SenseME Fan Debug beep : ON
SenseME Fan Debug indicators : ON
SenseME Fan Debug direction : forward
SenseME Fan Debug cooling temp: 2111
SenseME Fan Debug sleep temp : 2111
SenseME Fan Debug status : off / on (f:0, l:16)
SenseME Fan Debug sleep mode : OFF
SenseME Fan Debug dump complete
So this does appear to be working as described in my last comment. The dict is initialized to all empty values, getFanStatus()
is called, which sends the message <Living Room;DEVICE;ID;GET>
to the fan. The fan then responds with messages listing out the full current state of the fan, which the plugin parses and uses to fill in the dict. Then I invoked the debug Action in Indigo which dumped the dict which shows every field is properly populated.
The problem that I had seen was that cooling temp and sleep temp were not initialized for my fan. That cause an exception in validateDeviceConfigUi() because int() doesn't like operating on empty strings.
temp = int((int(fan['coolingIdealTemp']) / 100.0) * 9 / 5) + 32
I suspect it was related to the fan firmware version. My fan initially had no concept of cooling temp and sleep temp and I suspect was not responding to the GETALL with anything useful. After I installed the latest plugin version and made the patch that you tried out, I updated my fan to firmware 2.5.1 and now the values are populated.
It might be best to just make validateConfigDeviceUi() not attempt to update fan['idealCoolingTemp'] and fan['idealSleepTemp'] if they are current empty. That may avoid problems for people using older firmwares.
Ah, I hadn't even considered that this could be related to an older firmware version on the fan but that makes sense. If you're running an older version that doesn't include everything the plugin is looking for in the GETALL response then I can definitely see this happening. I'll have to think about the best way to deal with this.
Reverts bpennypacker/SenseME-Indigo-Plugin#11
I actually just realized that I shouldn't have merged this so I have reverted it. I need to research what this is intended to fix, as this fix is going to cause unexpected behavior.
The dict that's modified in this PR is just a temporary state that should be completely empty when Indigo initially creates the device. Because the device was just created neither the plugin nor Indigo itself has any idea what the current state of the fan is, so all those values are considered "undefined". Immediately after this dict is initialized a call is made to
getFanStatus()
which causes the fan to respond with a series of messages back to the plugin that lists the current state of every fan parameter. Those messages are received by the plugin via theprocessFanMessage()
function, which updates the dict with the actual current state of each property that is tracked in the dict.processFanMessage()
also callsdev.updateStateOnServer()
for each property to ensure Indigo itself knows the current state, and it sets the parametertriggerEvents
to False if the old value in the dict was set to''
. This ensures Indigo knows the current state but doesn't actually trigger the associated action. IftriggerEvents
is set to true then Indigo would trigger the action.So by setting
coolingIdealTemp
andsleepIdealTemp
to '0' rather than '' this is likely causing those actions in Indigo to trigger any time the plugin is restarted. If these really do need to be set to '0' initially then the respectivetriggerEvents
check in the appropriate sections ofprocessFanMessage()
would also need to be updated. Also the related section where the device state is reinitialized (search formsgtype == MSG_REINIT
) would also need to be updated to set these to '0' instead of ''.