Vera - Smarter Home Control Forum

Advanced => Programming => Scene Scripting => Topic started by: TimAlls on May 09, 2011, 04:58:47 pm

Title: Luup Code Generator new version 1.028
Post by: TimAlls on May 09, 2011, 04:58:47 pm
Download the latest code generator:
http://www.box.net/shared/cs0bxr7ho1 (http://www.box.net/shared/cs0bxr7ho1)
The screenshots are from my original program....the new version is quite different and incorporates a view of all your scenes and devices. Take a look and give me feedback, hopefully this will help Newbies get started with custom Luup code......all copy and paste, no experience needed. I currently have one example and will be adding lots mnore very soon!
END EDIT.........................................

Hi All,
Take a look at the screen shots from the Luup code generator....the basics are tested and functioning perfect.
The first screen shows a dimmer being staged as the "if" input and the second shows the "If / Then" code being generated.
The "If / Then" tab has a pull down control where you select where the staged code is coming from.....eg dimmers levels, thermostat level, zone status, etc. and the second pull down box selects the actions to perform....eg trigger a scene, dim a light, etc.
Getting closer and would love feedback if you are interested.
This will help all of us who are new to Luup coding get started and learn more rather than be overwhelmed!
It will be easy to expand off of this idea with more function.
Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator
Post by: flanew on May 09, 2011, 06:26:15 pm
Nice job man !!!!   :D
Where can i get  that program to test too?
best regards.
Title: Re: Luup Code Generator
Post by: TimAlls on May 09, 2011, 07:26:53 pm
The code generator is still in developement but still useful even though it is not finished. I recommend you download the Vera Report Generator first which will give you device number and names for dimmers, scenes, and security zones. It will generate two reports....one is a table of your devices with device numbers and names and the other report will give you your raw JSON output.http://www.box.net/shared/jhq6sxojrm (http://www.box.net/shared/jhq6sxojrm)
Then download and play with the Code Generator.http://www.box.net/shared/es8jd1k323 (http://www.box.net/shared/es8jd1k323)
Labview runtime engine is required to run any of my programs.....free at http://ftp.ni.com/support/softlib/labview/labview_runtime/8.0/windows/LabVIEW_8.0_Runtime_Engine.exe (http://ftp.ni.com/support/softlib/labview/labview_runtime/8.0/windows/LabVIEW_8.0_Runtime_Engine.exe)

Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator
Post by: MNB on May 09, 2011, 09:03:19 pm
Tim, Great start... Like your tabs construction logical and makes sense.  :-* will play with it and provide any observations.
Title: Re: Luup Code Generator
Post by: djrobx on May 10, 2011, 10:43:31 pm
As a luup noob, this will be a tremendous help.    I've had a Vera forever, but only recently got communication gong to my alarm panel, which opens up interesting possibilities for doing things automatically when doors open and such.   Luup seems powerful but the syntax is pretty ugly, especially when you're spoiled with auto-complete in Microsoft IDE's. 

I look forward to trying this!
Title: Re: Luup Code Generator
Post by: ballroller on May 14, 2011, 06:44:25 pm
Really interesting work, Tim! While it's not finished, it's light years ahead of anything else out there. Especially when MCV told us that it was immensely complicated and probably not going to happen from them anytime soon.

I can't wait for the final polished version. If I can add my .02 from a basic user's point of view- the final version needs to be in a very simple format that anyone can use easily. Pick x,y,z etc  from a drop down menu and have a final code produced that can be copied and pasted into the LUUP tab on the UI (with directions). My point-don't assume we  know what you are talking about! Sometimes programmers talk to programmers at a level that doesn't translate to the bottom rung. And while it might work beautifully, the masses can't figure out what to do with it!

