jneilliii / OctoPrint-TPLinkSmartplug

106 stars 57 forks source link

Data not showing on main page #73

Closed bvalat closed 5 years ago

bvalat commented 5 years ago

Hi, i just bought an hs110. Switch on and off are working but data are not showing anywhere. I can see place holder whiel loading the page but it desapeared. Page code seems to show that somthing is wrong :

is currently . The logs are showing data : `[2018-11-24 22:18:30,422] DEBUG: « Á"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.0.10 Build 160304 Rel.082646","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)","mac":"50:C7:BF:DD:40:52","deviceId":"800640E90EB30F21FBC20EFB4E9ADC3B18C4B118","hwId":"797CB3D09D9A83B1C43A623C6DD103C2","fwId":"848F75775BF7C417E48DA916C0B3FD58","oemId":"0D13F703F04C040DC3D27DB248C01A1A","alias":"Ender3","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":1,"on_time":596,"active_mode":"schedule","feature":"TIM:ENE","updating":0,"rssi":-79,"led_off":0,"latitude":XX.761934,"longitude":X.050819}},"emeter":{"get_realtime":{"current":0.128606,"voltage":235.526159,"power":9.911982,"total":0.007000,"err_code":0}}} ` (I put XX on GPS coordinate) How can i help you to track down the problem (I have some computer science skills)?
jneilliii commented 5 years ago

Is the emeter data being updated in config.yaml? Are there any errors in the browser's developer console? You may also need to restart octoprint after the initial setup, if the emeter data is in the config.yaml file.

bvalat commented 5 years ago

Yes i did restart octoprint and even reboot my raspberry. tplinksmartplug is in my config.yaml. I can switch on and off, the log file is here and there are lines in it. Yes those ko are in the html code of the page (dev console).
Wonder if there are real KO or just place holders.

bvalat commented 5 years ago

I wonder if the strange caracters in my logs are OK? [2018-11-24 23:39:37,352] DEBUG: ▒^@^B▒^S"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.0.10 Build 160304 Rel.082646","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)","mac":"50:C7:BF:DD:40: ~

bvalat commented 5 years ago

Tried to upgrade the plug. No effect, still garbage between debug and system : [2018-11-24 23:58:26,172] DEBUG: ▒▒b"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 180410 Rel.182657","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)","mac":"50:C7:BF:DD:40:52","deviceId":"800640E90EB30F21FBC20EFB4E9ADC3B18C4B118","hwId":"797CB3D09D9A83B1C43A623C6DD103C2","fwId":"00000000000000000000000000000000","oemId":"0D13F703F04C040DC3D27DB248C01A1A","alias":"Ender3","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"schedule","feature":"TIM:ENE","updating":0,"rssi":-79,"led_off":0,"latitude":XX.761934,"longitude":X.050819}},"emeter":{"get_realtime":{"current":0.016496,"voltage":233.634363,"power":0,"total":0,"err_code":0}}}

jneilliii commented 5 years ago

Those weird characters are just a logging issue, unrelated to your problem. I have them too and mine report fine. If there are no errors in your browser's console try enabling the polling option and set the interval to 1. Watch your browser's console while it updates and check for errors.

bvalat commented 5 years ago

I think i have a parsing problem. My plug is FR and fields have not the same order and same name as others log (i looked in othet request). Where are your parsing the answer from the plug. I didn't learn python and can't see where you are doing it. btw, thanks for your help.

bvalat commented 5 years ago

I found an error in the console. but i can't reproduce now. It was on item.emeter.get_realtimekey; from for (key in data.emeter.get_realtime){ console.log(key + ' = ' + data.emeter.get_realtime[key]); item.emeter.get_realtimekey; }

I switched back to 0.9.8 and everything is working fine. After upgrade too.... 0.9.9 tag and master. Don't get it. So wether 0.9.8 installed something missing, or maybe now i have 0.01Km total consumtion. Maybe the problem was 0 in thi field.

jneilliii commented 5 years ago

That's an interesting point about the 0. There shouldn't be anything installed with 0.9.8 that wouldn't have installed with 0.9.9. When I get a chance I'll look into resetting one of my plugs to put it into the same state as when you started and see if I can reproduce.

devildant commented 5 years ago

hello @jneilliii , I get a similar error in the console :

Uncaught TypeError: Cannot read property 'current' of undefined
    at packed_plugins.js?56686834:8930
    at Object.q (packed_libs.js?331a1bb5:11317)
    at Object.<anonymous> (packed_plugins.js?56686834:8924)
    at fire (packed_libs.js?331a1bb5:3269)
    at Object.fireWith [as resolveWith] (packed_libs.js?331a1bb5:3399)
    at done (packed_libs.js?331a1bb5:9306)
    at XMLHttpRequest.<anonymous> (packed_libs.js?331a1bb5:9549)

the consumption panel is not visible, and this causes a status recovery problem (the navbar icon turns gray)

