Amateur-God / home-assistant-technitiumdns

This custom integration allows you to integrate TechnetiumDNS with Home Assistant, providing sensors for various DNS statistics.
GNU General Public License v3.0
12 stars 1 forks source link

Missing Sensors? Fresh Install #35

Closed Krystm closed 3 weeks ago

Krystm commented 3 weeks ago

Problem/Motivation

Did the HACS Install (2.2.3), Linked as Admin-Level account. I can pause / stop blocking. However No sensors were found / created for the stats. Currently on HA 10.0.2.

Expected behavior

That sensors would auto show on the device. Have Removed and Re-Added Multiple Times.

Actual behavior

I get the buttons to enable / disable (and they tested working), but no list of sensor items.

Steps to reproduce

Clean Install is all I did. I did try adding the config to the yaml as well but instructions are somewhat unclear if all you need to do for the HACS install is just add the custom integration and install (which figured since also a warning saying it wouldn't use any config from the yaml) So not sure what else to try. I did try to do due diligence to see if anyone else had reported any issues etc but couldn't find any hence this issue.

Screenshot 2024-10-14 at 7 37 59 AM
Amateur-God commented 3 weeks ago

I have tried to recreate this on a fresh install on a new VM. However, so far, I haven't had any luck. Do you have any other custom integrations or plugins that could be causing a conflict anywhere?

Krystm commented 3 weeks ago

I do have quite an extensive setup. Is there anything I should look for specifically? I would figure should just be data pulling from the DNS Server but I can certainly look. Like I stated the Buttons to disable / Enable and temp disable timer buttons all work. So the connection seems to be there. I dont see any logs about failures, but not 100 sure where to look for specific logs. If ya can point me in the right direction maybe can find it.

Amateur-God commented 3 weeks ago

I do have quite an extensive setup. Is there anything I should look for specifically? I would figure should just be data pulling from the DNS Server but I can certainly look. Like I stated the Buttons to disable / Enable and temp disable timer buttons all work. So the connection seems to be there. I dont see any logs about failures, but not 100 sure where to look for specific logs. If ya can point me in the right direction maybe can find it.

the only thing i can think of is if for some reason another integration you have has the same sensor names or entry_ID as these however that would only happen if for some reason another integration uses technitium as the domain name of the integration.

the only other thing i could think of would be something in the settings for your DNS

Krystm commented 3 weeks ago

Yeah Im checking that right now, I just VLANed out my networks and separated my IoT from everything else and this was the reason to run Technitium. However, the HA device does have access to the device, but I am checking the user account / api token if maybe somehow doesnt have permissions. What is the suggested access for this? I was thinking admin since you are able to enable/disable blocking, but wasn't sure on that. I am usually about least privilege, but understand the need with that.

Krystm commented 3 weeks ago

Also I do have a local domain I run. Not AD or anything but I am running DNS zones .local etc. Would that make a difference In the settings? Looking at the Setup the only question maybe I messed up is "Server Name" is that this?

Screenshot 2024-10-15 at 8 31 47 AM Screenshot 2024-10-15 at 8 32 10 AM
Amateur-God commented 3 weeks ago

so on mine i created a new user called hasse and gave it DNS Administrator role, That the highest level of access required allows it to do DNS stuff like enable/disable ad blocking without having full admin access to settings

image

The server name in the config is just what you want it to be called in HA for example i have mine as DNS1 and DNS2

did you put the IP in for the dns server or did you use a local domain like dns.local?

for the dns server domain on your screenshots, technitium isnt a FQDN an fqdn would be something like dns.local but that shouldnt affect the integration as the integration doesnt call that from the API

what do your logging settings look like in Technitium?

Amateur-God commented 3 weeks ago

also can you enable debug logging and try to readd the integration and see if you get any errors?

Krystm commented 3 weeks ago
Screenshot 2024-10-15 at 8 51 12 AM

Standard default logging, I am using the IP Address and Port of the Server that is exposed on that vlan and do have the webservice listening on that IP. (I'd suspect issues with even the buttons if that was incorrect). So the only thing that should matter on the config from the Technitium Side is the API Key, IP (with port?) and then the User it belongs to. I have an exporter account I will give DNS Admin to. Ill check debug gotta turn that on assuming youre looking for HA logs?

Amateur-God commented 3 weeks ago

Ill check debug gotta turn that on assuming youre looking for HA logs?

yep sorry i meant HA logs, also do you have anything API related in the Technitium logs?

Krystm commented 3 weeks ago

So this is odd. I can access the DNS Server from HA's Terminal however I am seeing timeouts on the API reading sensors. But the main 6 buttons are there.

Screenshot 2024-10-15 at 9 00 07 AM

Checking the Tech logs now

Amateur-God commented 3 weeks ago

ill increase the timout and handle the top error too, im about to release a new beta ill add these to it to see if it fixes your error

Krystm commented 3 weeks ago

Ok Sounds good! Let me know if I can be of any help. I generated a new API Token since I had changed the user access to DNS Admin and that token connected but buttons dont work anymore. So maybe needs a higher level of administration, but I added my exporter to the admin group like your screenshot.

Krystm commented 3 weeks ago

also can see the session in tech. Im gonna turn on debug, delete/re-add the add on.

Screenshot 2024-10-15 at 9 11 38 AM
Amateur-God commented 3 weeks ago

Ok Sounds good! Let me know if I can be of any help. I generated a new API Token since I had changed the user access to DNS Admin and that token connected but buttons dont work anymore. So maybe needs a higher level of administration, but I added my exporter to the admin group like your screenshot.

i may have changed my perms and forgot about it but these are the perms required

image

Amateur-God commented 3 weeks ago

this hasnt been tested yet and i cant guarantee i havent completely broken stuff but if you want to try it out before ive had chance to test it you are welcome to

https://github.com/Amateur-God/home-assistant-technitiumdns/releases/tag/v2.3.0-Beta.1

Krystm commented 3 weeks ago

Ok heres the debug am I using the wrong URL by chance?

Screenshot 2024-10-15 at 9 19 06 AM
Krystm commented 3 weeks ago

Also How Do I deploy the Beta From HACS? It sees it in the top right but I cant remeber where I saw where you can choose the version you install. Do I have to re add the Repo?

Amateur-God commented 3 weeks ago

Also How Do I deploy the Beta From HACS? It sees it in the top right but I cant remeber where I saw where you can choose the version you install. Do I have to re add the Repo?

you just click the 3 dots and there should be a choose version option then tick enable beta or enable pre releases or something then just choose the beta in the dropdown

Krystm commented 3 weeks ago

I removed the install from HACS and then Re-Installed. Ill let ya know give me a few. Does the URL look right? just http://IP:Port right?

Krystm commented 3 weeks ago

Seems like its not connecting. I know it does have access, I can ssh from the HA terminal and have seen the Session in tech. Ill try deleting the session maybe thats blocking it.

Screenshot 2024-10-15 at 9 34 45 AM
Amateur-God commented 3 weeks ago

I removed the install from HACS and then Re-Installed. Ill let ya know give me a few. Does the URL look right? just http://IP:Port right?

Yeah that should be correct as long as it's the correct IP and port

Amateur-God commented 3 weeks ago

I have mine on separate VLANs too so it does work across VLANs

Krystm commented 3 weeks ago

Gonna check my firewall logs, I doubt they will show anything though since I am using the local interface on that subnet to try to link to it. It almost has to be Tech denying the login. Let me try the Full admin account one more time see if its any different. Maybe something weird with the API. I checked permissions were all the same on this side.

Krystm commented 3 weeks ago

Nothing in FW but did find this in the Tech logs.

[2024-10-15 14:33:38 UTC] [172.31.246.3:45110] Check for update was done {updateAvailable: False;} System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. ---> System.TimeoutException: A task was canceled. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at TechnitiumLibrary.Net.Http.Client.HttpClientNetworkHandler.InternalSendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Http\Client\HttpClientNetworkHandler.cs:line 99 at TechnitiumLibrary.Net.Http.Client.HttpClientNetworkHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Http\Client\HttpClientNetworkHandler.cs:line 242 at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) --- End of inner exception stack trace --- --- End of inner exception stack trace --- at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts) at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at DnsServerCore.WebServiceApi.GetCheckForUpdateJsonData() in Z:\Technitium\Projects\DnsServer\DnsServerCore\WebServiceApi.cs:line 80 at DnsServerCore.WebServiceApi.CheckForUpdateAsync(HttpContext context) in Z:\Technitium\Projects\DnsServer\DnsServerCore\WebServiceApi.cs:line 104

