Joggler question

14 replies [Last post]
magill
Offline
Joined: 27 Apr 2012

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

kevin
Offline
Huddersfield, United Kingdom
Joined: 17 May 2010
Yes, you need to create a

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

magill
Offline
Joined: 27 Apr 2012
Thanks Kevin for the

Thanks Kevin for the response. Although the theory is helpful I have no idea of how to achieve my goal.

At the moment a button on the joggler sends an alias which triggers a relay and also edits the cronfile to have a relay switch off event in 2 hours. This is where I would like to create the endpoint which somehow counted down the minutes.

John

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Thoughts

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

magill
Offline
Joined: 27 Apr 2012
AllanFood for thought. I'm

Allan

Food for thought. I'm off on hols tomorrow for a couple of weeks but will have a stab at this when I come back.

thanks

John

BTW where would I put the line:

bscBoostCounter = bsc.Endpoint{source="dbzoo.livebox.Plugboard:BoostCounter", direction=bsc.INPUT, type=bsc.STREAM}

In the alias lua?

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
You probably could put it in

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.

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Slight variation

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.

magill
Offline
Joined: 27 Apr 2012
Just back from hols (India)

Just back from hols (India) and getting somewhere with this. What is the best way to set up regular updating, say every 30 sec, of the endpoint. When the boost is triggered I start a timer which when it expires retriggers itself. This works but I am not sure if it eats resource. Any advice?

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
I'm not sure

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.

magill
Offline
Joined: 27 Apr 2012
AllanHow do you trigger your

Allan

How do you trigger your once per minute update. Do you use timer?

John

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Yes

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.

magill
Offline
Joined: 27 Apr 2012
ThanksI didn't realize that

Thanks

I didn't realize that the timer function retriggers itself, I was using a loop. Anyway I now have an endpoint that updates successfully. I now need help with interrogating an endpoint within lua script eg

if "relay1 is on" then etc...

What is the correct method?

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
I don't know how specific you want me to be

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.

magill
Offline
Joined: 27 Apr 2012
Thanks AllanI realize that

Thanks Allan

I realize that there's no easy way to just "look" at the state of an endpoint. I'm running my code in a modified aliasApplet and I will have to modify the function

function rfRelayCmd(t)
local addr1,addr2,state = unpack(t)
bsc.sendState(string.format("dbzoo.livebox.Controller:%s.%s",addr1,addr2),state)
end

to trap this information

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
No necessarily

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.

Hardware Info