jneilliii / OctoPrint-TPLinkSmartBulb

1 stars 0 forks source link

Does not work; complains about IP address #1

Closed bmcgough closed 6 years ago

bmcgough commented 6 years ago

I tried enabling debugging and logging from whatever options I saw in the plugin and octoprint, but don't find any useful messages.

How can I best debug/troubleshoot this?

The icon appears in the octoprint bar after restart and I get the plugin configuration page. The 'plug' plugin is installed and works on the same octoprint installation.

The IP address of my bulb has not changed, and the Kasa Android app works to control it. It is an LB110.

jneilliii commented 6 years ago

Thanks for testing, finally got someone with a bulb...once you enable debug logging in the plugin settings when you press the button and get the error it should log information I can use to find out what's going on. Can you please upload your plugin_tplinksmartbulb_debug.log file?

jneilliii commented 6 years ago

For example, when I try to do it against my plug (I know it's not going to work) I get the following.

[2018-10-04 17:22:08,423] DEBUG: Checking status of 192.168.0.130.
[2018-10-04 17:22:08,423] DEBUG: IP 192.168.0.130 is valid.
[2018-10-04 17:22:08,879] DEBUG: Sending command {"system":{"get_sysinfo":{}}} to 192.168.0.130
[2018-10-04 17:22:08,881] DEBUG: « 1ã"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.1.2 Build 161014 Rel.164426","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(US)","mac":"50:C7:BF:6A:6C:83","deviceId":"8006DB119EADD41BCE508828B19A949F1872F15C","hwId":"5EACBE93FB9E32ECBE1F1C2ADE6DDE11","fwId":"6C4ACA62CB1B921060CF24148345CD43","oemId":"37589AA1F5CACDC53E2914B7760127E5","alias":"CR-10","dev_name":"Wi-Fi Smart Plug","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"schedule","feature":"TIM","updating":0,"rssi":-69,"led_off":0,"latitude":33.811649,"longitude":-84.474007}}}
[2018-10-04 17:22:08,883] INFO: {u'system': {u'get_sysinfo': {u'oemId': u'37589AA1F5CACDC53E2914B7760127E5', u'dev_name': u'Wi-Fi Smart Plug', u'on_time': 0, u'feature': u'TIM', u'fwId': u'6C4ACA62CB1B921060CF24148345CD43', u'icon_hash': u'', u'relay_state': 0, u'latitude': 33.811649, u'hw_ver': u'1.0', u'type': u'IOT.SMARTPLUGSWITCH', u'led_off': 0, u'hwId': u'5EACBE93FB9E32ECBE1F1C2ADE6DDE11', u'sw_ver': u'1.1.2 Build 161014 Rel.164426', u'mac': u'50:C7:BF:6A:6C:83', u'active_mode': u'schedule', u'deviceId': u'8006DB119EADD41BCE508828B19A949F1872F15C', u'updating': 0, u'longitude': -84.474007, u'alias': u'CR-10', u'rssi': -69, u'model': u'HS100(US)', u'err_code': 0}}}
[2018-10-04 17:22:08,883] DEBUG: {u'system': {u'get_sysinfo': {u'oemId': u'37589AA1F5CACDC53E2914B7760127E5', u'dev_name': u'Wi-Fi Smart Plug', u'on_time': 0, u'feature': u'TIM', u'fwId': u'6C4ACA62CB1B921060CF24148345CD43', u'icon_hash': u'', u'relay_state': 0, u'latitude': 33.811649, u'hw_ver': u'1.0', u'type': u'IOT.SMARTPLUGSWITCH', u'led_off': 0, u'hwId': u'5EACBE93FB9E32ECBE1F1C2ADE6DDE11', u'sw_ver': u'1.1.2 Build 161014 Rel.164426', u'mac': u'50:C7:BF:6A:6C:83', u'active_mode': u'schedule', u'deviceId': u'8006DB119EADD41BCE508828B19A949F1872F15C', u'updating': 0, u'longitude': -84.474007, u'alias': u'CR-10', u'rssi': -69, u'model': u'HS100(US)', u'err_code': 0}}}
Warchildz commented 6 years ago

Ok I am trying to give it a shot I get the same as bmcgough, I have Gcode trigger set with the M80 192.168.XXX and M150 R U B P W I in my slicer start script,...

M80 192.168.1.116 M150 R U B P W I G28 ; home all axes M155 S30
G29 T M155 S3 G1 Z5 F3000 ; lift G1 X5 Y10 F1500 ; move to prime G1 Z0.2 F3000 ; get ready to prime G92 E0 ; reset extrusion distance G1 Y80 E10 F600 ; prime nozzle G1 Y100 F5000 ; quick wipe

plugin_tplinksmartbulb_debug.log

jneilliii commented 6 years ago

Thanks, that helps. I'll do some changes and get you to retest once complete.

jneilliii commented 6 years ago

Just pushed version 0.1.1 that should fix the current status detection issue. For your M150 command you have to include values on the individual letters R U B P W I. See the marlin gcode command reference here.

bmcgough commented 6 years ago

I've just updated to 0.1.1 through Octoprint. Thanks for this - it is exciting for me to have such great tools around my new printer.

I can now turn the bulb on! But I get the attached errors, and the bulb icon just keeps spinning.

If I reload Octoprint (just refresh in browser) it seems to read the bulb state properly (icon turns green). If I try to turn it off, the "Proceed" button doesn't do anything just hangs and no errors are printed to console.

I feel like I'm missing something - I just don't see a log file anywhere (ran find against my Octoprint venv).

2018-10-06 13:16:30,349 - octoprint - ERROR - Exception on /api/plugin/tplinksmartbulb [POST]
Traceback (most recent call last):
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/OctoPrint-1.3.9-py2.7.egg/octoprint/server/util/flask.py", line 1140, in decorated_view
    return flask_login.login_required(func)(*args, **kwargs)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/Flask_Login-0.2.11-py2.7.egg/flask_login.py", line 758, in decorated_view
    return func(*args, **kwargs)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/OctoPrint-1.3.9-py2.7.egg/octoprint/server/api/__init__.py", line 99, in pluginCommand
    response = api_plugin.on_api_command(command, data)
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint_tplinksmartbulb/__init__.py", line 146, in on_api_command
    self.turn_on("{ip}".format(**data))
  File "/home/been/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint_tplinksmartbulb/__init__.py", line 94, in turn_on
    chk = self.sendCommand('{"smartlife.iot.smartbulb.lightingservice":{"transition_light_state":{"on_off":1}}}',bulbip)["smartlife.iot.smartbulb.lightingservice"]["err_code"]
KeyError: 'err_code'
2018-10-06 13:16:30,352 - tornado.access - ERROR - 500 POST /api/plugin/tplinksmartbulb (127.0.0.1) 38.71ms
jneilliii commented 6 years ago

Thanks, I think I can fix that.

jneilliii commented 6 years ago

I do need one thing though. Can you upload your plugin_tplinksmartbulb_debug.log file please? I need to see how the bulb responds to the on/off commands.

Warchildz commented 6 years ago

Hello jneilliii, Ok I have play around with this for hours now and the on thing I have been able to get it to do was shut off my light one time, no color changes etc. it is connecting but when you hit the light button it will spin and hang, pretty much the issue as described above. I tried to enter the values on the color change from the Marlin page, not sure I have them placed right, I did not see a value for the "I" for the M150 R U B P W I entry on Marlin M code listing...… Here is my scripts...

M80 192.168.1.116 M150 [R<100>] [U<100>] [B<100>] [P<150>] [W<150>] [I<100>] G28 ; home all axes M155 S30 G29 T M155 S3 G1 Z5 F3000 ; lift G1 X5 Y10 F1500 ; move to prime G1 Z0.2 F3000 ; get ready to prime G92 E0 ; reset extrusion distance G1 Y80 E10 F600 ; prime nozzle G1 Y100 F5000 ; quick wipe

and ending....

M104 S0 ;extruder heater off M140 S0 ;bed heater off G91 ;relative positioning G1 E-1 F300 ;retract the filament 1mm G1 Z+0.5 E-3 X-20 Y-20 F6000 ;move Z up and retract filament 3mm M106 S255 ;fan at 100% to cool nozzle G90 ;absolute positioning G28 X0 Y0 ;home X and Y G1 Y200 ;move bed forward M84 ;steppers off G4 P120000 ;wait 2 minutes (120 seconds) M106 S0 ;fan off M81 192.168.1.116

and the log....

plugin_tplinksmartbulb_debug.log

jneilliii commented 6 years ago

Small change to your M150 command necessary.

M150 R100 U100 B100 P150 W150 I100

I'll check the log when I get back home later tonight.

jneilliii commented 6 years ago

Ok, not what I was expecting to see. Do me a favor and let's keep it simple for now and just use the button. First delete your octoprint.log and plugin_tplinksmartbulb_debug.log file and restart OctoPrint. It should in theory detect the current state of the bulb and color the button appropriately. Then press the button to change the on/off state of the bulb. From what you've described, this should now be in a state where the button icon is just spinning indefinitely. If so, grab those two log files and upload them here. If not, try the button again and if it's then in the spinning state, grab the log files and upload them here.

Once we get the on/off functionality working we can move on to color changing. I may end up purchasing one of these bulbs just to make it a little easier to debug.

Warchildz commented 6 years ago

Sorry I have been busy, I will get after it later today..... I have been fighting with the DetailedProgress Plugin and had to walk away from it, OutsourdedGuru was trying to help get it working right, but I can not get it to work. I have deleted it for now, will focus on this project. Thanks again.

Craig H.

Warchildz commented 6 years ago

octoprint.log plugin_tplinksmartbulb_debug.log

jneilliii commented 6 years ago

@Warchildz, can you try to toggle the bulb? From the plugin log you sent it doesn't look like you tried that, just retrieved the current status.

jneilliii commented 6 years ago

And then re-upload the plugin log file.

Warchildz commented 6 years ago

Ok I am doing what you have said to do, it is doing nothing...… I hit the button it starts to spin but the is nothing in the log file …… octoprint.log

![screenshot 48](https://user-images.githubusercontent.com/41930469/46850943-690f78 screenshot 49 00-cdbb-11e8-90cb-b06c83265a89.png) screenshot 50

Warchildz commented 6 years ago

Ok got something this time I had to reboot the system, not just reload to get anything.... plugin_tplinksmartbulb_debug.log octoprint.log

jneilliii commented 6 years ago

Yeah, looks like I'm going to have to buy a bulb. I don't see why it's not working.

Warchildz commented 6 years ago

I click the button, it starts to spin, the pop up comes up to proceed, I click on proceed and nothing happens, I have to hit the "X" to get the window to close...… Hope this info helps....

jneilliii commented 6 years ago

Just to test, open the bulb's settings and uncheck the warning options. That will bypass the warning box and maybe get us a step closer.

jneilliii commented 6 years ago

Think I just figured out the issue with the warning prompt and pushed an updated version 0.1.2. Force check for software updates and it should allow you to upgrade. Let me know how it goes.

Warchildz commented 6 years ago

Ok I had to manually download the update, I was getting install errors. The proceed button works now..... I also had to disable the auto start and the auto stop to get a log file without the system reboot, log files are with the auto stuff disabled...…. plugin_tplinksmartbulb_debug.log octoprint.log

Warchildz commented 6 years ago

This is with auto start and auto stop enabled...….. plugin_tplinksmartbulb_debug (1).log octoprint (1).log

with this on I have to reboot the system.....

jneilliii commented 6 years ago

Is it still just spinning when you click proceed? Can you open your browser's console to see if there are any client side errors for me when you click the button, etc.?

Warchildz commented 6 years ago

Ok, I did not have to reboot the system this time here, but there is no color in the icon. plugin_tplinksmartbulb_debug.log octoprint.log

....

jneilliii commented 6 years ago

Alright, I just ordered a KB130 from my local Wal-Mart for pick-up on my way home. I'll figure out what's going on over the weekend.

Warchildz commented 6 years ago

I am sorry that I am not better help for you...… :(

jneilliii commented 6 years ago

No problem @Warchildz, it's not that you aren't helping, it will just be faster for me to get one and work out the kinks directly.

jneilliii commented 6 years ago

Ok, I just published a new release. It's working for me with the LB130 I got from Amazon rather than KB130. Hopefully this will work for you. If you go into OctoPrint Settings > Software Update and click the advanced options then press the "Force check for updates" button.

I verified the gcode commands work as long as the settings have gcode trigger enabled on the bulb and you use the bulb's ip/hostname in the command. Assuming your bulb's ip address is 192.168.1.116 the following commands will perform the given action.

M80 192.168.1.116 will turn on your bulb. M81 192.168.1.116 will turn off your bulb.

For changing the color use the format M150 I<bulb ip> R<value 0-255> U<value 0-255> B<value 0-255> P<value 0-255>. For example M150 I192.168.1.116 R128 G0 B128 P128 will turn the bulb with ip 192.168.1.2 to a purple color at 50% brightness.

bmcgough commented 6 years ago

Sorry I don't have much time to print during the week. I just updated and it looks like everything is working on my LB110 - properly detecting state on startup, on, off, bulb icon reflects states correctly and behaves like the volt/bolt icon does.

Thank you!

I finally found the log files (was looking in the OS, not the Octoprint UI) and will be around this weekend if you need any additional info, though it sounds like you can do your own troubleshooting now.

jneilliii commented 6 years ago

Thanks for the update. Glad it is working for you. Don't hesitate to post a new issue later if you run into problems or have any additional enhancements you think would be beneficial.