devildant commented 5 years ago
ko.utils.arrayForEach(self.arrSmartplugs(),function(item){
    if(item.ip() == data.ip) {
        item.currentState(data.currentState);
        if(data.emeter){
            for (key in data.emeter.get_realtime){
                console.log(key + ' = ' + data.emeter.get_realtime[key]);
                item.emeter.get_realtime[key](data.emeter.get_realtime[key]);
            }
        }
    }
});

item.emeter.get_realtime is undefined

jneilliii commented 5 years ago

@devildant are you in a similar situation where you have 0 total consumption on your hs110?

devildant commented 5 years ago

no I have a total consumption with the application kasa. I tried to uninstall, reset the settings and reinstall, no change. I can open another issue if you prefer.

devildant commented 5 years ago

it may be a problem caused by the firmware of the hs110, my plug works with version 1.0.10

jneilliii commented 5 years ago

Which version of the firmware is causing errors? If you enable debug logging can you post the results of the status checks recorded in the log file so I can see what is returned in the faulty firmware if anything please?

devildant commented 5 years ago

hello @jneilliii , debug log

[2018-11-26 09:10:29,762] DEBUG: Checking status of 192.168.1.43.
[2018-11-26 09:10:29,763] DEBUG: {"system":{"get_sysinfo":{}},"emeter":{"get_realtime":{}}}
[2018-11-26 09:10:29,765] DEBUG: IP 192.168.1.43 is valid.
[2018-11-26 09:10:29,875] DEBUG: Sending command {"system":{"get_sysinfo":{}},"emeter":{"get_realtime":{}}} to 192.168.1.43
[2018-11-26 09:10:29,880] DEBUG: ▒▒y"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.0.10 Build 160304 Rel.082646","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)","mac":"XX:XX:XX:XX:45:D9","deviceId":"80062XX4EFD4","hwId":"797CB3XX103C2","fwId":"848F75775BF7C417E48DA916C0B3FD58","oemId":"0D13F703F0XX7DB248C01A1A","alias":"CR-10S","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM:ENE","updating":0,"rssi":-48,"led_off":0,"latitude":0,"longitude":0}},"emeter":{"get_realtime":{"current":0.014147,"voltage":232.889497,"power":0,"total":143.575000,"err_code":0}}}

Regarding the version, I use the maintenance branch of octoprint (equivalent to version 1.3.10 RC2 I think)

devildant commented 5 years ago

image

devildant commented 5 years ago

image

bvalat commented 5 years ago

Can you try unintall 0.9.9 and install 0.9.8 like i did? Or if you use themify plugin, upgrade to 0.9.10 since i see a bugfix with it.

bvalat commented 5 years ago

Et un petit salut d'un autre français :-) Hi five from another French.

devildant commented 5 years ago

@bvalat c'est mon mauvais anglais qui te fait dire que je suis fr aussi ? :) is it my bad English that makes you say that I am also fr?

@jneilliii here is the exact version that I use (it is a fork of octoprint because I made a pull request: p) ~/oprint/bin/pip install https://github.com/devildant/OctoPrint/archive/1.3.10rc2.zip

bvalat commented 5 years ago

Nope, it's the screenshot in french. Have you tried 0.9.8 or 0.9.10?

devildant commented 5 years ago

haha yes I did not pay attention. i try downgrade and upgrade

devildant commented 5 years ago

Ok, the error is gone, I understand the bug, in version 0.9.8, the emeter section is created in config.yml. unlike version 0.9.10 where this is not the case.

     emeter:
        get_realtime:
          current: 0.014752
          err_code: 0
          power: 0
          total: 143.575
          voltage: 233.238629

however, in version 0.9.10, the information is not updated, "current" stay to 0. image

devildant commented 5 years ago

image

devildant commented 5 years ago

@jneilliii Just a question, why save the status of the plug in config.yml? this could lead to premature wear of the SD card. using the websocket could be a good solution for this case, right?

devildant commented 5 years ago

nothing is updated correctly at the sight level, the current consumption appears at refresh then switches to 0, same thing for the icon in the navbar, if the plug is off, it goes in red to the loading then to the green.

jneilliii commented 5 years ago

I think I see the problem now. Like you mention the 0.9.8 saves the info into config.yaml, where 0.9.10 was trying to go the other way of not storing the data in config.yaml. The reason I was storing the data is due to issues with knockout binding of sub-items of an observableArray. I'll have to rethink the whole thing to figure out a way around that issue. In the interim, I'll probably just check to see if emeter.get_realtime exists and if it doesn't add that key to emeter, or alternatively add it to the default settings.

devildant commented 5 years ago

@jneilliii yes this will allow a users who has not gone through the 0.9.8 to have a functional version. On the other hand, the status of the view are erroned (printer icon always on green, and current power a 0). maybe also a problem with the observables again. the view is updated for a few seconds and then overwritten. it's as if config.yml information overloaded the real status

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity in 14 days. It will be closed if no further activity occurs in 7 days.