eelcohn / home-assistant-ddwrt

DDWRT component/entity for Home Assistant
18 stars 7 forks source link

Trouble using the integration approach #5

Closed sanderant closed 3 years ago

sanderant commented 3 years ago

First thanks so much for updating and making this!!!

I'm running the latest docker image with DD-WRT v3.0-r40559 std (08/06/19) no ssl connection. If I choose integration from the menu I can get to the point where it logs and gives me the items to select. I select a subset of them, but they never populate.

Seeing the below in the error log.

Logger: homeassistant.config_entries Source: custom_components/ddwrt/pyddwrt.py:398 First occurred: 11:08:24 AM (2 occurrences) Last logged: 11:17:23 AM Error setting up entry 192.168.1.1 for ddwrt

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/ddwrt/init.py", line 191, in async_setup_entry if not await router.async_update_sensor_data(): File "/config/custom_components/ddwrt/init.py", line 382, in async_update_sensor_data result = await self._hass.async_add_executor_job(self._router.update_wireless_data) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/ddwrt/pyddwrt.py", line 398, in update_wireless_data "uptime": elements[i + 3], IndexError: list index out of range

eelcohn commented 3 years ago

Can you send me the data from the following URL from your router?

http://192.168.x.y/Status_Wireless.live.asp

PS please check that the data you post doesn't contain any sensitive info :-)

sanderant commented 3 years ago

https://pastebin.com/E7F0m7h9 xxx'd out the sid, but the rest is as is. Figured this was a little less for the ages. Happy Thanksgiving!

eelcohn commented 3 years ago

Raw data:

{wl_mac::70:4F:57:72:6E:2E}{wl_ssid::xxx}{wl_channel::6}{wl_radio::Radio is On}{wl_xmit::Auto}{wl_rate::54 Mbps}{wl_busy::}{wl_active::}{wl_quality::}{wl_ack::}{active_wireless::'00:04:20:16:C4:41','','wl0','3:30:23','54M','54M','LEGACY','-44','-91','47','1000','EC:FA:BC:0B:F7:02','','wl0','4:39:29','72M','54M','HT20','-46','-91','45','1000','00:04:20:23:CD:4E','','wl0','17:00:31','54M','54M','LEGACY','-45','-91','46','1000','E0:4F:43:05:45:39','','wl0','1 day, 5:02:02','65M','26M','HT20','-33','-91','58','1000','00:04:20:16:70:70','','wl0','2 days, 12:07:43','54M','54M','LEGACY','-61','-91','30','780','00:04:20:1E:0F:A3','','wl0','2 days, 17:39:23','54M','54M','LEGACY','-33','-91','58','1000','00:04:20:16:5F:4A','','wl0','2 days, 17:39:22','54M','48M','LEGACY','-63','-91','28','740','00:04:20:1A:6C:2C','','wl0','3 days, 5:18:17','1M','54M','LEGACY','-50','-91','41','1000','D4:9A:20:AD:2F:14','','wl0','7 days, 22:26:48','1M','54M','LEGACYPS','-58','-91','33','840','68:C6:3A:D6:C7:98','','wl0','25 days, 20:42:12','72M','54M','HT20','-46','-91','45','1000','98:F4:AB:B3:94:D2','','wl0','25 days, 20:42:12','72M','36M','HT20','-54','-91','37','920','00:04:20:F7:BC:DA','','wl0','34 days, 13:47:36','1M','72M','HT20','-55','-91','36','900','00:0E:8E:2C:C1:16','','wl0','43 days, 11:30:34','1M','36M','LEGACY','-64','-91','27','720','48:3F:DA:6C:97:23','','wl0','55 days, 6:37:56','72M','6M','HT20','-65','-91','26','700','00:55:DA:52:A7:09','','wl0','71 days, 23:33:28','19M','43M','HT20','-24','-91','67','1000','9A:75:E4:37:A0:78','','wl1','20:46:20','200M','6M','VHT40PS','-53','-92','39','940','A2:C7:1A:46:A8:4B','','wl1','1 day, 1:16:00','135M','6M','VHT40PS','-69','-92','23','620','88:E9:FE:4C:A9:85','','wl1','7 days, 7:01:03','24M','6M','VHT80PS','-63','-92','29','740','B4:CE:F6:9D:14:9F','','wl1','18 days, 19:56:28','270M','400M','VHT80','-58','-92','34','840'}{active_wds::}{assoc_count::15}{packet_info::SWRXgoodPacket=184927842;SWRXerrorPacket=11;SWTXgoodPacket=506441918;SWTXerrorPacket=284;}{uptime:: 15:26:23 up 111 days, 4:23, load average: 0.00, 0.01, 0.00}{ipinfo:: IP: 6.2.1.1}

