I have never programmed lua nor have I ever done anything with html, js or upnp. So please be kind and forgive my ignorance if I made any obvoius mistakes.
During the last 2 hours, I have modified the L_sPhone.lua plugin to show the state of a motion sensor which is missing in the actual implementation, amongst other things.
For installation you only have to load the L_sPhoneUI.lua in the devices/luup files and check restart Luup.(I had to zip the file because uploading lua isn’t allowed.)
After that you have the Tripped state of a motion sensor on your smartphone.
Note:
I used the imagefiles that where already available in the cmh/images directory so I didn’t have to modify any images in the flash-rom except letting Vera upload the new plugin. (Personally I would have preferred putting the images into the iPhone_file directory because all other images for the plugin reside there too.)
but don’t think folks got to completing it. Note that any changes to this file will likely need to be redone as new Vera firmware versions are released, just a heads up.
I’ve also gone ahead and added [tt].lua[/tt] as an acceptable File upload type so it’ll be easier next time
it must have been the weekend for polishing the smartphone interface.
i made a very similar change so that the red or green circle gif would show the status of my door sensors. however, i didn’t make the tripped indicator (the red or green circle) a link. would there be a reason to do this? i didn’t because it is already hard enough to click the right link on my Storm2, so i figured a third link in that area would make it more difficult.
just wondering if I missed something when i made my modifications.
First of all, I see the stream camera has been removed. Any reason for that?
Then, I did two new versions. The first one has only slight changes:
[ul][li]added some missing [font=courier]local[/font] kewords.[/li]
[li]wrapped the whole code in a [font=courier]do … end[/font] block, that allows for better encapsulation. For example, [font=courier]html_header[/font] is a local variable for the whole block, almost like a global but isolated from globals from other plugins (which run on the same Lua context).[/li]
[li]Used ‘long string’ syntax ([font=courier][[ … ]][/font])where appropriate.[/li][/ul]
I’m attaching this version. Should be equivalent to the last contributed one, please test and comment.
… And here’s the other version I did. This one has a bigger restructuring, and is so far incomplete. I’m attaching it mostly to show where i’m going in terms of Lua code, check the first few functions to see this modifications:
[ul][li]Added a simple [font=courier]string:template(vars)[/font] function.[/li]
[li]Replaced the [font=courier]lul_html = lul_html … “…”[/font] with [font=courier]table.insert (out, "…')[/font], where ‘out’ is a table of strings that get concatenated at the very end ([font=courier]return table.concat (out)[/font]). This is more efficient both in terms of time and space. Especially noticeable on long loops that add content to the page.[/li][/ul]
As said, it’s still unfinished. i’m posting mostly to hear some feedback.
Oh, how I wish we had a version control system at the moment to easily compare versions…
Anyway, our changes were relatively simple. We tried to not change the code structure or its flow, just add the missing functionality with the limited intervention.
So, umtauscher used the version of the plugin available at that moment and just modified [tt]lug_sPhoneRequest_sensor()[/tt] function to add the sensor’s tripped state indicator in form of green/red dot. And I added two new functions - [tt]lug_sPhoneRequest_temp()[/tt] and [tt]lug_sPhoneRequest_bright()[/tt], as well as the necessary hooks into the [tt]lug_sPhoneRequest_room()[/tt] function where it checks for [tt]DEVICE_CATEGORY_*[/tt] values of the devices…
I see that you are now rewriting parts of the plugin to be more elegant and easy to read, which is always appreciated. I’m still not done reading through your changes yet, so I’ll provide my feedback later. Thanks.
Hello
do you have instruction how to use this plagins?
i’ve instaled it but i don’t know how to connect to it from my local network (i have problems with findvera.com on the scope on my isp and i use dynamic dns)
please provide for advantage guide of how to connect to it
Just replace the ip-address (192.168.1.4) with the one of your Vera.
The sceenes are a bit messed up in the rooms now, but I really don’t mind any more. I use SQRemote instead.
Hope this helps