Discussion Forum to share and further the development of home control and automation, independent of platforms.

    SmartHome Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Unsolved
    (Last Updated: 26 April 2021)
    • Need help in finding the right smart switch for my kitchen lights

      M

      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

      General Discussion
    • Short survey

      P

      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.

      General Discussion
    • OT: Universal Remote

      CatmanV2

      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

      General Discussion
    • The Home Automation Controller Pyramid

      rafale77

      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...

      Screen Shot 2020-05-14 at 07.11.06.png

      General Discussion
    • Thread removed - why?

      Black Cat

      I was just going to add my support for a Update Button for the bare bones version of MSR and find the thread has been removed.
      I'm wondering what was so provocative that required it's removal?
      Have we become as paranoid as an owner of another forum?

      Anyway +1 for an Update Button.

      General Discussion
    • 3-way smart switches in separate buildings.

      D

      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!

      General Discussion
    • X-10 replacement for a new wall switch (HomeKit)

      G

      I have a X10 wall switch system and I want to get rid of it. What would be the easiest transition to something more modern and easy to use with either wifi/homekit capabilities? My current X10 controls 3 zones in my bedroom. All zones are dimmable.
      Zone 1 is 4 canister ceiling lights. LED bulbs
      Zone 2 is 1 canister ceiling lights. Halogen Bulb
      Zone 3 is 1 canister ceiling lights. Halogen Bulb
      I have an old plug-in remote from Radio Shack and a wall switch with 3 buttons, each controlling one zone. (images attached)
      My wall switch has one two wires from the wall. One black, one white.

      Is there any solution easy to install without the need of an electrician? Thanks for any feedback.

      ij455pd333061.jpg.jpeg ttsjhpd333061.jpg.jpeg

      General Discussion
    • Looking for alternative to Gcal3 in Vera for MSR and public calendar

      T

      Good morning all,
      I'm working on weaning myself off of being totally Vera dependent. I've installed MSR on my Fedora home server, and I've been migrating luup Reactor rules over little by little. My hope is to use Vera as a bare bones z-wave hub, until I replace it either with Ezlo (not so sure about), or perhaps Hubitat. I'm just tired of zero new development in Vera, empty promises of native device integration, and cloud services that go down and leave my automation hanging.

      In any case, I digress. I've attempted to use Gcal3 on Vera to integrate Public calendars, such as Federal Holidays, School Calendars, etc. It use to somewhat work, but more often than not, all I get from Gcal3 is "token error code: HTTP/1.1 400 Bad Request". The developer no longer is active, and it's effectively not working anymore.

      I'd like to use these public calendars as Entity Attributes or Constraints in MSR. For instance, if it's a Federal Holiday, I don't have to work, and I may want to sleep in, which means lights may not come on as early, window coverings in the bedrooms may open later in the day, etc. Similar idea with a school calendar. If "closed" is in the event, my daughter may want to sleep in, and not want the window coverings opened as early.

      I'm aware that Ezlo has integration through NuCal to all sorts of web based services, including Google Calendar, but as I stated earlier, I'm undecided on going down that path. Is there anyway to do this on MSR through any of it's abilities, such as HTTP calls or MQTT ( not experienced in MQTT, so I don't know now it works really).

      Has anybody already done this?

      Thanks for any advice in advance.

      General Discussion
    For those who registered but didn't received the confirmation email, please send an email to support@smarthome.community with the email you used

    UniFi Energy Report - How can I retrieve the value via http ?

    General Discussion
    2
    6
    110
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • parkerc
      parkerc last edited by

      Hi,

      I have a piece of code that returns the Watts used by all the PoE devices on my home network. I’m trying to set it up on Vera so that can retrieve that value in a similar way I would retrieve a Vera variable via a http request.

      The function works returns the total value when run via LuaTest, but when I try to retrieve it via luup.register_ handler, for some reason it returns the entire UniFi json file ??

      Please could some help me with what’s wrong, my goal is to be able to retrieve the value , like an api so I can use it elsewhere ..

      luup.register_handler("UnifiControllerPoE","UnifiWatts")
      
      function UnifiControllerPoE()
      	local unifi_username = "unifi" 
      	local unifi_password = "unifi" 
      	local unifi_controller_ip = "192.168.1.207" 
      	local unifi_controller_port = "8443"  
      	local cookie = "/tmp/unifi_cookie_lua" -- Temp cookie file
      	local tempfilename = "/tmp/UnifiController.tmp" -- Temp JSON output file
      	local device = 'api/s/default/stat/device'
      	local f = io.popen("stat -c %Y " .. tempfilename)
      	local last_modified = f:read()
      		--if (os.difftime (os.time(), last_modified) > 30) then
      			-- URL for logging in, query and logging out
      			url_login = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure -H \'Content-Type: application/json\' -X POST -d \'{"password":"' .. unifi_password .. '","username":"' .. unifi_username .. '"}\' https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/api/login'
      			url_open = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure -s -o '..tempfilename..' --data "json={}" https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/' ..device
      			url_logout = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/logout'
      			-- Execute url
      			-- Execute url
      			read_login = os.execute(url_login)
      			read_open = os.execute(url_open)
      			read_logout = os.execute(url_logout)
      		--end
      
      		
      	local line
      	local file = io.open(tempfilename, "r")
      		if file then
      			line = file:read("*a")
      			file:close()
      		end
      	return line
      end
      
      --print(UnifiController())
      
      local readings = {}
      local total = 0
      local json = require "dkjson"
      local u = json.decode( UnifiControllerPoE() )
      --print('\n')
      
      for key,value in ipairs( u.data ) do
      	for n, p in ipairs( value.port_table ) do
      		--print('\t'.. tostring(p.port_idx), p.poe_enable, tonumber(p.poe_power))
      		-- print(p.port_idx)
      		table.insert( readings, { value.name, tonumber(p.poe_power)}) -- populate readings table
      	end	
      end
      	for _, reading in ipairs(readings) do
      		local Variable = reading[1]
      		local Value = reading[2] or 0
      		total = total + Value
      			if Value ~= 0 then 
      			--print(Variable.. " - ".. Value, total)
      	end
      end
      
      print("Total watts = " ..total)
      
      local html = "<html><head>" ..
                           "</head>" ..
                           "<body>" ..
                           "<b>" ..
                           tostring(total) .. '</b>' ..
                           "</body></html>"
          
      	return html, "text/html"
      
      therealdb 1 Reply Last reply Reply Quote 0
      • parkerc
        parkerc last edited by

        Hi all,

        Is this even possible to do ?

        If so, does anyone have any ideas / suggestions on how to do it ? Many thanks

        1 Reply Last reply Reply Quote 0
        • therealdb
          therealdb @parkerc last edited by

          @parkerc you should move your end at line 33 to be the last, otherwise the function will not include the rest of your code.

          --
          On a mission to automate everything.

          My MS Reactor contrib
          My Luup Plug-ins

          1 Reply Last reply Reply Quote 0
          • parkerc
            parkerc last edited by

            Thanks so much @therealdb - Such a silly mistake, for some reason I was thinking it would run the whole piece of code, when i should have realised it will only run the function part, as that’s all that’s being called! Doh !

            .

            1 Reply Last reply Reply Quote 1
            • parkerc
              parkerc last edited by

              Ok, perhaps I spoke too soon as that’s created other errors - but at least I know where to focus my attention for now..

              1 Reply Last reply Reply Quote 0
              • parkerc
                parkerc last edited by parkerc

                Sorted ! - thanks again @therealdb , I had to break it up over two functions in the end - but it works a treat ! 🙂

                luup.register_handler("rununfiwattagereport","unifi")
                 
                function UnifiControllerPoE()
                	local unifi_username = "vera"
                	local unifi_password = "vera"
                	local unifi_controller_ip = "192.168.102.207"
                	local unifi_controller_port = "8443"
                	local cookie = "/tmp/unifi_cookie_lua" -- Temp cookie file
                	local tempfilename = "/tmp/UnifiController.tmp" -- Temp JSON output file
                	local device = 'api/s/default/stat/device'
                	local f = io.popen("stat -c %Y " .. tempfilename)
                	local last_modified = f:read()
                		--if (os.difftime (os.time(), last_modified) > 30) then
                			-- URL for logging in, query and logging out
                			url_login = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure -H \'Content-Type: application/json\' -X POST -d \'{"password":"' .. unifi_password .. '","username":"' .. unifi_username .. '"}\' https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/api/login'
                			url_open = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure -s -o '..tempfilename..' --data "json={}" https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/' ..device
                			url_logout = 'curl --cookie ' .. cookie .. ' --cookie-jar ' .. cookie .. ' --insecure https://' .. unifi_controller_ip .. ':' .. unifi_controller_port .. '/logout'
                			-- Execute url
                			-- Execute url
                			read_login = os.execute(url_login)
                			read_open = os.execute(url_open)
                			read_logout = os.execute(url_logout)
                		
                	local line
                	local file = io.open(tempfilename, "r")
                		if file then
                			line = file:read("*a")
                			file:close()
                		end
                	return line
                end
                
                function rununfiwattagereport()
                local readings = {}
                local total = 0
                local json = require "dkjson"
                local u = json.decode( UnifiControllerPoE() )
                --print('\n')
                
                for key,value in ipairs( u.data ) do
                	for n, p in ipairs( value.port_table ) do
                		--print('\t'.. tostring(p.port_idx), p.poe_enable, tonumber(p.poe_power))
                		-- print(p.port_idx)
                		table.insert( readings, { value.name, tonumber(p.poe_power)}) -- populate readings table
                	end	
                end
                	for _, reading in ipairs(readings) do
                		local Variable = reading[1]
                		local Value = reading[2] or 0
                		total = total + Value
                			if Value ~= 0 then 
                			--print(Variable.. " - ".. Value, total)
                	end
                end
                
                print("Total watts = " ..total)
                
                local html = "<html><head>" ..
                                     "</head>" ..
                                     "<body>" ..
                                     "<b>" ..
                                     tostring(total) .. '</b>' ..
                                     "</body></html>"
                    
                					 return html, "text/html"
                end
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                Welcome. If you’d like to participate in the discussion, rather than just read, then you can join the forum. As a member, you can interact with others here to share your experience and ask the questions you need answered.

                Powered by NodeBB | Contributors
                Hosted freely by PointPub Media Communications Inc. | Contact us