Hi, Can someone point me to a guide of how to setup of the twitter access, and the command structure for sending tweets, I cannot seem to get it to work!
Also a list of tweek examples would be useful to see what can be done thro twitter.
The first link I gave has an example of what you send from twitter. Don't forget to include the command prefix
To see xAP traffic you need a viewer, I use a windows PC, so xFxViewer from
http://www.erspearson.com/xAP/xFx/viewer_main.htm
and to use that you need a hub, also from Edward
http://www.erspearson.com/xAP/xFx/hubs_main.htm
The hub must be running first.
There is also a xAPSnoop application which is similar but I have never used that runs directly on the Livebox
So, logged into my kevinshouse account I tweeted HAH Relay 1 on, where HAH is my command prefix. This results in a message as seen in Viewer
xap-header
{
v=12
hop=1
uid=FF00D900
class=alias
source=dbzoo.livebox.1.Twitter
}
command
{
text=Relay 1 on
}
( Note my livebox has an instance of '1')
You need to know if this is working for you before you do much else
Next you need an Alias Interpreter, and I confess I haven't used this yet
The link in the twitter section goes to the wrong version of plugboard, but I know there is an example interpreter on your livebox in /etc_ro_fs/plugboard/samples called aliasApplet.lua
But hopefully someone who knows a bit more will jump in. we can record the steps and add the full example to the wiki.
kevint
To answer your question YES if you refresh the web page.
Here is a diagram that explain how all the bit function together.
If somebody want to draw this up nicely in visio we can post it to the twitter wiki page.
I can hand draw faster than anybody could do this in a computer :)
Brett
The plugboard is described at http://www.dbzoo.com/livebox/hah_plugboard_v2
It allows you to register an interest in a specific xAP message (or set of messages) and will then perform an action when the message is spotted on your network. As well as actions based on messages, you can setup timers which also trigger actions.
Using the plugboard is a bit more complex than using some other HAH facilities, in that you need to write some scripts in Lua (or use a script that somebody else has written). You must also enable the plugboard itself (automation/assists tab on the UI).
It's very flexible and hugely powerful. Kinda like an http://www.ifttt.com/wtf for the HAH.
Derek
Because the sample's are burnt into the firmware and can't be adjusted. You need to copy them into /etc/plugboard before they can be executed and editted.
Brett
Plugboard needs to be activated within the web GUI so that it loads and runs the scripts
Why is your script called relay_auto_off.lua ? This will not be picked up all scripts should be of the form xxxApplet.lua - Are you running build 306 ? Where did you get this example from?
Get yourself onto the latest release: http://www.dbzoo.com/livebox/upgrades_backups
Brett
Instead of posting a list of files you could also indicate where you are looking to save me asking.
Where are you looking ? Because in /etc_ro_fs/plugboard/samples you will not find that list of files.
I bet you upgraded from an OLD release and these are in /etc/plugboard/samples if this is the case then you might as well DELETE them all as they will NOT run as they are all v1 scripts which are not compatible with the new v2 plugboard engine.
Brett
I have copied aliasApplet.lua from /etc_ro_fs/plugboard/samples to /etc/plugboard.
I my case I copied it via my PC so I could modify the addresses to include 'instance',
ie
from dbzoo.livebox.Controller to dbzoo.livebox.1.Controller
and
dbzoo.livebox.Twitter to dbzoo.livebox.1.Twitter
(You may not need to do this editing)
Then I restarted plugboard from the WebGUI
From my 'kevinshouse' twitter account I sent the command
'HAH relay 1 on' where HAH is the command prefix
This produced a a xAP message of
xap-header
{
v=12
hop=1
uid=FF00D900
class=alias
source=dbzoo.livebox.1.Twitter
}
command
{
text=relay 1 on
}
which in turn produced a message from plugboard of
xap-header
{
uid=FF00D800
source=dbzoo.livebox.1.Plugboard
hop=1
class=xAPBSC.cmd
target=dbzoo.livebox.1.Controller:relay.1
v=12
}
output.state.1
{
id=*
state=on
}
turning the relay on and producing a xAPBSC.event message of
xap-header
{
v=12
hop=1
uid=FF00DB60
class=xAPBSC.event
source=dbzoo.livebox.1.Controller:relay.1
}
output.state
{
state=on
displaytext=Relay 1 on
}
Note that there is a small delay between entering the command in Twitter and the Livebox Twitter app picking it up.
Also I need to check wether the Twitter command is case sensitive
<edit> Be aware that the Livebox deletes the twitter command from the twitter account after it has been actioned. This is to allow the same command to be issued again, but it also means that there is no record in the twitter account of the commands sent <end edit>
I will write this up for the wiki later
kevint
Check in above folder.
Lawrence given you are struggling at this basic level I can give you the command however I feel you are going to struggle all the way along unless you are spoon fed the exact commands to type in. If others are willing to help you then you may be in luck however this project is about discovery and learning for yourself, this is half the fun, the HAH isn't a turnkey system you need to do some work to enable various features.
I've looked at http://www.dbzoo.com/livebox/twitter wiki page and the EXACT command you need to enter is there in a large GREEN box that is hard to miss. As you are having trouble reading let me reproduce it here for you.
cp /etc_ro_fs/plugboard/samples/aliasApplet.lua /etc/plugboard /etc/init.d/xap restart plugboard
On those directories:
- /etc is Read/Write
- /etc_ro_fs as the name implied is READ-ONLY.
Brett
You need to copy from etc_ro_fs/plugboard/samples to etc/plugboard
Try this and let us know how you get on
Garry
Just noticed Brett was replying as I was tying. one step ahead as usual ;)
How are you doiing with this Lawrence?, did my write up above make sense in the end?
kevint
Lawrence. You need the aliasApplet script which is in the examples folder.
This has been mentioned a few times in this thread and on the wiki. Suggest you reread both to understand the workings before playing too much more. You will be able to do much more with it if you take time now to undestand how it all plugs together
Garry
When I try to enable the Twitter service through the HAH browser I get an error that:
Authorisation has not been setup
What do I need to do to enable this?
On the same hah web page there is a big authorise with twitter button!
It is also discussed on the wiki detailed in this post
Garry
As I say, pressing this just gives an error. I see the Wiki has now been modified to suggest using a different browser as this may be the cause of the problem.
whilst noobs quesitons may sometimes seem a bit dense even I couldn't overlook the button marked 'authorise with twitter'
The fact that I posted a question to this clearly points to it not working as expected so your answer was not very helpful.
Jim, I wasn't trying to be rude but your post says you tried to enable twitter NOT authorise it. From your post it looked as though you were enabling it before authorising the HAh. This would also explain your error message.
If you are saying the authorisation step is not working then this will need looking at.
I will take a look at the authorisation on my system when I get home.
Maybe more detail in what you have tried and the exact results you got, with screenshot if poss, would help diagnose the issue without confusion Garry
Jim I have just tried on my system and twitter authorisation works fine can you please confirm that you get transferred to the twitter website?, does the authorisation work okay at this stage? When do you see the error message is this when you click the enable button on the HAH web GUI? Garry
Jim that wiki page regarding using a different browser for twitter authorisation hasn't been recently updated. The section you are referring to regarding issues with IE8 was added on the 27-Jan-12. I would find it unusual that twitter auth has suddenly broken.
Brett
Gary:
No, I do not get transferred to the Twitter site when I press the button. (I will try a different browser)
Brett:
I maybe misinterpreted the message:
'If you are struggling to get OAUTH to work on when using IE8, try using another browser, eg Chrome'
As I didn't know the expected behaviour of pressing the 'Authorise with Twitter' button.
After getting the error reported above I tried clicking on OAuth and that link worked ok, (takes me to the OAuth site) so I misinterpreted the message regarding browsers as to have something to do with this.
I now realise you mean if the 'Authorise with Twitter' button does not take you to the Twitter page try a different browser, (I think! is that what you mean?)
As the link works ok for me
Garry
OK, using Chrome I was able to authenticate with Twitter.
However, I don't think that /etc/plugboard/samples exists
I tried using 'cd' to get to plugboard, but 'ls' only shows the plugboard.lua file.
IE I haven't got the alias file so I can't do the next step:
I set the command prefix to 'hah', so now in twitter if I type 'hah relay 1 on'
Similarly for Google Calendar. I have yet to see any evidence that the event is triggering properly.
I checked that the event was enetered as given and entered this directly as a message using xfx which switched the led as reuqired.
However, I have set an event and then waited while the time went past the start time and nothing happens.
If I change the password on google on the browser to something incorrect, then resave as the correct password will this force the HAH to poll Google Calendar and cache the next hour's events, or do I have to wait an hour after enetering any event before HAH polls Google Calendar?
Hi Jim,
Well done on hanging in there and getting this far, it really is well worth it.
Looking at your post above, I think you may have missed typed the "cp" command, I've copied it below, from the wiki, for clarity.
cp /etc_ro_fs/plugboard/samples/aliasApplet.lua /etc/plugboard /etc/init.d/xap restart plugboard
The first line copies the aliasApplet.lua script from the "/etc_ro_fs/plugboard/samples" folder, this part of the HAH filesystem that can't be updated, hence the "_ro_" at the start. By placing it in the /etc/plugboard folder, and by the fact that is has "Applet.lua" at the end of it's name, it will be executed everytime the pluboard is started, usually at boot up.
The next line restarts the plugboard subsystem, saving you the hassle of a reboot.
This Alias script is key to Google as well, so once you've got this right it opens up lots of possibilities for you.
Karl
Jim
The alias scripts and the samples are mentioned:
- http://www.dbzoo.com/livebox/hah_plugboard_v2#more_samples
- http://www.dbzoo.com/livebox/twitter (and how to install also mentioned here for good measure)
Twitter and Google require an Alias interpreter as documented on these links:
The alias engine is discussed in more detail here:
Many of these questions have been asked before, which resulted in the wiki being updated, if you do a little searching you will find the answers. Please take the time to read the documentation it may not be step by step but its certainly adequate if read.
Brett
The alias script works for rf and relays only. If you want to use this for arduino stuff. Eg LED switching you will need to modify the script.
It is fairly intuitive if you take a look at it and relatively easy to modify to suit your needs
Garry
I am 100% positive I entered:
cp /etc_ro_fs/plugboard/samples/aliasApplet.lua /etc/plugboard /etc/init.d/xap restart plugboard
correctly, but I will try again tonight.
However, I'm still unclear as to why typing:
cd /etc/plugboard
ls
doesn't show me the /samples directory, should it not be possible to see this?
I must have made a boob at some point though as I now have
/plugbaord listed on /etc
again when I try to cd to this it gives an error
if i type:
rm plugbaord
will this remove this?
And finally, if I fail to find the aliasApplet.lua can I simply create it in vi in plugboard directory according to: http://www.dbzoo.com/livebox/twitter#alias_interpreter ?
Attachment | Size |
---|---|
Capture.PNG | 22.12 KB |
You need to get the Samples from /etc_ro_fs/plugboard/samples. NOT /etc/plugboard/samples as these are version 1 (I think)
Brett, this has caught me out in the past. Any chance of removing them during an update to save confusion? Garry
Success!
not sure what I did wrong first time with the cp from /etc_ro_fs/plugboard/samples command, but it worked OK this time.
Once I'd remembered to restart plugboard I was able to tweet and see the message arrive in xfx viewer.
Now that I have been through the process I'm really impressed by what can be done and that all of this is provided free.
With regards to Google Calendar functionality, does the alias script mean that the HAH recognises Google Calendar events as twitter events and handles them in the same way?
(edited before seeing your response Garry)
I asked about how arduino:led funtionality could be added to the script. I've now seen there is the script section of the forum so will trawl that today.
The alias script handles alias style xap messages regardless of their origin.
Google and twitter send alias messages so hare handled.
If I get chance tonight I could
Maybe have a go at adding led support for trial purposes, it wont be pretty but will function ;)
Garry
Try modifying you /etc/plugboard/aliasApplet.lua script with the following, I've highlighted the additional code. This hasn't been tested, and my programming skills are rubbish, but I think it will work. Don't forget to restart the plugboard after saving the changes.
pat={
-- Add a new pattern match for the Arduino LED
[rex.new("(led) (on|off)")]=function(m) led(m) end,
[rex.new("(relay) ([1-4]) (on|off)")]=function(m) rfRelayCmd(m) end,
[rex.new("(rf) ([0-9]+) (on|off)")]=function(m) rfRelayCmd(m) end,
[rex.new("tweet (.*)")]=function(m) tweet(m) end
}
-- The Arduino LED function
function led(t)
local addr1,state = unpack(t)
bsc.sendState(string.format("dbzoo.livebox.Controller:%s",addr1),state)
end
function tweet(m)
local msg = unpack(m)
bsc.sendText("dbzoo.livebox.Twitter",msg)
end
This should enable you to send the commands "led on" or "led off", and if you're using the example from the wiki to control the LED, so the endpoint is "dbzoo.livebox.arduino:led", it should work, fingers crossed.
Karl,
Thanks for this. Was gonna have a go tonight but you beat me to it.
Should the Controller not be Arduino though in the Bsc send state?
Cheers
Garry
Thanks Garry, I did mention that I can't program ;) Does this looks better :-
-- The Arduino LED function
function led(t)
local addr1,state = unpack(t)
bsc.sendState(string.format("dbzoo.livebox.arduino:%s",addr1),state)
end
I wondered about that so I must be beginning to understand the logic of these scripts!
Thanks for the help.
My wife is beginning to become slightly anxious about exactly what it is I plan to control around the house and how much wiring is goingto be involved!
Blinking an LED via Twitter or Google has so far elicted, 'that's nice dear'
(I wouldn't mind, but she trained as an instrumentaiton technician in France and worked for the ESA and Peugot at the start of her career. I guess my ham-fisted dabbling looks pretty unsophisticated to her eyes).
OK, I edited the aliasApplet.lua script as suggested, (with the correction).
Now when I send a tweet I see this message being relayed:
xap-header
{
v=12
hop=1
uid=FF00D900
class=alias
source=dbzoo.livebox.Twitter
}
command
{
text=led on
}
But no repsonse from the led
Any ideas where the error is?
Do you see the message sent to xap serial that the applet should have sent! The above message is from xap twitter and is present regardless of the script.
You should see another message sent from plugboard to xap serial. I think!?
Garry
The modification you did to the alias script does not talk to xap-serial directly it will send a xAPBSC.cmd with a state event to another LUA applet acting as the BSC/Serial gateway.
The gateway applet when it receives the xAPBSC.cmd with the state will communicate to xap-serial with a Serial.Send. This is the same applet that is responsible for opening up the serial communication channel with the correct baud etc that you would have previously got working.
Brett
Sure. Just create an alias entry for this in the aliasApplet
pat={
[rex.new("(relay) ([1-4]) (on|off)")]=function(m) rfRelayCmd(m) end,
[rex.new("(rf) ([0-9]+) (on|off)")]=function(m) rfRelayCmd(m) end,
[rex.new("tweet (.*)")]=function(m) tweet(m) end,
["reboot"] = function() os.execute("reboot") end
}
Brett
Hi again,
I haven't been able to get into this for a while and I'm struggling to remember what I had learned so far.
However, I did modify the aliasApplet.lua script as directed to allow messages to be sent to the Arduino and hence the LED.
Unfortunately it seems like this isn't working.
When I send a tweet I see the twitter message arive OK, but then nothing is done with it.
What could be the problem? and how should I troubleshoot it?
Thanks
This is the Twitter sestion of the wiki
http://www.dbzoo.com/livebox/twitter
And here are some scripts I use all the time on my box
http://www.homeautomationhub.com/content/twitter-scripts-messaging-schema
kevint