Scripting

Description

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

Forums

I currently have an excelent script that switches on my immersion if the solr generates over 1.8Kw and the meter indicates i am feeding the grid.

 

what i want to do is exactly the same but fire another relay if my solar generates over 2.5Kw.

 

CAN I copy the existing script change the values and save it under a different name?

 

Dean

Forums

A script been done by anyone that :-

 

input goes high and then 500ms later an rf stste is toggled?

 

bought some homeeasy doorbells and want to integrate them into existing system hence need a 500ms delay (otherwise 2 rf doorbells will clash)

 

Dean

Forums

I'm afraid I'm struggling with xap messages again.

I'm feeding temperature data into xap-serial and I can see the xap messages on xfx viewer as follows

xap-header
{
v=12
hop=1
uid=FF00D500
class=Serial.Comms
source=dbzoo.livebox.Serial
}
Serial.Received
{
port=/dev/ttyUSB1
data=20.0
}

 

Unfortunately when I apply a filter like:

f:add ("xap-header","source","dbzoo.livebox.Serial")

f:add("xap-header","class","Serial.Comms")

and then in my callback function I try to use

frame:getValue("Serial.Received","data")

to extract the data element but it returns a nil value.

What should my callback function be looking for?

 

Allan

Forums

Hi,

I'm having trouble collecting xap messages to pachube from remote system.

One part of my system uses a joggler(ubuntu) connected with USB/RS232 to my resol solar collector.

I'm using it partly as an excuse to learn python also and using the create examples and xaplib.pm from http://www.dbzoo.com/livebox/hah_xap_python.

from the broadcast side, I'm managing to sucessfully send out packets from the joggler and with the windows xap viewer I can see the packets as I expect them: 

xap-header

{

v=12

hop=1

uid=FF000F00

class=xAPBSC.event

source=shawpad.ujog.solar

target=

}

input.state

{

colTemp=-0.40

tankbotTemp=59.90

tanktopTemp=73.00

pump=0

}

I understand that I should probably select a unique uid, but hoping this should be ok for now.

These are transitted every 60 seconds onto the network, no heartbeats, just repeats of this message.

I've have the attached for my hah pachube config page.

The problem is that none of the temps from my solar packet are getting up to pachube, all the other data is logging sucessfully and feed is live (not frozen).

The pachube log file on hah is empty.

I figure I'm missing something in hah, but after looking around I can't quite see what.

Any pointers appreciated,

Ian.

 


Forums

Hi

 

I want to create 2 scripts one that simulates a momentry switch for example when a bsc command to turn hah relay 1 on the script would then wait 500 millisecond and turn hah relay 1 off making it a momenty switch.

Script 2 take a bsc input and then turn another end point on for example hah input 1 turns on the script would read this and turn on hah relay 2 on, hah input 1 turns off the script would then turn hah relay 2 off.

 

Can someone point me in the right direction, I have looked a the LUA page on here but I am not sure where to star I am used to vb asp but this does not see anything like these.

 

Thanks
John

Forums

I'm afraid that I haven't yet got the idea of the BSC schema so I'd be grateful for any help with the following problem:
I'd like to create a BSC endpoint that will allow me to change a file which shows the state of my boiler boost function.
The idea is to switch it between 1 and 0 depending on the state of the boost.

This is what I have so far but I can't get it to actually change the file.

This is an applet which I was hoping would do the work:

module(...,package.seeall)


require "xap"
require "xap.bsc"

info={
version="1.0", description="Boiler Boost Controller"
}

function boostCmd(endpoint)
file = io.open("/etc/plugboard/boosttemp","w+")
if endpoint.state == "on" then
file:write("1")
else
file:write("0")
end
file:close()
end

function boilerboostInfoEvent(endpoint, clazz)
endpoint.displaytext = "Boost is " .. endpoint.state
return true -- Return TRUE if the INFO/EVENT should be emitted / FALSE otherwise
end


function init()
boilerBSC = bsc.Endpoint{source="dbzoo.livebox.boilerboost:state", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=boostCmd, infoEventCB=boilerboostInfoEvent}
end

*******************************


This is a script just to test the endpoint

require "xap"
require "xap.bsc"

state = 0


function init()
print("starting")
end




function flipflop()

if state == 0 then
state=1
else
state=0
end

if state==1 then
sendBscCmd("dbzoo.livebox.boilerboost:state","text=on")
else
sendBscCmd("dbzoo.livebox.boilerboost:state","text=off")
end

end

function sendBscCmd(target,body)
xap.sendShort(string.format([[xap-header
{
target=%s
class=xAPBSC.cmd
}
output.state.1
{
id=*
%s
}]], target, body))
end


xap.init("dbzoo.lua.boostendpointtest","FF005D00" )

xap.Timer(flipflop,30):start()

xap.process()

******************

xfx viewer shows the xap commands being sent to switch the state and the info seems to change but I don't understand well enough to know why the actual change is not being made to the file.

What am I doing wrong?

 

 

Forums

With the extreme weather on its way, I thought it would be interesting to have a display on the joggler of the min and max temperatures in the last 24 hours.

However, I dont know C, or any other modern language. My programming started with basic and stopped with pascal. I can do assembler but that is about it these days. I seem to be able to follow about 70% of the LUA examples, but the language in the wiki goes over my head Im afraid. What is the f in f:add? I know I need a filter to look at the xAP endpoint, but I cant work it out.

Can someone help me understand? point me to a book for dummys even?

If I could get my head around this I could get the system to email me alerts for temperature in the loft water tank near freezing or the greenhouse frying up.

I dont ask for help lightly in such an "I dont know where to start" manner, but I am lost on this.

 

Many thanks 

Alan

Forums

Brett,

 

I have only recently started to make use of the webserver applet in anger and have noticed it crashes plugboard every now and there at seeming random intervals of uptime.

 

The log shows this to be related to this bit of code:

 

function sendError( client, status, str )
    message = "HTTP/1.0 " .. status .. " OK\r\n" ;
    message = message .. "Server:  xapCacheApplet" .. socket.version .. "\r\n";

error message is: attempt to concatenate field 'version' ( a nil value)

 

should this be info.version as used elsewhere in the code?

 

thanks

Garry.

Forums

 

 

what i have set up is on the inputs i can "see" when my boiler is on or the house alarm is on, what i would like to do is for these to be viewable on the joggler etc also is there a way of uploading and recording switch/input state to pachube?

 

Ta