I'll be happy to be the guinea pig anytime you need me!
Title: Re: Luup Code Generator
Post by: TimAlls on May 14, 2011, 06:57:13 pm
Thanks for the feedback.....the next version is going to have a few very straight forward examples in it that will allow you to pick your devices and copy / paste the code. I am a little bogged down in learning the best way to handle time events. It won't be much longer so stay tuned!
I will need help from someone using thermostats and sensors, so let me know if your game! Just to intice you, give me the senario you want the code for and I will use it in my next version.
Regards
Tim
Title: Re: Luup Code Generator
Post by: ballroller on May 14, 2011, 07:23:35 pm
I have 3 thermostats (Trane) and 3 HSM100's. And Schlage locksets. Let me know what you want me to do and I'll do my best to help out.
Title: Re: Luup Code Generator
Post by: TimAlls on May 15, 2011, 12:43:47 am
A quick question on the thermostats.....do any of them read temperature in tenths of a degree. I was thinking about adding a trend chart for temperature but it would be more useful if it was more accurate than a single degree.
Thoughts?
Tim
Title: Re: Luup Code Generator
Post by: Ap15e on May 15, 2011, 09:04:31 am
Nice application.

Some of my devices have device IDs as high as 16800. LCG seems to limit the device ID to 255.

If LCG would parse Vera's configuration data, LCG could present the user with a list of device names (instead of device IDs).

'If and Time Then' and 'Read Variables' seem to be non-functional in the current release.
Title: Re: Luup Code Generator
Post by: ballroller on May 15, 2011, 09:31:30 am
My Trane's only read in 1 deg increments.


A quick question on the thermostats.....do any of them read temperature in tenths of a degree. I was thinking about adding a trend chart for temperature but it would be more useful if it was more accurate than a single degree.
Thoughts?
Tim
Title: Re: Luup Code Generator
Post by: TimAlls on May 15, 2011, 11:52:53 am
Nice application.

Some of my devices have device IDs as high as 16800. LCG seems to limit the device ID to 255.

If LCG would parse Vera's configuration data, LCG could present the user with a list of device names (instead of device IDs).

'If and Time Then' and 'Read Variables' seem to be non-functional in the current release.
I must have defined the IDs as byte, I will change them to I32 and look for others that might be limiting. Your system is a good test.....you have a lot installed!
You are correct on the non functioning tabs, I am working on them.
I am going to merge the report generator with the LCG and do exactly what you said.....drop down boxes that let you select you devices. It will make it really easy.
I have been studying another insteon controller and there cognitional logic.....in a thread you steered me to, lots of good ideas.
Thanks for the feedback
Tim
Title: Re: Luup Code Generator
Post by: guessed on May 15, 2011, 08:34:56 pm
A quick question on the thermostats.....do any of them read temperature in tenths of a degree. I was thinking about adding a trend chart for temperature but it would be more useful if it was more accurate than a single degree.
Thoughts?
Tim
Internally in MiOS, it's being "held" as an int (i4), so you'll see whole values only.
Title: Re: Luup Code Generator
Post by: TimAlls on May 15, 2011, 09:37:13 pm
A quick question on the thermostats.....do any of them read temperature in tenths of a degree. I was thinking about adding a trend chart for temperature but it would be more useful if it was more accurate than a single degree.
Thoughts?
Tim
Internally in MiOS, it's being "held" as an int (i4), so you'll see whole values only.
Is that true for sensors as well? In the Wiki they have example code of temperature in a xx.x format.
Regards
Tim
Title: Re: Luup Code Generator
Post by: guessed on May 15, 2011, 11:19:39 pm
The UPnP service definition also has it as i4 for the CurrentSetpoint value both as a StateVariabke and via the actions/methods
Title: Re: Luup Code Generator
Post by: TimAlls on May 15, 2011, 11:52:04 pm
Thanks Guessed, you are right as usual!
This example is what confused me:

local lul_temp=luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",3)
 if( (tonumber(lul_temp)<26.6
   and tonumber(lul_temp)>25)
   or tonumber(lul_temp)<23 ) then
     return false
 end

