jneilliii / OctoPrint-TPLinkSmartplug

105 stars 57 forks source link

Disappearing sidebar? #83

Closed Jozer99 closed 5 years ago

Jozer99 commented 5 years ago

Firstly, thank you for the plugin, I love having the TP-Link control functionality in Octoprint.

I notice that when I load the octoprint webpage in my browser, a side panel box with the current power consumption of the TP link plug is displayed. This sidebar disappears when the page fully loads. How do I get this sidebar box to stay around? I think having the power consumption of the printer displayed would be interesting. Looking at the page source, the div "sidebar_plugin_tplinksmartplug_wrapper" is set to "display: none".

jneilliii commented 5 years ago

That sidebar panel will only stay if one of the plugs configured in settings are an energy monitoring device. Not all plugs supply that information. I believe it's a model HS-110 that does.

Jozer99 commented 5 years ago

My smartplug is an HS-110, and the TP-Link app provides information on power usage. The sidebar panel still disappears.

jneilliii commented 5 years ago

Can you enable debug logging in settings, restart octoprint, force a refresh of the browser (ctrl + F5) and then report back here with your plugin_tplinksmartplug_debug.log file please?

Dalewn commented 5 years ago

Just saw the same behaviour. I only own a HS100, so sadly it is intended behaviour.

One a sidenote: Maybe add a note to your description as it is not clear that the HS110's power usage actually is supported.

jneilliii commented 5 years ago

Good point @Dalewn, I haven't updated the readme with screenshots or details about that. I'll add that to my todo list for the next update.

kalle-1989 commented 5 years ago

I have an HS110 and also the same issue with the disappearing sidebar panel for power consumption. I attache my log with removed IP und Ids. plugin_tplinksmartplug_debug.log

jneilliii commented 5 years ago

That's weird, I'll have to go back and review the code, but it should be working because it's returning the information for the plug for sure. The last line toward the very end is the energy data.

"emeter":{"get_realtime":{"voltage_mv":233653,"current_ma":19,"power_mw":0,"total_wh":85,"err_code":0}}

Have you by chance tried restarting octoprint since setting up the plug?

jneilliii commented 5 years ago

@Jozer99 that looks like an exact copy of @kalle-1989 log file. The timestamps are even exactly the same.

Jozer99 commented 5 years ago

Opps, uploaded the wrong log file. Here is the real one, I hope.
plugin_tplinksmartplug_debug.anon.log

jneilliii commented 5 years ago

yep, I see it returning the correct data back. Have you tried restarting octoprint since adding the plug in settings?

Jozer99 commented 5 years ago

I've had the plugin with these settings for months. I have restarted it several times today. The energy monitor sidebar panel disapears during page load still.

jneilliii commented 5 years ago

Thanks. If you ssh to your pi and open ~/.octoprint/config.yaml does the plugin settings show the emeter data saved with the plug?

jneilliii commented 5 years ago

For example, on my pi here are the plugin's settings that are saved currently.

  tplinksmartplug:
    _config_version: 7
    arrSmartplugs:
    - autoConnect: false
      autoConnectDelay: 10
      autoDisconnect: false
      autoDisconnectDelay: 0
      btnColor: '#808080'
      countdownOffDelay: 0
      countdownOnDelay: 0
      currentState: 'on'
      displayWarning: false
      emeter: null
      gcodeEnabled: false
      gcodeOffDelay: 0
      gcodeOnDelay: 0
      icon: icon-bolt
      ip: 192.168.0.130
      label: HS100
      sysCmdOff: false
      sysCmdOffDelay: 0
      sysCmdOn: false
      sysCmdOnDelay: 0
      sysRunCmdOff: ''
      sysRunCmdOn: ''
      useCountdownRules: false
      warnPrinting: false
    - autoConnect: true
      autoConnectDelay: 10
      autoDisconnect: true
      autoDisconnectDelay: 0
      btnColor: '#808080'
      countdownOffDelay: 0
      countdownOnDelay: 0
      currentState: unknown
      displayWarning: true
      emeter:
        get_realtime:
          current: 0.021603
          err_code: 0
          power: 0
          total: 25.935
          voltage: 119.048836
      gcodeEnabled: true
      gcodeOffDelay: 0
      gcodeOnDelay: '0'
      icon: icon-bolt
      ip: 192.168.0.122
      label: Clu3D
      sysCmdOff: false
      sysCmdOffDelay: 0
      sysCmdOn: false
      sysCmdOnDelay: 0
      sysRunCmdOff: ''
      sysRunCmdOn: ''
      useCountdownRules: false
      warnPrinting: true
    - autoConnect: false
      autoConnectDelay: 10
      autoDisconnect: false
      autoDisconnectDelay: 0
      btnColor: '#808080'
      countdownOffDelay: 0
      countdownOnDelay: 0
      currentState: unknown
      displayWarning: false
      emeter:
        get_realtime:
          current: 0.020651
          err_code: 0
          power: 0
          total: 1.636
          voltage: 120.437648
      gcodeEnabled: false
      gcodeOffDelay: 0
      gcodeOnDelay: 0
      icon: icon-coffee
      ip: 192.168.0.102
      label: Keurig
      sysCmdOff: false
      sysCmdOffDelay: 0
      sysCmdOn: false
      sysCmdOnDelay: 0
      sysRunCmdOff: ''
      sysRunCmdOn: ''
      useCountdownRules: false
      warnPrinting: false
Jozer99 commented 5 years ago

This is all that I get under tplinksmartplug:

tplinksmartplug:
    _config_version: 7
    arrSmartplugs:
    - autoConnect: true
      autoConnectDelay: 10
      autoDisconnect: true
      autoDisconnectDelay: 0
      btnColor: '#808080'
      countdownOffDelay: 0
      countdownOnDelay: 0
      currentState: 'on'
      displayWarning: true
      emeter: null
      gcodeEnabled: true
      gcodeOffDelay: '10'
      gcodeOnDelay: 0
      icon: icon-bolt
      ip: xxx.xxx.xxx.xxx
      label: Printer
      sysCmdOff: false
      sysCmdOffDelay: 0
      sysCmdOn: false
      sysCmdOnDelay: 0
      sysRunCmdOff: ''
      sysRunCmdOn: ''
      useCountdownRules: false
      warnPrinting: false
jneilliii commented 5 years ago

Thanks. For some reason the emeter section isn't updating from what's returned by the plug when the plugin checks the status. Were you using a version prior to 0.9.8? I'd like trying deleting the entire tplinksmartplug section from config.yaml and then restart octoprint and reconfigure the plug in settings.

jneilliii commented 5 years ago

I think I see the issue now. It's definitely related to code issues on the plugin side. I'm looking into possible fixes now.

jneilliii commented 5 years ago

Could you guys test a potential fix for this issue by installing an updated version using the url below in plugin manager? So far my testing has proven positive, would love to get some additional feedback prior to officially releasing it.

https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/archive/0.9.11.zip

alexisju commented 5 years ago

Worked for me with the 0.9.11 (didnt worked previously with my HS110(FR))

sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 180410 Rel.182657","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)

jneilliii commented 5 years ago

Version 0.9.11 officially released. Thanks @alexisju for confirmation. I still want to split out the energy monitoring request to display accurately, to fix the issue where the sidebar data displays the plug as still drawing power when it's off and should show 0.

Jozer99 commented 5 years ago

I can verify that it is now working correctly. Thank you jneilliii for your plugin, and your excellent assistance with this issue.