Joggler question
Hi
I have an interface on my joggler that controls my heating. It indicates when the timer has kicked in for each zone. I have boost override buttons for 1 and 2 hours for each zone. All works well but I would love to have a countdown indicator on the boost button. I think it would need some sort of contrived endpoint that counted down 1:59, 1:58 etc
I have no idea how to achieve this, anyone have any ideas.
thanks
John
Here are a couple of thoughts on things you might need to do, though I can't say I'm an expert.
You'll need some kind of boost time counter, I use this:
runningtime = os.difftime(os.time(), boosttime)
where boosttime is set when the boost period starts.
It counts in seconds.
You'll need some kind of bsc endpoint, maybe
bscBoostCounter = bsc.Endpoint{source="dbzoo.livebox.Plugboard:BoostCounter", direction=bsc.INPUT, type=bsc.STREAM}
When you are in the counting phase you'll need to update the end point at whatever interval you decide on, perhaps something like this:
bscBoostCounter:setText( tostring(3600-runningtime) )
bscBoostCounter:sendEvent()
I think that this will show a reducing number of seconds remaining of the boost (change 3600 to 7200 if it's a 2 hour boost)
Then you'll need to read the bsc.Endpoint and display it on your joggler.
I've no idea if or how this would work in practice but it's how I would start if I was going to have a go.
Hope it helps
Allan
You probably could put it in the alias handler, as long as you create it somewhere I think it should be accessible. Personally I'd create it in the script that runs the code for your heating controller in the init section.
Just as a matter of interest I've implemented the above suggestions on my box, to the extent of creating and updating the endpoint, (I don't have a Joggler).
I've used bscBoostCounter:setText( tostring(math.floor((3600-runningtime)/60)) ) in my boiler update routine to give me the count down in minutes. As it is a valid bsc endpoint I would think that you should be able to do pretty well whatever you need with it.
I'm not really qualified to comment on the resource usage issue but my "heating controller" routine runs every minute and compares house temp to thermostat setting and switches the boiler on/off as appropriate. I include:
runningtime = os.difftime(os.time(), boosttime)
bscBoostCounter:setText( tostring(math.floor((3600-runningtime)/60)) )
bscBoostCounter:sendEvent()
in the boiler update routine and this sets the endpoint which can be referenced by reading the xap message. This gives a reducing count of minutes left of the boost period.
P.S. If you're counting down in minutes there's probably no point in updating every 30 seconds if you think that resource usage might be an issue.
Yes.
xap.Timer(updateboiler, updateinterval):start()
So it checks temp, thermostat setting and boost state once each minute and outputs the appropriate code to the boiler. The boost state can then be referenced by the xap message.
But OK.
In your init section you probably need to add a filter to respond to
a relay 1 event. Like this:
local f = xap.Filter()
f:add("xap-header", "source", "dbzoo.livebox.Controller:relay.1")
f:add("xap-header","class","xAPBSC.event")
f:callback(BoostStart)
and then you need a function (which I've called BoostStart) to handle
a change in the state of relay 1.
Within that function you should set a variable depending on the
output state of relay 1. Your heating controller can then reference
that variable to determine whether the boost is on or off.
You will then be able to use the format of "if relay 1 is on" by testing
the variable which you created.
Here's a snippet from my heating controller which deals with the boost
if boost == 1 then
if boosttime == 0 then -- first pass, set boost start time.
boosttime = os.time()
--print(" Boost Start : " ..tostring(boosttime))
bscBoostCounter:setText( "60" ) -- Set boost counter to 60 minutes and update end point.
bscBoostCounter:sendEvent()
else
runningtime = os.difftime(os.time(), boosttime)
bscBoostCounter:setText( tostring(math.floor((3600-runningtime)/60)) )
bscBoostCounter:sendEvent()
Let me know if you need more info.
unless you particularly want to.
The alias handler just parses an alias message and sends the appropriate xap message.
As I said above what I think you need is a function which reacts to a change in the state of relay 1. If you use such a function then when the function is called because of a change of state of relay 1 your script can set a variable (in my code snippet the varable "boost" is changed to 1 or 0 depending on the boost state ) which you can then test to determine whether the boost is on or off.
The additional variable boosttime is used as the counter for how long the boost state has been running. I set it to the system time when the boost state starts and to 0 when the boost state ends.
You are probably best doing all this stuff in your heating controller script and leaving the alias handler alone.
Yes, you need to create a virtual endpoint that either is a BSC level device in which case it could be visualised as a slider or a text type which will give you the numerical countdown. Actually you could use a level endpoint with a displaytext parameter that would give you both options.
K