As it turns out the reason they used the fraction was to convert Celcius to Fahrenheit.
I was going to add trending to the temperature readouts from the thermostats, we do that on our yachts and it is very helpful. Maybe I will add it anyway and see if users like it.
Regards
Tim
Title: Re: Luup Code Generator
Post by: MNB on May 17, 2011, 09:17:57 pm
@TimAlls, I take it that you've not released any new Generator and/or report code of late?
Title: Re: Luup Code Generator
Post by: TimAlls on May 17, 2011, 10:52:07 pm
No, I am currently out of town....my daughters wedding!
I will have a revised Report Generator out tomorrow and by the weeks end I will have the new code generator. It took me a while to learn the time functions....I am brand new to this language!
You will like the new code generator.....it uses the report generator to feed drop down boxes for picking your devices. You pick the device name and the code picks up the device number. Time is displayed in real world values but the code is converted to seconds making it easier on the Vera....less calculations. Degree conversions for Celcius and Farnht.
A couple of questions for you....
Does your report Generator have scenes in the table that were generated by notifications? (assuming you are using notifications) Corrected
Second, can you give me an example of a Luup code you would like to generate? EG Turn the lights off in the living room if there is no motion and it is after midnight.
Let me know and thanks for testing out the software.
Regards
Tim
Title: Re: Luup Code Generator
Post by: ballroller on May 17, 2011, 11:41:21 pm
Well, I guess a congratulations is in order! Please pass along our congrats to the Bride from the Z-people!
Title: Re: Luup Code Generator
Post by: MNB on May 18, 2011, 01:14:52 pm
@TimAll, no rush, there are more important things in life than VERA and Wedding are one of them. Wish your son-in and daughter nothing but the best and my sympathy to your wallet ::) Mike
Title: Re: Luup Code Generator
Post by: TimAlls on May 18, 2011, 11:54:29 pm
You guys are too much! Thanks.
I am back in town and back to work.....more to come.
Tim
Title: Re: Luup Code Generator
Post by: michaelk on May 19, 2011, 05:54:22 pm
1) congratulations

2) MCV should pay you a consultants fee for doing their job for them. Some time ago and on more than once occasion they mentioned creating a code generator such as this because it was too complex to fix the back end and create the UI for it anytime soon.


THANKS!

I'm always amazed when a single human being whips out a solution so quickly and for free while a related commercial concern can't seem to get right. Very impressive!
Title: Re: Luup Code Generator
Post by: umtauscher on May 20, 2011, 04:12:02 am
Hi Tim,

thanks for your hard work.
Just to let you know:
The reporting tool doesn't get my switches, dimmers and sceenes right. There is an awful lot missing. What firmware version do you test with?
I am currently on 1.1.1047  on Vera 1 and am just scared to change anything.
I have attached the json report that is collected by the verareport tool.
Maybe this this helps
Cheers
Umtauscher
Title: Re: Luup Code Generator
Post by: umtauscher on May 20, 2011, 04:30:21 am
Hi Tim,

sorry, I didn't realize that you are already on version 3.
Maybe this thread should me closed then.
Thanks again
Umtauscher
Title: Re: Luup Code Generator
Post by: TimAlls on May 20, 2011, 09:32:00 am
Hi Tim,

sorry, I didn't realize that you are already on version 3.
Maybe this thread should me closed then.
Thanks again
Umtauscher
I am going to move all my latest versions to the top of the thread.....I will try to make things less confusing.
I will look at you JSON today and see what's happening.
Regards
Tim
Title: Re: Luup Code Generator
Post by: TimAlls on May 20, 2011, 11:11:46 am
Hi Tim,

thanks for your hard work.
Just to let you know:
The reporting tool doesn't get my switches, dimmers and sceenes right. There is an awful lot missing. What firmware version do you test with?
I am currently on 1.1.1047  on Vera 1 and am just scared to change anything.
I have attached the json report that is collected by the verareport tool.
Maybe this this helps
Cheers
Umtauscher
The Json file you sent me is totally different in format from the ones I am parsing.....It has a lot of []] brackets that don't add up. Does any one else have a Json file from an older firmware they can share?
Rather than clipping personal data out of the file you can XXXXXX over passwords etc..
Thanks
Tim
Title: Re: Luup Code Generator
Post by: umtauscher on May 21, 2011, 04:07:01 am
Hi Tim,

