After a number of years of using the HAH to manage our central heating amongst other things, we have made a number of building changes to our house and would like to zone our central heating.
Hi Brett many thanks for your lighteningly fast reply.
Yes I did look at the bindings applet in the samples folder, unfortunatley my lua skills are very limited and was not able to work out the changes to be made to suit my requirements.
I have trolled all through the forum and cannot find anything close that I think I could adapt.
Those changes look correct there where two places to change the dbzoo.livebox.Slave.relay.* filter string I assume you did both. You might want to put in debugging print statements in the callback to see if its getting in there. Sounds like its not for some reason which would imply a filter issue. The trick is understanding what I've given you so you can see the path forward.
Hi Brett, yes I had made the 3 changes, see below for complete applet.
Many thanks for your pointers, I will delve deeper as to what the problem is, unfortunatley my software skills are very limited so may take a while. Not sure how to implement the debug but will look back through the forum for help.
--[[
If any SLAVE relay is on then the MASTER relay should be on too.
Assumption:
When the script starts all slaves are OFF
The script will update that assumption as events are received.
--]]
module(...,package.seeall)
require("xap")
require("xap.bsc")
info={
version="1.0", description="any slave on, master on"
}
slaveStates={'off','off','off','off'}
masterState="off"
local function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
-- Filter Callback
local function anyOn(master)
-- Strip the Relay ID from the source and record the state
local id = xap.getValue("xap-header","source"):sub(-1)
Member for
16 years 10 monthsKema, Did you have a look at
Kema, Did you have a look at the sample where relays are bound together so they stay in sync?
https://github.com/dbzoo/hah/blob/master/userapps/hah/xap-plugboard/samples/bindRelaysApplet.lua
Doing more would require I wrap my head around my code and figure this out as its been a while.
Member for
13 years 4 monthsHi Brett many thanks for your
Hi Brett many thanks for your lighteningly fast reply.
Yes I did look at the bindings applet in the samples folder, unfortunatley my lua skills are very limited and was not able to work out the changes to be made to suit my requirements.
I have trolled all through the forum and cannot find anything close that I think I could adapt.
Many Thanks
Member for
16 years 10 monthsI'll fire up my trusty HAH
I'll fire up my trusty HAH development VM and see if I can whip you up something. It might be a day or two if you can bear with me.
Member for
13 years 4 monthsBrilliant
Brett fantastic, really apprechiate your help.
Many Thanks
Member for
16 years 10 monthsSome scripts. Tee applet is
Some scripts. The applet is what you want. I'm also attaching my endpoint simulator that I used to verify the applet was working.
Member for
13 years 4 monthsHi Brett many thanks for your
Hi Brett many thanks for your help with the master / slave applet, unfortunately I am struggling with what I should substitute for my set up.
I would like my master relay to be “relay.1” so I have substituted
local masterRelay = "dbzoo.livebox.Master:relay.1"
for
local masterRelay = "dbzoo.livebox.Controller:relay.1"
Hopefully this is correct.
My slave relays are controlled via a jeenode with 4 relays
source=dbzoo.livebox.jeenode:kema6.relay1
source=dbzoo.livebox.jeenode:kema6.relay2
source=dbzoo.livebox.jeenode:kema6.relay3
source=dbzoo.livebox.jeenode:kema6.relay4
I am not sure what I should change
f:add("xap-header","source","dbzoo.livebox.Slave:relay.*")
The following does not work
f:add("xap-header","source"," dbzoo.livebox.jeenode:kema6.relay.*”)
Many Thanks
Member for
16 years 10 monthsThose changes look correct
Those changes look correct there where two places to change the dbzoo.livebox.Slave.relay.* filter string I assume you did both. You might want to put in debugging print statements in the callback to see if its getting in there. Sounds like its not for some reason which would imply a filter issue. The trick is understanding what I've given you so you can see the path forward.
Member for
13 years 4 monthsHi Brett, yes I had made the
Hi Brett, yes I had made the 3 changes, see below for complete applet.
Many thanks for your pointers, I will delve deeper as to what the problem is, unfortunatley my software skills are very limited so may take a while. Not sure how to implement the debug but will look back through the forum for help.
--[[
If any SLAVE relay is on then the MASTER relay should be on too.
Assumption:
When the script starts all slaves are OFF
The script will update that assumption as events are received.
--]]
module(...,package.seeall)
require("xap")
require("xap.bsc")
info={
version="1.0", description="any slave on, master on"
}
slaveStates={'off','off','off','off'}
masterState="off"
local function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
-- Filter Callback
local function anyOn(master)
-- Strip the Relay ID from the source and record the state
local id = xap.getValue("xap-header","source"):sub(-1)
slaveStates[tonumber(id)] = xap.getValue("output.state","state")
-- Is any slave relay on?
if has_value(slaveStates,'on') then
newState='on'
else
newState='off'
end
if masterState ~= newState then
bsc.sendState(master, newState)
masterState = newState
end
end
function init()
--local masterRelay = "dbzoo.livebox.Master:relay.1"
local masterRelay = "dbzoo.livebox.Controller:relay.1"
f = xap.Filter()
--f:add("xap-header","source","dbzoo.livebox.Slave:relay.*")
f:add("xap-header","source","dbzoo.livebox.jeenode:kema6.relay.*")
f:add("xap-header","class","xapbsc.event")
f:callback(function() anyOn(masterRelay) end)
-- Make sure we always have the correct state.
-- Handle HAH reset with master/slaves still on
f = xap.Filter()
f:add("xap-header","source",masterRelay)
f:add("xap-header","class","xapbsc.info")
f:callback(function() masterState = xap.getValue("output.state","state") end)
f = xap.Filter()
--f:add("xap-header","source", "dbzoo.livebox.Slave:relay.*")
f:add("xap-header","source", "dbzoo.livebox.jeenode:kema6.relay.*")
f:add("xap-header","class", "xapbsc.info")
f:callback(function() anyOn(masterRelay) end)
end