Krystm commented 3 weeks ago

Ok, Not sure where else to go but I did make manual API requests in the browser and it works there so I know the keys are good at least.

Screenshot 2024-10-15 at 9 58 19 AM
Krystm commented 3 weeks ago

No differences between the exporter or admin account. Doesn't seem to be connecting at all. Anything can think of prereq for HA that maybe needs enabled? I feel like I have some other API pulls / sensors from other integrations going.

Also just tested the same API Pull from the Terminal inside HA to make sure it could talk to the Tech server and it replied back with all the account info etc. So I guess let me know what else I should look at, preexisting sensors etc that maybe blocking like you had first mentioned?

Amateur-God commented 3 weeks ago

tbh we have looked at everything i could think of i noticed my technitium server needed updating so i just updated to the latest version to make sure no api stuff had changed and mine is pulling all of the sensors and everything still.

without being able to recreate this there isnt much i can do to fix it unfortunately, everything is pointing to an issue with your home assistant integration not being able to connect to the technitium server but then you are able to connect to it via terminal which tbh puts me at a loss tbh. i dont really think there is much i can do at the moment.

do you have anything in your technitium logs about connection refused or anything like that?

Amateur-God commented 3 weeks ago

also if you go to your home assistant logs for core and click load full logs is there anything in there related to the integration