I did a bit of homework myself and formatted the json file more friendly to the human eye.
There are no missing or analigned brackets in it.
Maybe you'll have a look at it now to help you better analyze the structure of it. (I hate such interfaces by the way). I find it very confusing that the properties of the devices don't even have the same lineup. Sometime the name is the first parameter, sometimes the status.
Good luck.

Umtauscher
Title: Re: Luup Code Generator
Post by: TimAlls on May 21, 2011, 10:38:38 am
Hi Tim,

I did a bit of homework myself and formatted the json file more friendly to the human eye.
There are no missing or analigned brackets in it.
Maybe you'll have a look at it now to help you better analyze the structure of it. (I hate such interfaces by the way). I find it very confusing that the properties of the devices don't even have the same lineup. Sometime the name is the first parameter, sometimes the status.
Good luck.

Umtauscher
That's funny .... That's exactly what I did......separate it out and look at the formatting.
I have requested documentation from MCV on the format of the file because it has changed so much......my concern is will I be compatible with the next Firmware?
The part that surprised me about your file was that "[" brackets sometimes were not followed by the "]" opposite closeout bracket and that the section layout was totally different. In the new version there are Main sections that are easy to identify.......Rooms, Scenes, Devices, Categories, Etc.. My software grabs that section and separates it out. With the older format the sections around the devices is inconsistent......well let's say it just doesn't make sense to me. I will let you know what I find out. For reporting purposes I may have to switch to the XML output to maintain compatability. I chose this format so that I could use it to poll Vera and give updated information for my new UI......thanks for the feedback, it will help me build on a solid base, I am still new to this and learning.

As to the code Generator, I was slowed down a bit but will have something new to look at this weekend!

Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator
Post by: TimAlls on May 21, 2011, 07:12:14 pm
Hi all,
Just a quick update......
I have delayed releasing the new code generator. Thanks for your patience, it won't be much longer.
I am taking longer than projected because when I started testing the code I realized the need for more tools. The main thing that bugs me as a novice to Luup is trying to debug the code.....what went wrong!
The tool I am working on right now is a variable watch. It will be helpful for all of us to be able to see the variables in the code being displayed as they change. For example, I am working on the code for "run a scene if the door is open for a set amount of time". I want to have my program display all the variables in the code so that you can see the door status, watch the door timer, etc. Etc.. This will really help us see the code in action and debug it without pulling out the last remaining hair on our heads!
Stayed tuned.....good things are coming.
Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator
Post by: Henk on May 22, 2011, 08:18:34 am
@TimAlls

Tim, i was wondering, would your code generator be able to generate code like this?

http://forum.micasaverde.com/index.php?topic=6613.0
http://forum.micasaverde.com/index.php?topic=6309.0
or
http://forum.micasaverde.com/index.php?topic=6589.0

Im curious what your implementation could do!
Title: Re: Luup Code Generator
Post by: MNB on May 22, 2011, 12:05:08 pm
TimAlls, I agree with you it is frustrating to not being able to debug one code without trial/error. On thing to consider especially with time based code or duration code of somehow being able to shorten the duration in order to watch the code real time execute without having to wait for sunset/sunrise or 11:30pm. Patiently awaiting

With all this work that your doing, me thinks you should be looking for donations (shareware wise) once the code becomes more stable, I for one will donate... ;D

Mike
Title: Re: Luup Code Generator
Post by: TimAlls on May 22, 2011, 01:41:27 pm
@Michael,
I agree with what you are saying about watching time. My original ideas went out the window when I started writing and testing code.
I am a visual person.....show me what's going on! That's the way I learn. Just finished a variable watch routine and you sparked an idea....in addition to watching the variable it would be nice to change....or push time forward. I will work on that as well. One needs to create the code and accelerate the timing and watch events take place, other wise you will take days to debug the code.
I have to start another topic right now because I am creating new variables in the advanced tab of devices and using them in my code.that way I can watch them as well. Very easy but will it have any contrary reactions. I don't want to crash the little bugger!
More to come......
Regards
Tim
Title: Re: Luup Code Generator
Post by: TimAlls on May 25, 2011, 08:16:22 pm
Code Generator Version 1.0:http://www.box.net/shared/4sv0ocdfc8 (http://www.box.net/shared/4sv0ocdfc8)

