Scripting

Description

Queries re using the xap-plugboard component to script xAP action events.

Forums

Hi to everyone who still visits the forum.

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.

I have 4 script/applets (thanks to garry) running 4 different zones which work fine on their own, but this has its limitations.  

What I would like is a very simple script/applet that works as follows:-

If any relay on my RelayNode4{instance="jeenode:kema6",endpoints={relay1=1,relay2=1,relay3=1,relay4=1}, ttl=900}, -(4 ZONES)

is on, then turn on  Relay1 (dbzoo.livebox.Controller:relay.1). 

Any help whatsoever would be very much appreciated.

 Kema...

Forums

Hi, How can I check if my plugboard is running and also check which scripts are running?

 

Thanks

Forums

I've written a script to mirror a xap rf command on my livebox to a port on my raspi.

 

require "xap"
require "xap.bsc"
require("socket");
local switchoff="01427111937";
local switchon ="11427111937";
local myIP="172.16.1.164";
local myPort = 3000;
local sendTx

function init()
client=socket.tcp()
client:settimeout(0.5)
res, err = client:connect(myIP, myPort)
if not res and not res=="timeout" then
print("Error in connect: "..err)
os.exit()
end
print("success")
client:send("u", i, j)
f = xap.Filter()
f:add("xap-header", "source", "dbzoo.livebox.controller:rf.2")
f:add("xap-header","class","xAPBSC.event")
f:callback(switchplug)
end


function getdata()
local s, status, partial = client:receive('*l') --try to read all data
if status ~= "timeout" then
print(s)
end
end




function switchplug(frame)
sendTx = frame:getValue("output.state","state")
print(sendTx)
if sendTx == "on" then
client:send(switchon, i, j)
print(switchon)
else
client:send(switchoff, i, j)
print(switchoff)
end
end


xap.init("dbzoo.lua.tcptest","FF005A00" )
init()
xap.Timer(getdata, 6):start()
xap.process()

 

The script seems to work fine on the livebox but I expected to be able to run it on the Pi and have it respond to the xap function callback. Which of the xap programs needs to be running on the Pi to make this work?

Forums

Hi Brett,

I just noticed the new gateway is crashing my plugboard if it can't connect to the configured broker.

I'm going to try to fix in my rusty Lua but wanted to highlight issue.

 

Forums

Hi,

is this possible?

what would be the notation to do that?

I've tried using a variable to initialise it but the moment I add a 2nd, the first stops running.

I've tried adding counters to a table and using table.key to initialise but same as above.

Forums

Hi Guys

Messing around trying to get my location detection code up and running and I'm getting some weird issues.

When I run this applet:

-- Sets up bsc Endpoints for presence detection
--
-- Auth: Gary, 2014

module(...,package.seeall)
require("xap")
require("xap.bsc")

info={version="0.0.1", description="Locate.Endpoints"}

--function relayInfoEvent(endpoint, clazz)
--   endpoint.state = "off"
--   return false -- Return TRUE if the INFO/EVENT should be emitted / FALSE otherwise
--end

function init()
    xap.init{instance="Locate", uid="FF00DF00"}
    bsc.Endpoint{name="home.Kit", direction=bsc.OUTPUT, type=bsc.LEVEL}
    bsc.Endpoint{name="home.BR", direction=bsc.OUTPUT, type=bsc.LEVEL}
--    bsc.Endpoint{name="home.LR", direction=bsc.OUTPUT, type=bsc.LEVEL}
    bsc.Endpoint{name="home.Loft", direction=bsc.OUTPUT, type=bsc.LEVEL}
    bsc.Endpoint{name="home.Hall", direction=bsc.OUTPUT, type=bsc.LEVEL}
end

I get the following issues:

  1. No more heartbeats from plugboard
  2. When restarting the plugboard(while testing other code), my logRFstatesApplet.lua applet fires but all the rf state cmds have the 'Locate' instance as the source(as seen in XfXViewer.
  3. Plugboard starts showing Serial.Comms messages.

I've checked all the instance settings and all are set to default.

 

What am I doing wrong?

 

Forums

Hi Guys,

I've set myself something of a challenge for my LUA programming development and wondered if I can pick your brains.

I want to start building in some 'intelligence' into the HAH, something some of you may have already done.  My plan is to bring 'presence' as a variable that all applets can be made aware of and modify their behaviour accordingly.  I've seen a few scripts around that seem to refer to presence but only as a 'local' condition i.e. for a room.

My understanding is that on LUA variables can they are global by default but that only means within each applet and local variables are local to the function.

My first thought was to try and create a super global 'variable' that all applets could check but I don't think this is possible, certainly not with my current abilities, so then I thought to use xap and filters.

I could easily create my own broadcast class which each applet(if desired) could check against...i.e. home.lr or away.car something like that.

The HAH could then "reconfigure" things depending on what the global state was.  I could then write a couple of applets that update my new schema by monitoring various items around the house, obvious ones are sensor motion inputs from jeenodes but other inputs could also be used like a button pressed on a Joggler or a remote pressed for Squeezebox etc.

Each area or room would have a sentryApplet that monitors devices and updates the class.

I then thought that this state could be further improved by adding in some 'info quality' checks like checking the last update against current time to determine the probable validity of that state.

Point of the post is to see any of you had any thoughts on this topic and if there were any helpful suggestions on my solution?

Forums

Is there a command for turning on or off, 2 or 3 devices at once? Along the lines of my examples below, that do not work.

 

aliasmsg  “rf.2 on”, “rf.3 on”

 

bscmsg -t dbzoo.livebox.controller:rf.2 -s on, rf.3 –s on

 

The wild card command below to turn off all rf devices does work

bscmsg -t dbzoo.livebox.controller:rf.* -s off

 

Many thanks

 

kema