Krystm commented 3 weeks ago

I looked by IP and didn't see anything there. I stay bleeding edge though so maybe a random update will fix it lol. I have like 1 or 2 other things I'm gonna try to see if it takes. Cause It used to connect and I even had the buttons AND they worked. Just didnt have the logs. Now it doesnt seem to connect at all. Ok Ill check full logs one sec.

Krystm commented 3 weeks ago

2024-10-15 10:33:26.242 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration technitiumdns which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-10-15 10:33:44.155 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform technitiumdns is taking over 10 seconds. 2024-10-15 10:33:54.246 ERROR (MainThread) [custom_components.technitiumdns.api] Attempt 1: Error fetching data from api/user/checkForUpdate: 2024-10-15 10:34:19.249 ERROR (MainThread) [custom_components.technitiumdns.api] Attempt 2: Error fetching data from api/user/checkForUpdate: 2024-10-15 10:34:27.178 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('technitiumdns', '01JA8BA3XW5MBMP4B7X63841X8'): 194496.441249347, ('wled', 'b91385237ab674f109b0508cb7e1e5ff'): 194500.67136907} 2024-10-15 10:34:34.156 ERROR (MainThread) [homeassistant.components.sensor] Setup of platform technitiumdns is taking longer than 60 seconds. Startup will proceed without waiting any longer. 2024-10-15 10:34:44.252 ERROR (MainThread) [custom_components.technitiumdns.api] Attempt 3: Error fetching data from api/user/checkForUpdate: 2024-10-15 10:34:44.254 ERROR (MainThread) [custom_components.technitiumdns.sensor] Error fetching data: Error fetching data from api/user/checkForUpdate after 3 attempts: 2024-10-15 10:34:44.256 ERROR (MainThread) [custom_components.technitiumdns.sensor] Could not initialize TechnitiumDNS: Error fetching data: Error fetching data from api/user/checkForUpdate after 3 attempts: File "/config/custom_components/technitiumdns/api.py", line 31, in fetch_data File "/config/custom_components/technitiumdns/api.py", line 29, in fetch_data File "/config/custom_components/technitiumdns/sensor.py", line 57, in _async_update_data Technitiumdns_update_info = await self.api.check_update() File "/config/custom_components/technitiumdns/api.py", line 82, in check_update File "/config/custom_components/technitiumdns/api.py", line 41, in fetch_data File "/config/custom_components/technitiumdns/sensor.py", line 105, in _async_update_data File "/config/custom_components/technitiumdns/sensor.py", line 29, in async_setup_entry File "/config/custom_components/technitiumdns/sensor.py", line 38, in async_setup_entry