Hi All,
I think the hard work is starting to pay off! The variable watch program is working well and it has allowed me to test code very quickly. I am able to place variables after every calculation or command if needed to see what is going on.
The Report Generator is now merging with the Code Generator....so they are the same from here on out.
The idea is that we parse the system and create a unique set of tables to draw off of for our drop down boxes.....in other words you don't have to remember your ID numbers, it remembers for you.
This is the first of the series I will be posting for code generation. This is version 1.0 and it needs you to try it out and give me feedback. Goto the tab for code and follow the line by line instructions...it walks you through a step at a time. When you are done you will have a scene that will operate only from timeA to timeB. You will be able to adjust the time by using the Vera UI....under the advance tab for the device. You will be able to watch variables update every minute when the scene timer runs and you can see the results of the math used.....
Check it out. If it makes sense and is easy to use, then I will push on.
Thanks for your help in this project.

Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator
Post by: MNB on May 25, 2011, 10:14:40 pm
@TimAlls, question I notice that both the report and code generator for some reason only display devices A-L all of my M-Z lettered devices are missing ??? Mike
Title: Re: Luup Code Generator
Post by: TimAlls on May 25, 2011, 10:33:12 pm
@TimAlls, question I notice that both the report and code generator for some reason only display devices A-L all of my M-Z lettered devices are missing ??? Mike

I must have screwed something up...ha. I have your JSON.....I will plug it in and test it.

I would love it if you could look at the presentation of the code tab and give me feedback. I want to lay a foundation for a lot of code to be placed so now is the time to make adjustments. As a user trying to
learn code what could be better. Don't worry about nit pickin....it all helpful and you won't step on my toes. Same for the rest of you.
Regards
Tim
Title: Re: Luup Code Generator new version 1.024
Post by: TimAlls on May 29, 2011, 01:08:35 am
Here is the latest:
Rebuilt the parsing routines to read older Firmware.
Added new reports.....auto export straight into Excel for easy formatting
Added new UserData2 report
Added settings file to remember your IP
Fixed camera missing : on IP address
Reads German Json files
Easy drop down boxes for Variable Watch
Easy drop down box that fills in the Code.....just copy and paste

I still need feedback on the code generator......try it out.

Regards
Tim Alls
AllSeas Yachts
Title: Re: Luup Code Generator new version 1.024
Post by: umtauscher on May 29, 2011, 07:58:33 am
Hi Tim,

I finanally had the time to check it out.
Its much better now, but my older firmware still seems to have a will of its own.
I get only 1 room, while as you can see from the snippet of usredata2 there are 8.
I suppose the json interface of my firmware simply doesn't do it.
Thanks
Umtauscher
Title: Re: Luup Code Generator new version 1.024
Post by: TimAlls on May 29, 2011, 09:37:25 am
Hi Tim,

I finanally had the time to check it out.
Its much better now, but my older firmware still seems to have a will of its own.
I get only 1 room, while as you can see from the snippet of usredata2 there are 8.
I suppose the json interface of my firmware simply doesn't do it.
Thanks
Umtauscher
The older firmware doesn't have as much information as the new firmware. I rewrote the coding to make sure the devices and scenes would come through. You should be able to run the Variable Watch as well as the new Code Generator. Just ignore the rooms and categories for now.....
I hope you find the program useful. I am adding more code examples as well as lock support today.
Just an interesting note:
When I ran your HTML reports using Google Chrome it ask me if I wanted it to translate the file from German to English......I said why not, and it automatically translated everything perfectly!

Ich hoffe, Sie genie├čen die Software

Regards
Tim
Title: Re: Luup Code Generator new version 1.024
Post by: Henk on May 29, 2011, 10:00:45 am
Hi Tim,

So you went for converging the Report tool and the Code generator? Not bad!

Here are a few remarks:

1. HTML report for devices
   - No header line for colums
   - Only 1 device is shown
   - Difficult to read dus to narrow columns

2. HTML report for scens
   - Clearly readable (well designed table)
   - No colum headers (what value is what?)