Formatted:

{wl_mac::70:4F:57:72:6E:2E}
{wl_ssid::xxx}
{wl_channel::6}
{wl_radio::Radio is On}
{wl_xmit::Auto}
{wl_rate::54 Mbps}
{wl_busy::}
{wl_active::}
{wl_quality::}
{wl_ack::}
{active_wireless::
'00:04:20:16:C4:41','','wl0','3:30:23','54M','54M','LEGACY','-44','-91','47','1000',
'EC:FA:BC:0B:F7:02','','wl0','4:39:29','72M','54M','HT20','-46','-91','45','1000',
'00:04:20:23:CD:4E','','wl0','17:00:31','54M','54M','LEGACY','-45','-91','46','1000',
'E0:4F:43:05:45:39','','wl0','1 day, 5:02:02','65M','26M','HT20','-33','-91','58','1000',
'00:04:20:16:70:70','','wl0','2 days, 12:07:43','54M','54M','LEGACY','-61','-91','30','780',
'00:04:20:1E:0F:A3','','wl0','2 days, 17:39:23','54M','54M','LEGACY','-33','-91','58','1000',
'00:04:20:16:5F:4A','','wl0','2 days, 17:39:22','54M','48M','LEGACY','-63','-91','28','740',
'00:04:20:1A:6C:2C','','wl0','3 days, 5:18:17','1M','54M','LEGACY','-50','-91','41','1000',
'D4:9A:20:AD:2F:14','','wl0','7 days, 22:26:48','1M','54M','LEGACYPS','-58','-91','33','840',
'68:C6:3A:D6:C7:98','','wl0','25 days, 20:42:12','72M','54M','HT20','-46','-91','45','1000',
'98:F4:AB:B3:94:D2','','wl0','25 days, 20:42:12','72M','36M','HT20','-54','-91','37','920',
'00:04:20:F7:BC:DA','','wl0','34 days, 13:47:36','1M','72M','HT20','-55','-91','36','900',
'00:0E:8E:2C:C1:16','','wl0','43 days, 11:30:34','1M','36M','LEGACY','-64','-91','27','720',
'48:3F:DA:6C:97:23','','wl0','55 days, 6:37:56','72M','6M','HT20','-65','-91','26','700',
'00:55:DA:52:A7:09','','wl0','71 days, 23:33:28','19M','43M','HT20','-24','-91','67','1000',
'9A:75:E4:37:A0:78','','wl1','20:46:20','200M','6M','VHT40PS','-53','-92','39','940',
'A2:C7:1A:46:A8:4B','','wl1','1 day, 1:16:00','135M','6M','VHT40PS','-69','-92','23','620',
'88:E9:FE:4C:A9:85','','wl1','7 days, 7:01:03','24M','6M','VHT80PS','-63','-92','29','740',
'B4:CE:F6:9D:14:9F','','wl1','18 days, 19:56:28','270M','400M','VHT80','-58','-92','34','840'}
{active_wds::}
{assoc_count::15}
{packet_info::SWRXgoodPacket=184927842;SWRXerrorPacket=11;SWTXgoodPacket=506441918;SWTXerrorPacket=284;}
{uptime:: 15:26:23 up 111 days, 4:23, load average: 0.00, 0.01, 0.00}
{ipinfo:: IP: 6.2.1.1}
eelcohn commented 3 years ago

