-
ChatGPT samples:
Me:
Tell me about an iot program called openLuup.
It:
OpenLuup is an open source home automation system that is built on the VeraLuup platform. It is designed to be easy to install and configure, and provides users with a powerful and versatile way to control their home automation devices. OpenLuup offers a wide range of features, including support for many popular home automation devices, scheduling, scripting, and integration with other services. OpenLuup is designed to be customizable, allowing users to create their own home automation systems. It is an excellent choice for those looking to create their own home automation system without spending a lot of money.
Me:
Write an iot program using openLuup.
It:
--openLuup IoT Program-- -- Initialize Variables -- local device_id = "MyHomeDevice" local temperature_sensor_id = "MyTemperatureSensor" local temperature_threshold = 75 -- Create Devices -- luup.create_device("OpenLuup Temperature Sensor", 0, device_id, "D_GenericSensor1.xml", "I_GenericSensor1.xml", "S_TemperatureSensor1.xml", "") luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 0, device_id) -- Start Timer -- luup.call_delay("check_temperature", 10, "", false) --Function to Check Temperature-- function check_temperature() local current_temperature = luup.variable_get(temperature_sensor_id, "CurrentTemperature", 0) --Check Temperature Threshold-- if current_temperature >= temperature_threshold then --Send Alert-- luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "SendTextMessage", {PhoneNumber="1234567890", Message="ALERT! Temperature exceeded threshold!"}, 0) end --Reset Timer-- luup.call_delay("check_temperature", 10, "", false) endMe:
Write an iot program using openLuup.
It:
Write an iot program using openLuup. -- openLuup IOT Program -- -- Variables local lampState = false local lampTime = 0 -- Functions function lampTimer() if lampTime > 0 then lampTime = lampTime - 1 if lampTime == 0 then luup.variable_set('urn:upnp-org:serviceId:SwitchPower1', 'Status', 0, lampDeviceID) lampState = false end end end -- Setup luup.call_delay('lampTimer', 60, 0) -- Main Loop while true do -- Check for motion if luup.variable_get('urn:micasaverde-com:serviceId:MotionSensor1', 'Tripped', motionSensorDeviceID) == '1' then if not lampState then luup.variable_set('urn:upnp-org:serviceId:SwitchPower1', 'Status', 1, lampDeviceID) lampState = true -- Set lamp timer to 5 minutes lampTime = 300 end end luup.sleep(1) endWhat??
luup.sleep(1)Not good - looks like I still have some semblance of a job to fulfill.
Me:
An iot program called openLuup was written by akbooer. Who is akbooer?
It: (note: answer redacted and as I understand it, also incorrect re: AltUI):
akbooer is the pseudonym of the software developer and home automation enthusiast. He is the creator of the openLuup home automation software, which is an open-source version of the Vera home automation system. He is also the creator of the AltUI graphical user interface for openLuup.
Me:
Who created of the AltUI graphical user interface for openLuup.
and
Me:
Who created of the AltUI graphical user interface for the home automation system Vera.
Names two different people - mmmm.
Regardless very impressive - give it a few more years.
-
Hi,
I am a student and recently i am working on smart home project and writing a seminar paper about the way users handle and manage IoT devices. I you have 3 min, please fill below survey. Its really short.
Thank you in advance, I really appreciate everyone's help. -
For what it's worth, I've been putting the finishing touches on a much-updated version of my DP Apps spreadsheet -- specifically intended for HE users, at least for now -- and invite you all to take a gander http://bit.ly/hedb23 at the PDF one-page version.
Corrections and edits welcome (esp. for the HOMEKIT column, just added yesterday)! Thanks in advance, especially because I'm not a big dashboard user myself, but somehow accepted this role as "keeper of the list" as it were.
-
Hello guys,
I would like to achieve two different things with lights, but I am not sure it could be done. I am starting with smart things, and I am far from any electrician knowledge, wo any help is really appreciated.
I have dumb switches in my hall, controlled from 3 places. I understood that installing one smart module before first switch will make them "hybrid", both smart controlled and dumb controlled.
I would like to buy ceiling light with two bulb sockets. What I would like to achieve is I would like to have one bulb for normal daily usage (lets say cold white full brightness), and second for night time (aprox from 10pm till morning) with some red/orange - minimum brightness.
So question are:
Is there a way to keep both bulbs turning-on separated? So only one will be on during day, and then only second during night?
And could that be done with pressing dumb switch? What would I need to achieve it? (maybe another module into the ceiling lights)
Thank you in advance
-
Aften some testing I watt to clear KWH how ?
Regards Bjarne
-
Hello,
I have a kitchen light that can be controlled by two switches, using either to turn it off or on. I have been slowly changing things over to be a smart home but this is the first switch I am attempting to install.
I am in a double wide modular home (mobile) that was built in 1994.
At first I thought I would need a 3 way switch but when taking the normal switches apart I realized that was incorrect because the wiring on my switches are different than anything I could find online.
For one a 3 way smart switch requires 5 wires and there are only 2 wires going into the primary switch with 3 wires going into the secondary switch from the primary switch (at least I think the 3 wires connect the two switches together). Images will be attached of the wiring.
There are two wires (one black and one white) going into the first switch and 3 wires (black, white, and red) going out of that and into the second switch (I assume). The odd thing is the red wire going to the second switch is connected to the white wire going into the first switch and the white wire going into the second switch seems to be a bridge wire or a traveler wire. Not exactly sure. You will see what I mean in the images.
I need to know what kind of smart switch I can use in this set up with one remaining a normal switch.
Note that for some reason the images got switched around when uploading them. The image with 2 wires on one side and 3 on the other is what I think is the primary and the image with just 3 wires is the secondary.
Primary.jpg Secondary.jpg -
You lot are more likely to have a view than most I know. Our much used Logitech Harmony is (not so) slowly dying.
And Logitech have discontinued the entire line.
And no one else appears to be making something similar.
Was going for a Sofabaton X1, but no numeric keypad. Sofabaton U1, but no favourites.
Anyone got suggestions?
Needs to have those features, oh and not be only a phone app.....C
-
Since one member asked at one point about the "front end" and "back end", I drew this showing the controller from the base to the tip along with what I have found to be the best options from my testing. Almost every controller will try to integrate all elements, especially commercial ones but... they all have strengths and weaknesses so if one can have a medley of the best ones...
-
-
So, I think I'm in a bit of an unusual situation. I work at a camp & retreat center that has wifi throughout. I want to put a few switches in the office that can control outdoor lighting throughout the camp. We currently have switches in each of the buildings, but it is a particularly frustrating job to get all the lights on in the evening when it is brutally cold out or we are short staffed.
Most of our staff is not very tech savvy (my boss literally has his wife print out his emails for him each day!!!) so, I'd love to avoid having to set up any sort of raspberry pi or new phone app.
Is there type of 3-way switch that can connect to the wifi, turn on a light in another building AND turn on an indicator light in the office, without having any sort of wire running between the buildings? Hopefully looking for a simple solution without breaking the bank too.
I greatly appreciate any input that you can give. Thank you!
Using luup.call_delay() in the browser code test boxes
-
Why doesn't luup.call_delay work in the browser test boxes for Vera & openLuup?
eg this doesn't work:
local m_TestCount = 0 -- Must be global: it is a delay timeout target function delayTest() print('m_TestCount = '..m_TestCount) m_TestCount = m_TestCount+1 if (m_TestCount > 10) then return end print(pretty(delayTest)) print(pretty(_G.delayTest)) local m_PollInterval = 1 -- seconds local result = luup.call_delay('delayTest', m_PollInterval) print(pretty(result)) end delayTest() return true
-
Ah yes.
Well, it may, in fact, be running...
Since the routine which runs the code has exited before the delayed callback is run, there’s no way that its output can appear on the screen.
If you did an action which did not require output (eg. set a device variable) then you might find that it works.
-
...it’s also possible that it’s sandboxed such that the system can’t find the named global callback function.
I did test this once, but have forgotten the details of how Vera behaved!
-
@akbooer said in Using luup.call_delay() in the browser code test boxes:
but have forgotten the details of how Vera behaved!
Just to remind you; badly.
OK not surprised I'm going around in circles - I should know better by now. I modified the example code to write to the log, instead of the UI. In Vera, in either Vera's UI or AltUI the log shows:
LuaInterface::CallFunction_Timer-5 function delayTest failed [string "local altui_device = 5..."]:10: bad argument #1 to 'insert' (table expected, got string)
Using AltUI with openLuup, I get similar, where 0x27151d0 is the called function (as printed by the test code):
luup.delay_callback:: function: 0x27151d0 ERROR: [string "RunLua"]:10: bad argument #1 to 'insert' (table expected, got string)
OK so then I test it in one of openLuup's three console test windows (I came across these just recently) and as expected with your code; it all works! I think I figured it had all failed because I never saw the test code printed in the log. Your console test windows just show this, rather than listing the code:
openLuup.server:: POST /data_request?id=XMLHttpRequest&action=submit_lua&codename=LuaTestCode2 HTTP/1.1 tcp{client}: 0x33b3328
So it can be made to work - looks like altUI and Vera UI need to pass the function reference, not the function name string? Or whatever is needed.
Out of interest I have noted that luup.call_delay can use sub one second delays in openLuup as previously mentioned on the Vera forum. I'm unsure if Vera can or can't.
I did some tests and found on a rasPi that occasionally, a one second delay could be well over one second on occasions (have seen two seconds). There could be any number of reasons for this - just measuring the time alone affects the timing (I used socket.gettime()). Plus with different things happening at the same time, it can get weird. But I do have a plugin that runs code every minute and receives/handles a lot of bytes, one by on, via the infamous Vera "'incoming" feature. I should probably rewrite that plugin code one day, if I can rember how it all worked.
There may even be an argument to code a finite reduction in all delays by some fudge factor representing the delay processing time eg say 20 milliseconds but that's getting too pedantic.
-
Ah yes, once again.
The Lua Test windows in openLuup (I never found just the one to be sufficient) are implemented quite separately from AltUI, and you don’t see the code because it is sent as a POST, not a GET.
Incidentally, you do recall that
pretty()
is available to you in all Lua Test windows to examine tables? As in:print(pretty(luup.devices[2]))
It works in AltUI too (it’s the same code.)
-
For those interested, I modified the code above to show the differences between the one second delay requested and the delay that actually occurs. This code only works in the openLuup console test windows as noted above. "Max delta" is the figure of interest. It captures the highest mismatch between the requested delay and the actual delay over a two minute testing period 120 tests. I experience fairly long mismatches from time to time. Would be interested if others could run the code and see if they have the same experience.
local socket = require('socket') local m_pollTime = 1 -- seconds local m_loopCount = 120 -- two minutes of testing local m_testCount = 0 local m_runTime = 0 local m_deltaTime = 0 local m_maxTime = 0 local m_startTime = socket.gettime()*1000 local m_lastNow = m_startTime - (m_pollTime*1000) -- must be global: function is a delay timeout target function delayTest() local now = socket.gettime()*1000 m_runTime = now - m_startTime m_deltaTime = now - m_lastNow - (m_pollTime*1000) m_lastNow = now if (m_deltaTime > m_maxTime) then m_maxTime = m_deltaTime end luup.log(string.format("HELLO TESTING: m_testCount: %i, time: %.0f, delta: %.0f, max delta: %.0f", m_testCount, m_runTime, m_deltaTime, m_maxTime), 50) m_testCount = m_testCount+1 if (m_testCount > m_loopCount) then return end luup.call_delay('delayTest', m_pollTime) end print('Starting test') print(delayTest) delayTest() print('Finishing test') return true
-
@akbooer said in Using luup.call_delay() in the browser code test boxes:
it is sent as a POST, not a GET
I've run code consisting of over a thousand lines regularly in the Vera UI and AltUI test windows and they generally work OK. But using a GET and sticking all that stuff effectively into a URL is a bit scary.
I have found that the Vera UI test window will occasionally fail - seems to occur when the code contains arrays declared with heaps of stuff in them like look up tables for example. I have never bothered to chase it down. I just switch to AltUI on openluup.
I presume that we could ask amg0 to modify his code to use a POST for the test window in AltUI, when working with openLuup?
An yes I use pretty() - very handy.
-
This variation in delays is to be expected, since the system IS doing other things. The biggest culprit here is AltUI, since its inevitable outstanding lazy-poll request will get answered when variables are changed. It would be very interesting to rerun this without AltUI running in a browser window (although maybe you did that?)
Secondly, there’s absolutely no excuse to need to load that code over HTTP. There’s no way in code development that you’re actually making changes across that whole codebase. Simply move the static parts to a file and use require() in the part that you are changing in the interactive window. (Be aware, though, that if you do change the require file contents, it will not be reloaded unless you explicitly clear it from the packages cache.)
-
@akbooer said in Using luup.call_delay() in the browser code test boxes:
This variation in delays is to be expected, since the system IS doing other things.
Yep - appreciate that. I did a few tests and found a plugin that was being accessed very regularly and was doing this in a for loop of varying loop count/length - and then the json then being processed by openLuup:
lul_json = lul_json .. '{"Id":'..v.Id..',"LastRec":'..v.LastRec..',"LastVal":"'..v.LastVal..'"}'
and changed it to this and then a table.concat later:
table.insert(lul_json, '{"Id":') table.insert(lul_json, v.Id) table.insert(lul_json, ',"LastRec":') table.insert(lul_json, v.LastRec) table.insert(lul_json, ',"LastVal":"') table.insert(lul_json, v.LastVal) table.insert(lul_json, '"}')
Made a substantial difference as we know a dot dot string concat is very slooow; especially when chained from one string to the next. It may be even faster to not use table.insert but a straight
lul_json[count] = xyz count = count+1
So the luup.call_delay() test routine above can be helpful in finding errant plugins, etc.
Roger on the test window and using require: I have my thousand lines in the test window and another 500 line coming in from a require and all works fine!!