3. Rooms tab
   - Due to fixed column width not all data is readable to humans.

(option to have columnwidth scalable to contents (up till a max and then start to wrap text?)

As for the code page, after i have had some time to play with it ill write a How To following your 7 steps.
Maybe its usefull to get some of your work listed here:
http://wiki.micasaverde.com/index.php/Scripts_for_scenes

--edit--
Where are the settings (on IP) stored? The app says c:\settings.txt but i cant locate the file there.
What if i needed to change the IP manually?
Is it doable to store the settingsfile in the same path as the app?



Title: Re: Luup Code Generator new version 1.024
Post by: TimAlls on May 29, 2011, 10:22:44 am
Thanks Henk,

Code: [Select]
1. HTML report for devices
   - No header line for colums
   - Only 1 device is shown
   - Difficult to read dus to narrow columns
I added the Excel output to help with the problem. The JSON outputs vary widely as to the column formats and I can't keep up with the variations from Firmware to firmware. My solution is transfer the information into a spreadsheet and let the user edit the format to fit his system and firmware. I want to move on to the bigger task at hand......code generation and a PC based UI for touchscreen computers and laptops.
Please explain only one device is shown....Is the program not detecting all your devices?
I rewrote my code to read older firmwares so I am hoping I didn't break something in the process!

I regards to Coding, I am new to Luup coding so I am relying on code donations from other programmers....no offers yet.
I am hoping some Newbies will try out my example and let me know if the program helps bridge the fear of adding Luup code to their scenes.
We will see!

Regards
Tim
Title: Re: Luup Code Generator new version 1.024
Post by: Henk on May 29, 2011, 10:26:34 am
Thanks Henk,

Code: [Select]
1. HTML report for devices
   - No header line for colums
   - Only 1 device is shown
   - Difficult to read dus to narrow columns
I added the Excel output to help with the problem. The JSON outputs vary widely as to the column formats and I can't keep up with the variations from Firmware to firmware. My solution is transfer the information into a spreadsheet and let the user edit the format to fit his system and firmware. I want to move on to the bigger task at hand......code generation and a PC based UI for touchscreen computers and laptops.
Please explain only one device is shown....Is the program not detecting all your devices?
I rewrote my code to read older firmwares so I am hoping I didn't break something in the process!

I regards to Coding, I am new to Luup coding so I am relying on code donations from other programmers....no offers yet.
I am hoping some Newbies will try out my example and let me know if the program helps bridge the fear of adding Luup code to their scenes.
We will see!

Regards
Tim

The HTML report only shows 1 device (no others) in my particular case the DAD device.
As you might remember, im on 1.1.1245

more remarks;
Unable to close the app unless by going to the first tab and click quit... major annoyance!
Title: Re: Luup Code Generator new version 1.024
Post by: TimAlls on May 29, 2011, 11:09:52 am
Henk,
Give the DAD control a name.....I suggest Z.DAD
This will place the device at the bottom. This plugin display tons of great information. Unfortunately, the JSON outputs all the data as well making a Display Table  fun to deal with when most devices only have a few pieces of data.
Try my new Excel Output if you have Excel....it's a much nicer output than HTML.

Your table is there.......you have to scroll to the right to find it!
I will be setting up a special place for the DAD information to go. Most likely it should have an entire table to itself.

I will change the stop button.....thanks for the feedback.

Regards
Tim
Title: Re: Luup Code Generator new version 1.024
Post by: Henk on May 29, 2011, 11:18:43 am
Henk,
Try my new Excel Output if you have Excel....it's a much nicer output than HTML.

How about creating comma seperated value lists (.csv) so any spreadsheet can open it, be it excel, calc or whatever)
Title: Re: Luup Code Generator new version 1.024
Post by: TimAlls on May 29, 2011, 01:19:34 pm
Henk,
Try my new Excel Output if you have Excel....it's a much nicer output than HTML.

How about creating comma seperated value lists (.csv) so any spreadsheet can open it, be it excel, calc or whatever)
Sounds like a good idea.....

