weird script behavior

Paul Koreneff paulx10 at koreneff.net
Wed Feb 5 13:17:55 EST 2020


Chuck:

My Thermostat state shows words such as ‘idle’ rather than a binary on/off.

It comes from my Vera Plus …

Have you checked how it shows in your XTension unit list?

Paul

> On Feb 5, 2020, at 11:10 AM, Chuck <xtension4osx at mac.com <mailto:xtension4osx at mac.com>> wrote:
> 
> Yes, good catch Philippe. I changed that and now that fan is responding as expected.
> 
> James, yes, I did add the space in “ Winter” to keep the sort where all the critical pseudo’s are at the top of the list.
> 
> So, what is interesting is that the error does not show up when the furnace is not running. Once the furnace is running the error shows up. The furnace thermostat activates the HVAC script I am going to try a delay of 10 seconds and see if that makes a difference. And if that doesn’t work then I will put the script into the “on” of the furnace thermostat.
> 
> It is so weird. I remember a situation like this at least a decade ago and I don’t remember what I did to fix it but I did get it fixed.
> 
> Welcome back James, we missed you.
> 
> Chuck
> 
>> On Feb 5, 2020, at 7:23 AM, James Sentman <james at sentman.com <mailto:james at sentman.com>> wrote:
>> 
>> That is a very good catch Philippe!
>> 
>> the status verb will return a boolean, and you’re comparing it to a number which does make sense for the error message you’re getting.  I only see that in the one place in the script down towards the bottom, but I would definitely review the logic throughout as I’m not entirely sure of my proofreading skills yet ;) 
>> 
>> I would also verify that the name of your “Winter” unit really does start with a space? I see it in the script as “ Winter” each time. Which is fine, I sometimes do the same just to force things to sort the way I want them to, but since thats also interesting I wanted to mentino it.
>> 
>> The only other things I would suggest are just style questions. Everytime you use an XTension verb there is some overhead as it calls back into the program and looks up the information and returns it. It’s not a lot, but it adds up. Not that it’s a problem as the script probably runs in plenty of time, but you could speed it up some, and reduce changes for typos down in the code by pulling some of the most called for values into local variables to compare rather than asking XTension for the same thing over and over again.  There aren’t many but you could pull Thermostat (State) and Winter into locals for faster comparison something like:
>> 
>> set isWinter to (status of “ Winter”)
>> set thermostatState to (status of “Thermostat (State)”)
>> 
>> and then do the comparisons just like:
>> 
>> 
>> if isWinter then
>> 	if thermostatState then
>> 		if (value of "Ceiling fan - Happyroom") is less than 100 then
>> 			brighten "Ceiling fan - Happyroom" to 100
>> 		end if
>> 		if (value of "Ceiling fan - LR") is less than 100 then
>> 			brighten "Ceiling fan - LR" to 100
>> 		end if
>> 		if (value of "Ceiling fan - TV") is less than 100 then
>> 			brighten "Ceiling fan - TV" to 100
>> 		end if
>> 	end if
>> else
>> 	if not thermostatState then
>> 		if (status of "Ceiling fan - Happyroom") is true then
>> 			turnoff "Ceiling fan - Happyroom"
>> 		end if
>> 		if (status of "Ceiling fan - LR") is true then
>> 			turnoff "Ceiling fan - LR"
>> 		end if
>> 		if (value of "Temp - TV room") is greater than 70 then
>> 			if (value of "Ceiling fan - TV") is not equal to 66 then
>> 				brighten "Ceiling fan - TV" to 66
>> 			else
>> 				if (value of "Ceiling fan - TV") is not equal to 33 then
>> 					brighten "Ceiling fan - TV" to 33
>> 				end if
>> 			end if
>> 		end if
>> 	end if
>> end if
>> 
>> and so forth as you access those values quite a bit throughout the script.
>> 
>> For myself I’ve also created an attachment handler called:
>> 
>> on turnonConditional( theUnit)
>> 	if not (status of theUnit) then
>> 		turnOn theUnit
>> 	end if
>> end turnonConditional
>> 
>> on turnoffConditional( theUnit)
>> 	if (status of theUnit) then
>> 		turnOff theUnit
>> 	end if
>> end turnoffConditional
>> 
>> on dimConditional( theUnit, theValue)
>> 	if (value of theUnit) is not equal to theValue then
>> 		dim theUnit to theValue
>> 	end if
>> end dimConditional
>> 
>> 
>> This doesn’t remove any extra calls, but makes the code easier to read and few places to mistype a unit name as you could just do things like:
>> 
>> if isWinter and not thermostatState then
>> 	turnoffConditional( "Ceiling fan - Happyroom”)
>> 	dimConditional( “Ceiling fan - TV”, 33)
>> 	turnoffConditional( “Ceiling fan - LR)
>> end if
>> 
>> rather than the last 3 comparisons for ceiling fans in the script. Again those last things won’t affect the actual reliability or speed of the script, but is just a style suggestion.
>> 
>> Thanks,
>>   James
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200205/2b0249c5/attachment.html>


More information about the XTensionList mailing list