Script help
James Sentman
james at sentman.com
Mon Apr 6 22:33:17 EDT 2020
Chuck is right about using variables and also future value. I would possibly go a step or two further though :) You can compare both future value and value of (thisUnit) to know if the value was previously above or below the setpoint but is now equal to or below or whatever, so you don’t have to worry unless you’re actually crossing the threshold. The other thing you can do is to have 2 values for each change, one higher than the other which will protect you from switching on and off continually. You’ll be doing a schmitt trigger. So the temp for turning on the first fan is not a single boundry, it’s 2. Say 80 and 82. The fan won’t turn on until the temp is over 82, but won’t turn off until the temp drops below 80. That way it won’t be clicking on and off constantly as it oscillates around 80 when it first turns on. Do the same thing for the second fan but with 2 higher temps.
Im just typing this into email and not testing it ;) So typos and applescript syntax forgetfullness may have to be corrected by you :)
property tempLowOn: 76
property tempLowOff: 74
property tempHighOn: 86
property tempHighOff: 83
set newTemp to (future value)
set currentTemp to (value of (thisUnit))
— manage fan 1
if newTemp ≥ tempLowOn and currentTemp < tempLowOn then
turnon “relay of fan 1”
else if newTemp < tempLowOff and currentTemp ≥ tempLowOff then
turnoff “relay of fan 1”
end if
— manage fan 2
if newTemp ≥ tempHighOn and currentTemp < tempHighOn then
turnon “relay of fan2”
else if newTemp < tempHighOff and currentTemp ≥ tempHighOff then
turnoff “relay of fan 2”
end if
I think that will do it. It will only turn anything on or off at the intersection of the temp readings where it was previously not in the range but now is so you don’t need anything with timers or events, just this in the On script receiving the temperature.
> On Apr 2, 2020, at 4:40 PM, Charlie Pendleton <charlie at pendletonweb.com> wrote:
>
> Thanks Chuck, I do like the idea of the variables. I will also give this a try.
>
> This list is the best!
>
> On April 2, 2020 at 3:08:30 PM, Chuck (xtension4osx at mac.com <mailto:xtension4osx at mac.com>) wrote:
>
>> Charlie,
>>
>> property tempLow : {}
>> property tempHigh : {}
>>
>> set tempLow to 76 —for control of the relay-2
>> set tempHigh to 85 —for control of the relay-3
>>
>> if future value is less than tempLow then
>> if status of “Barix-50: Relay-2” is true then
>> turnoff “Barix-50: Relay-2”
>> if status of “Barix-50: Relay-3” is true then
>> turnoff “Barix-50: Relay-2”
>> end if
>> end if
>> else
>> if “Barix-50 is greater than tempLow then
>> if status of “Barix-50: Relay-2” is false then
>> turnon “Barix-50: Relay-2”
>> end if
>> end if
>>
Thanks,
James
James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200406/cc25294c/attachment.html>
More information about the XTensionList
mailing list