I found several small bugs and fixed that as well as giving you options on the way you view your Device Data......this will help with older firmwares
I moved the quit button to where it is always seen.

Latest Version: http://www.box.net/shared/rq4cvjf5e0 (http://www.box.net/shared/rq4cvjf5e0)

Regards
TimAlls
Title: Re: Luup Code Generator new version 1.027
Post by: ballroller on May 29, 2011, 04:02:15 pm
The Excel option is wonderful!

My Schlage locks don't show up as an option in the code generator examples.

Is there a way to show the actual scene information other than whether it's active or not? IOW, what the scene is supposed to do?
Title: Re: Luup Code Generator new version 1.027
Post by: ballroller on May 29, 2011, 04:12:55 pm
Just saw something else- A scene is showing as active (showing "1") although the timer is turned off on that scene. Am I reading this correctly?

Edit to add: The code report generator is showing incorrect Device ID matchup. The "Pick Device" name doesn't match the Device ID, and the data as such is incorrect.

Ie My front porch light is actually device ID #7 and is showing up as #8. It also shows the temperature is set at 70 and it's cooling!! And I don't think I have a Device ID #8 at all...
Title: Re: Luup Code Generator new version 1.027
Post by: TimAlls on May 29, 2011, 07:05:12 pm
Just saw something else- A scene is showing as active (showing "1") although the timer is turned off on that scene. Am I reading this correctly?

Edit to add: The code report generator is showing incorrect Device ID matchup. The "Pick Device" name doesn't match the Device ID, and the data as such is incorrect.

Ie My front porch light is actually device ID #7 and is showing up as #8. It also shows the temperature is set at 70 and it's cooling!! And I don't think I have a Device ID #8 at all...

 { "name": "Front Porch Light", "altid": "7", "id": 8, "category": 3, "room": 6, "parent": 1, "status": "0", "heatsp": "70" }
                                                                (it is easy to mix up altIDs with ID's.....your front porch light is #8)

As for the thermostat and scene, search your Json Report and it will show if the program is reading incorrectly.
EG: { "name": "Den Thermostat", "altid": "5", "id": 6, "category": 5, "room": 22, "parent": 1, "mode": "CoolOn", "temperature": "71", "heatsp": "63", "coolsp": "69", "status": "1", "humidity": "67", "state": -1, "comment": "" }

I give you the Heat Set Point (63) and the CoolSet Point (69), temperature (71) and the Mode ("CoolOn")

The purpose of the Example One Code generator is to set a variable called "Between?" to yes or no. Let me explain where I am going from here.....
I believe that code writing for those of us new to Luup (me included) needs to be modular. You create one piece of the code and test it, play with it, an learn to understand how it works. In this case, the larger project could be :
If the door sensor is tripped and it is Between Time A and Time B, and there is no motion, then turn on Light A,B,C and D and blink the porch lights on and off.

That is a lot of code to write for a Newbie. So here is my proposed method:
Write code that sets a variable if between time A and Time B (Var-1)
write code that sets a variable if the motion detector has shown no motion for X minutes (Var-2)
set up a scene and code to blink the light on and off (Sc-1)
create a scene that turns on light A,B,C, and D(Sc-2)

after all this is tested and working write a timer scene that has the following Luup code added:
If tripped and Var1 and Var-2 (all true)
then    turn on scene Sc-1 and Sc-2
else return false

The example is not real code .....but the method is easy to follow and debug one step at a time.
Thoughts?

I hope that makes sense!

Added Locks: http://www.box.net/shared/cs0bxr7ho1 (http://www.box.net/shared/cs0bxr7ho1)

Regards
Tim






Title: Re: Luup Code Generator new version 1.028
Post by: ballroller on May 30, 2011, 12:12:58 am
Okay, I did get confused between ID and altID, sorry. And then the temperature and heat mode threw me off-until I realized that THAT data was included in my advanced file- for what reason I don't understand. Why would a light switch show temps and heating mode??

I will look at the Json report and see if there is some strange data in there- if my eyes don't roll back into my head before I'm done!

Thanks.

Edit: thanks for adding the locks.
Title: Re: Luup Code Generator new version 1.028
Post by: TimAlls on May 30, 2011, 01:54:19 am
Quote
Okay, I did get confused between ID and altID, sorry. And then the temperature and heat mode threw me off-until I realized that THAT data was included in my advanced file- for what reason I don't understand. Why would a light switch show temps and heating mode??
I was hoping you could explain the light!
Tim
Title: Re: Luup Code Generator new version 1.028
Post by: ballroller on May 30, 2011, 09:17:06 am
I can't. Nor can I explain why my Garage Door Lock-inside is showing a temp of 66, and my main patio lights with a temp of 158!!
Title: Re: Luup Code Generator new version 1.028
Post by: oTi@ on May 30, 2011, 09:24:53 am
I can't. Nor can I explain why my Garage Door Lock-inside is showing a temp of 66, and my main patio lights with a temp of 158!!
Your patio light must be overheating. ;) Do you also see these values in UI4, say in the Advanced tab of the device?
Title: Re: Luup Code Generator new version 1.028
Post by: ballroller on May 30, 2011, 09:35:29 am
Yes, it's showing up in the advanced info. Weird.
Title: Re: Luup Code Generator new version 1.028
Post by: TimAlls on May 30, 2011, 09:42:40 am
Yes, it's showing up in the advanced info. Weird.
Perhaps your dimmers report back the dimmer temperature.....a handy thing if they do! What brand of dimmers?
The 158 degrees would be correct if you have a lot of lights connected.
Tim
Title: Re: Luup Code Generator new version 1.028
Post by: ballroller on May 30, 2011, 09:58:24 am
The main patio light switch is not a dimmer. It's a Leviton switch-not sure if it's the 5 amp or 15. It only has 2 LED lights drawing max 15 watts!