@sanderant thank you, and a happy thanksgiving to you as well

Can you (temporarily) add the following to your configuration.yaml:

logger:
  logs:
    custom_components.ddwrt.config_flow: debug
    custom_components.ddwrt.pyddwrt: debug

This will enable debug logging for some parts of the DD-WRT integration. You should see a lot more logged in your logfile. Can you post the logs related to DD-WRT? Many thanks in advance

sanderant commented 3 years ago

Sorry for the delay, here you go. I can send the whole grepped part of the log, but this is the end of the occurrences of 'grep custom_components.ddwrt home-assistant.log'

2020-11-27 12:54:11 DEBUG (SyncWorker_5) [custom_components.ddwrt.pyddwrt] DDWrt.update_network_data: Updating Networking data...
2020-11-27 12:54:11 DEBUG (SyncWorker_5) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: Connecting to http://192.168.1.1/Networking.live.asp
2020-11-27 12:54:11 DEBUG (SyncWorker_5) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: %s
2020-11-27 12:54:12 DEBUG (SyncWorker_2) [custom_components.ddwrt.pyddwrt] DDWrt.update_router_data: Updating router data...
2020-11-27 12:54:12 DEBUG (SyncWorker_2) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: Connecting to http://192.168.1.1/Status_Router.live.asp
2020-11-27 12:54:12 DEBUG (SyncWorker_2) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: %s
2020-11-27 12:54:12 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt.update_router_data: Updating WAN data...
2020-11-27 12:54:12 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: Connecting to http://192.168.1.1/Status_Internet.live.asp
2020-11-27 12:54:12 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: %s
2020-11-27 12:54:13 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt.update_wireless_data: Updating wireless data...
2020-11-27 12:54:13 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: Connecting to http://192.168.1.1/Status_Wireless.live.asp
2020-11-27 12:54:13 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: {'active_wds': '', 'uptime': ' 12:54:13 up 112 days,  1:51,  load average: 0.18, 0.05, 0.01', 'ipinfo': ' IP: 67.243.133.186'}
  File "/config/custom_components/ddwrt/__init__.py", line 191, in async_setup_entry
  File "/config/custom_components/ddwrt/__init__.py", line 382, in async_update_sensor_data
  File "/config/custom_components/ddwrt/pyddwrt.py", line 398, in update_wireless_data
eelcohn commented 3 years ago

No worries for the delay, we all have lives other than the awesome Home Assistant stuff. I'll try to take a look at it this weekend.

eelcohn commented 3 years ago

Are you sure that the following line hasn't changed due to the grep command?

2020-11-27 12:54:13 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: {'active_wds': '', 'uptime': ' 12:54:13 up 112 days,  1:51,  load average: 0.18, 0.05, 0.01', 'ipinfo': ' IP: 67.243.133.186'}

Because if this is indeed the full received data, then I probably have found the issue :)

sanderant commented 3 years ago

These look like the lines around it.