Amateur-God commented 3 weeks ago

this is strange i cant see any reason why it wouldnt connect, you are doing http://ip:port right for the integration setup

Krystm commented 3 weeks ago

correct http://172.x.x.x:5380

Amateur-God commented 3 weeks ago

in home assistant you go into dev tools, go to states and where it says filter entities click there and put in dns or whatever name you gave the integration when you added it do they show up in there?

Krystm commented 3 weeks ago

Nada - I even tried GPT rewriting the api.py and sensor.py as it had some suggestions but no changes. It really does seem like its just being blocked from sending API commands, but so weird they work from the terminal driectly

Screenshot 2024-10-15 at 10 54 01 AM Screenshot 2024-10-15 at 10 55 51 AM
Amateur-God commented 3 weeks ago

fair warning GPT isnt great at python or at APIs even if you provide it with documents, i provided it with the latest api docs for Technitium because i didnt want to read through a wall of text and asked it to tell me if there was any new API endpoints i can use and it just straight up made some up and i trusted it which lead me to creating sensors and api calls for them to find out they didnt actually exist.

ive also found when ive tried to use it before to help me debug stuff in discord.py when i first started coding it would just straight up make stuff up that dont actually exist and give me suggestions to improve my code which would just break it

unfortunately, i cant recreate this issue, i thought i had a moment a go but then it was just the browser being slow to update and sadly without being able to recreate it and this being the only issue of this type it seems like its an issue somewhere in your internal network and not a bug with the integration and as such im going to have to close the issue.

the only thing i can suggest is checking your interVLAN firewall rules and making sure there is nothing there that could be blocking anything

Amateur-God commented 3 weeks ago

you could also try V2.3.0-Beta.3 out and see if the increased timeout helps

Krystm commented 3 weeks ago

I just checked my PAFW and its not crosssing any vlans so intervlanning isn't the issue there. But Im thinking about making a virtual interface in another vlan and shooting it over to see if maybe that could do it.

so funny thing... that screen shot says 2.2.3 should be the beta. I removed the Repo in HACS and re added it, it asked what version which I chose the latest one in beta. So thats also weird. But not if you dont change that in the betas. But I am updating from .1 to .3 to see if it helps.

As far as GPT, absolutely understand, I had a lot of the same experiences with it, just kinda was going all or nothing at this point lol.

Amateur-God commented 3 weeks ago

so funny thing... that screen shot says 2.2.3 should be the beta. I removed the Repo in HACS and re added it, it asked what version which I chose the latest one in beta. So thats also weird. But not if you dont change that in the betas. But I am updating from .1 to .3 to see if it helps.

it should say 2.3.0 as thats what the manifest says, did you restart home assistant after redownloading the beta?

it should say it here in HACS

image where the box thing is thats version downloaded

and here in integration it should say 2.3.0

image

Krystm commented 3 weeks ago

Yes it showing 2.3.0 there now. and I was doing restarts of HA after each install / removal (not full reboot) but a full HA service restart.

Amateur-God commented 3 weeks ago

well unfortunately im out of ideas, its definitely not an issue with the integration as i have tried multiple times to reproduce it and couldn't and this is the only issue like this ive had opened.

i would look through any settings for Firewalls or AppArmor on the hosts of either and see if there is anything on either that could be preventing the connection.

personally i recommend using HAOS in a VM for full HA features

Krystm commented 3 weeks ago

I use a dedicated NUC for it has been awesome for 3 years now lol. I appreciate the effort and Ill let ya know when I figure it out. Even if it ends up just being a random update that fixes it. I have had issues with the NUT server between updates and then the next hotfix of haos fixed it lol. So im not too worried I just love stats and data so was hoping to pull these in like my Pi-Hole that I use for my IoT Devices (more for the easier tracking and cooler interface lol since technically both could block.)

Amateur-God commented 3 weeks ago

yeah i get that, if you work out what caused it please let me know.

also if you want to find out about any updates or anything i have a discord for all my projects and releases where some peopel also go to ask questions/help it is pretty dead though as it only really gets activity when something needs fixing

feel free to join the discord