I knew it was going to be warm out today, but....
Title: Re: Luup Code Generator new version 1.028
Post by: oTi@ on May 30, 2011, 10:17:18 am
It's a Leviton switch-not sure if it's the 5 amp or 15.
No temperature on the VRS05, or VRS15.
It could be that some wrong coding / Luup experiments got those variables in there. Are those values changing at all?
Title: Re: Luup Code Generator new version 1.028
Post by: ballroller on May 30, 2011, 10:24:55 am
The stateid is changing for the temperature sensor, but the temp remains constant at 158.. The serviceid shows TemperatureSensor1 which is quite odd for a switch!

Title: Re: Luup Code Generator new version 1.028
Post by: TimAlls on May 30, 2011, 10:46:27 am
It's a Leviton switch-not sure if it's the 5 amp or 15.
No temperature on the VRS05, or VRS15.
It could be that some wrong coding / Luup experiments got those variables in there. Are those values changing at all?

Most likely coding with the wrong ID numbers. If you read or write to variables in a device that doesn't have those variables, it will create them for you. They will show up in the advanced tab and as far as I know can't be deleted. It is nothing to worry about.
The variable watch tab of my program will pull up everything variable the device has and gives
you the values. Have you tried any Luup code regarding your thermostats? The variables you are seeing are normal thermostat variables.

Example: go into the Luup tab of a scene and add " luup.variable_set("urn:user-com:serviceId:myvar","Ex1_Between?","No",76) "
    substitute a valid device number into 76.....save luup......refresh UI
activate the scene and the variable "Ex1_Between?" shows up automatically in my variable watch tab or with the standard UI look under advanced tab for that device.

Regards
Tim
Title: Re: Luup Code Generator new version 1.028
Post by: Henk on June 01, 2011, 12:48:07 pm
Suggestion to either move this thread to Vera Luup & Development and/or lock it as its replaced by the 1.005 thread here
http://forum.mios.com/index.php?topic=6515.0
Title: Re: Luup Code Generator new version 1.028
Post by: TimAlls on June 01, 2011, 09:43:21 pm
This software has merged with a larger one that now does Reports, Code, and UI control of devices. The software is functional but still under Development.
Goto this thread for the latest:
http://forum.micasaverde.com/index.php?topic=6515.0 (http://forum.micasaverde.com/index.php?topic=6515.0)