Scripting

Description

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

Forums

hello 

this simple script 

module(...,package.seeall)

require("xap")

require("xap.bsc")

 

info = {version="0.04", description="HAH LCD Clock"}

 

function init()

xap.Timer(doclock, 5):start()

end

 

function doclock()

  bsc.sendText("dbzoo.dockstar.Controller:lcd", os.date("%H:%M:%S"))

end

 

output this bad xap message !!

 

why ?

thanks for your help

 

 

xap-header

{

  uid=FF00D800

  source=dbzoo.dockstar.Plugboard

  hop=1

  class=xAPBSC.cmd

  target=dbzoo.dockstar.Controller:lcd

  v=12

}

output.state.1

{

  id=*

  text=21:04:17

  state=on

}

Forums

Sorry to ask such as basic question, but which folder should the .LUA files be located for running scripts.

Also I saw somewhere, but cannot find it again, what is the command to run scripts for the command line.

Forums

What is the value returned with <obj>.ttl ?

The value increases if I issue <obj>:reset() but I have tried converting this to a 'readable' time but not having much luck.

Mark

Forums

Okay heres my first attempt, just add the names and mac addresses into the table and your good to go. tested on Rasp PI after installing arping (sudo apt-get install arping)

lets see if this works for the apple stuff..I suspect they will stop responding on standby but time will tell!

 

Garry.

 

 

-- Presence detection via wifi
module(...,package.seeall)

require("xap")
require("xap.bsc")
require("string")

info={
   version="1.0", description="Presence Detection via Wifi"
}

local endpoints = {GarryPhone = "xx:xx:xx:09:33:1B", GarryIpad = "xx:xx:xx:xx:82:BA"}

function Detection(timer, self)
                local msg = "arping -c 1 -i eth0 -q "..self.address
--              print("msg"..msg)
                retval = os.execute(msg)
                if (retval == 0) then state = "on" else state = "off" end
                self:setState(state)
                self:sendEvent()
        timer:reset()
end

function init()
        for k,v in pairs(endpoints) do
                k = bsc.Endpoint{instance="Presence:"..k, direction=bsc.INPUT, type=bsc.BINARY, address=v}
                xap.Timer(Detection, 60, k):start(true)
        end
end

 

Forums

I was thinking about google calender and how the library is deprectated and that got me thinking... "is it possible to drive twitter with just LUA as it has to OAUTH and then pound a REST API just like googlecal does?"

So I compiled up a few lua helper modules and stamped out a simple LUA program that would talk to twitter.

local OAuth = require "OAuth"
oauth_token = "9xxxgIqm"
oauth_token_secret = "DptRmDxxxxxOXHv3eTNc"
consumer_secret="6iaSFRxxxxcFNv7lQyoA"
consumer_key="hmGxxxxxnw"

client = OAuth.new(consumer_key, consumer_secret, {
        RequestToken = "https://api.twitter.com/oauth/request_token",
        AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
        AccessToken = "https://api.twitter.com/oauth/access_token"
}, {
        OAuthToken = oauth_token,
        OAuthTokenSecret = oauth_token_secret
})

-- the mandatory "Hello World" example...
local response_code, response_headers, response_status_line, response_body =
client:PerformRequest("GET", "https://api.twitter.com/1.1/statuses/user_timeline.json", {screen_name = "dbzoo"})
print("response_code", response_code)
print("response_status_line", response_status_line)
for k,v in pairs(response_headers) do print(k,v) end
print("response_body", response_body)

Pretty simple for starters.... more to come.

Forums

Hello,

Has anyone on this forum managed to control the HE830S switches using just an Arduino and RF transmitter?

I have a set of the HE830S switches, controlled by an HE300 remote, which I picked up from B&Q. I would like to be able to control the switches using an Arduino Uno and and a 433MHz RF transmitter (link to the transmitter / receiver set I am using).

I know most people on this forum will be using the modified router to control their switches but after reading some of the forum pages on other people who have the HE830S switches, it seems like the members of this forum have a good degree of technical knowledge on the rf codes/transmission packet sequences used to control these devices. 

What I have tried so far:

I have logged the output of the remote using the rcswitch library for the Arduino, plus used the receiver code on the Arduino Playground Home Easy page to establish my remote control code but I can't successfully transmit and control the HE830S switches using either the rcswitch send code or the Arduino Playground Home Easy transmit scripts. I know the rf transmitter and receiver pair are working as I can send information between them using the rcswitch code (and see the results on the Arduino serial monitor).

Unfortunately my understanding of the remote control's raw data captured by the rcswitch code is limited and I'm not sure how to convert it into a successful transmit package to control the HE830S switches. If anyone could provide any guidance or sample Arduino code I would be most grateful!

Forums

I'm trying to tweak a script to control the lighting using nodes as movement sensors but only after dark.

While playing I have noticed in xFx viewer that sometimes I get a couple of xAPBSC.info messages for the same endpoint with different values without an xAPBSC.event. I thought that an event was sent if an endpoint changed and an info was sent if no change.

Am I mistaken or is this normal?

Forums

I'm not sure what process others use for uploading lua scripts. Filezilla? Anyway I've thrown together a vb app (windows)to download, edit and upload again to Livebox.

If anyone is interested I can email it.

Forums

Due to hardware limitations I have attempted to combine the HAHcentral node for jeenode data collection and the URFrX sketch.

this has worked fine and I know get xap-serial messages from jeenodes and 433mhz rf devices.

jeenodes are still functioning fine so i'm no worse off than I was.

however, I know need to squirt the data from xap-serial into the xap-urfRx. Looking through the code it doesn't appear that I can direct a xap message towards it so i was wondering if there is any other way.

Brett, I noticed you have sucked in data from a file using a command like: $ ./xap-urfrx -i eth0 -s urf.in. 

Is it possible to do something similar, save the xap-serial data to a file then call the above command, although I suppose this means starting and stopping the daemon regularly. It all sounds messy.

any other thoughts?

 

thanks

Garry

Forums

This is a follow on from another post but needs a seperate thread as it may be of use to others :)

 

what i want to do is switch an RF socket on (via a tweet or a direct command from joggler/android) and for it to switch off 1 hour later automatically.

 

I do not do software, anyone any ideas how or has this been done before? (yes i did STF but couldnt find anything)

 

This is related to "boosting" a heating system remotely (or in my case locally) to max but just for 1 hour, SWMBO when she gets cold she wants HEATING NOW!

 

Dean