[zan@nucky ha]$ grep -A30 -B2 ' 12:54:13 up' home-assistant.log 2020-11-27 12:54:13 DEBUG (SyncWorker_1) [homeassistant.components.nmap_tracker.device_tracker] Scanner initialized 2020-11-27 12:54:13 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.243:80/fieldValue?name=power 2020-11-27 12:54:13 DEBUG (SyncWorker_0) [custom_components.ddwrt.pyddwrt] DDWrt._get_ddwrt_data: received data: {'active_wds': '', 'uptime': ' 12:54:13 up 112 days, 1:51, load average: 0.18, 0.05, 0.01', 'ipinfo': '&nbsp;IP: 67.243.133.186'} 2020-11-27 12:54:14 DEBUG (MainThread) [aioharmony.hubconnector_xmpp] 192.168.1.217: Connected to hub 2020-11-27 12:54:14 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event device_registry_updated[L]: action=update, device_id=2e65f13d86fe42cd85b9dd9ca0d282cc> 2020-11-27 12:54:14 DEBUG (MainThread) [homeassistant.components.iqvia] Finished fetching 10025 disease_index data in 3.559 seconds 2020-11-27 12:54:14 DEBUG (MainThread) [homeassistant.components.iqvia] Finished fetching 10025 asthma_index data in 3.561 seconds 2020-11-27 12:54:14 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=camera.okx, old_state=None, new_state=<state camera.okx=idle; access_token=26b99d7e3e33eaa26410ea5aa6cc5491792ef18dc76d55cb67e02b373f05cd83, friendly_name=OKX, entity_picture=/api/camera_proxy/camera.okx?token=26b99d7e3e33eaa26410ea5aa6cc5491792ef18dc76d55cb67e02b373f05cd83, supported_features=0 @ 2020-11-27T12:54:14.184600-05:00>> 2020-11-27 12:54:14 DEBUG (MainThread) [aioharmony.responsehandler] 192.168.1.217: Registering handler get_current_state with UUID 0993beb3-80ff-43ac-add5-f6d7510512ea that will expire on 2020-11-27 12:55:14.185064-05:00 2020-11-27 12:54:14 DEBUG (MainThread) [aioharmony.hubconnector_xmpp] 192.168.1.217: Sending payload: {'xmlns': 'connect.logitech.com', 'mime': 'vnd.logitech.connect/vnd.logitech.statedigest?get'} verb=get:format=json 2020-11-27 12:54:14 DEBUG (MainThread) [aioharmony.harmonyclient] 192.168.1.217: Retrieving HUB information 2020-11-27 12:54:14 INFO (SyncWorker_5) [homeassistant.loader] Loaded scrape from homeassistant.components.scrape 2020-11-27 12:54:14 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream from="connect.logitech.com" id="b856feea" version="1.0"> 2020-11-27 12:54:14 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:features xmlns="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanisms></stream:features> 2020-11-27 12:54:14 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.1.1 for ddwrt Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/ddwrt/__init__.py", line 191, in async_setup_entry if not await router.async_update_sensor_data(): File "/config/custom_components/ddwrt/__init__.py", line 382, in async_update_sensor_data result = await self._hass.async_add_executor_job(self._router.update_wireless_data) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/ddwrt/pyddwrt.py", line 398, in update_wireless_data "uptime": elements[i + 3], IndexError: list index out of range

eelcohn commented 3 years ago

Can you try the 1.1.1 branch I just published?

sanderant commented 3 years ago

Hey, I tried the 1.1.1 branch before and after merging, and the integration now loads. Yay!

There are two other issues, which may be due to my initial integration not working or something else.

1) If I choose options on the ddwrt in the integrations area, I get a notification box which won't go away saying "Please wait while the integration is being installed" I have to reload the web ui to get rid of it.

2) There are some fields which are being misidentified or the sensors aren't working correctly. There were a bunch of munged device entries with partial mac addresses, but those have gone away since I reinstalled in the integration. The binary wan connection reads false, yet I'm posting here (maybe this is an odd terminology?). Also what card should I use for the monthly traffic notification? I tried the camera card, but it doesn't seem to load, even though the image url is correct.

As always thanks for working on this as it is awesome!

sanderant commented 3 years ago

OK looking at the output I see that you are getting the "correct" data and the router is reporting it incorrectly, sorry.

I'm still looking at getting the camera working, but maybe it's just a field in the card.

I'm still trying figure out the device opposite entity areas and how I might customize them. It's unclear to me how the away is registered, is it based on active dhcp lease? For example my PC shows as away currently. As you're getting this from the router (presumably) I'll take a look there.

One last item is some of the outputs aren't showing up as numbers, but instead as states (I'm sorry I'm not sure the exact terminology) an example would be cpu_temp shows up correctly, whereas other items like load_average1, wl_count, wl_rx_packet_error, ip_connections show up a state with a distinct number.

Thanks as always for all your hard work on this. I hope you are planning on getting this included as part of the official integration at some point.

eelcohn commented 3 years ago

Hey, I tried the 1.1.1 branch before and after merging, and the integration now loads. Yay! Good to hear that!

There are two other issues, which may be due to my initial integration not working or something else.

If I choose options on the ddwrt in the integrations area, I get a notification box which won't go away saying "Please wait while the integration is being installed" I have to reload the web ui to get rid of it.

Okay, I haven't seen this issue yet, so I'll have to figure a way out to recreate that issue.

There are some fields which are being misidentified or the sensors aren't working correctly. There were a bunch of munged device entries with partial mac addresses, but those have gone away since I reinstalled in the integration.

This might be caused by the problems you encountered when installing v1.0.0.

Also what card should I use for the monthly traffic notification? I tried the camera card, but it doesn't seem to load, even though the image url is correct.

I've added this as a camera (camera.traffic), but I'm not sure if I'll keep this in future releases. Other integrations use the recorder component to store this kind of information, and then use a lovelace card to generate the graphic.

As always thanks for working on this as it is awesome!

Thanks! It's good to hear that this integration is of use for other people as well :)

I'm still trying figure out the device opposite entity areas and how I might customize them. It's unclear to me how the away is registered, is it based on active dhcp lease? For example my PC shows as away currently. As you're getting this from the router (presumably) I'll take a look there.

Do you mean the devices in the device_tracker? This component was changed some time ago, and I'm not sure how to correctly implement the device_tracker in the ddwrt-integration yet, so basically it's still 'under construction'. I'm open to suggestions if anyone is able to help me with this.

One last item is some of the outputs aren't showing up as numbers, but instead as states (I'm sorry I'm not sure the exact terminology) an example would be cpu_temp shows up correctly, whereas other items like load_average1, wl_count, wl_rx_packet_error, ip_connections show up a state with a distinct number.

I think this is due to the Unit-Of-Measurement. cpu_temp is measured in Celcius, but ip_connections is just a number, so it hasn't got a Unit-Of-Measurement right now. I'm also open to suggestions for these :) You can check which entities have an unit_of_measurement in the UI at Developer Tools -> States.

eelcohn commented 3 years ago

One last thing: if you run into other issues, please open for each one a seperate issue. That way I can keep track of each issue :)

sanderant commented 3 years ago

Thanks for everything I'll close this issue now and open up others like you suggested. The units of measurement will be the first item as the rest could easily be due to some problem in my config and I've found stale items tend to linger the more HA moves away from the old school YAML. I'll uninstall the integration see what I can do to clean it up and then restart and see if I can offer some suggestions on the unit of measurements.

eelcohn commented 3 years ago

As for the monthly traffic: the camera.traffic device will be removed in a future release; see https://github.com/eelcohn/home-assistant-ddwrt/issues/8 for more details.

eelcohn commented 3 years ago

As for the wan_connected binary sensor: I might have found out why this isn't working for you. Have you set the language in your router to something different than English?

sanderant commented 3 years ago

It doesn't look like it: root@DD-WRT:~# nvram show |grep lang size: 40853 bytes (24683 left) language=english

It looks to be correct, but I can try resetting it. I've been meaning to send some updates in the form of new issues, but I'll try that new version first in case you've fixed one of the issues I was having. I have been seeing this: 2020-12-08 17:48:38 WARNING (SyncWorker_37) [custom_components.ddwrt.pyddwrt] update_wireless_data(): invalid number of elements in active_wireless (expected 11, found 222)

I'll see if I can poke around on IRC and the dd-wrt forum if there are any clues what might be odd with my set up.