GamerClassN7 / HA_Desktop_Companion

App which is using native HA Api to comunicate and report data to HA
50 stars 5 forks source link

Location is not fetched from ipinfo #45

Closed Hellis81 closed 1 year ago

Hellis81 commented 2 years ago

I looked through the code and found this part here in sensors.cs

        public static string queryLocationByIP()
        {
            try
            {
                string info = new WebClient().DownloadString("http://ipinfo.io/");
                return (string) JsonSerializer.Deserialize<JsonObject>(info)["loc"];
            }
            catch (Exception)
            {
                return null;
            }
        }

When I inspect the element I get this path: #loc-string > div > span > span:nth-child(2) > span

Is that what should be used where it says ["loc"]?

GamerClassN7 commented 2 years ago

no it is because JsonSerializer.Deserialize which omit all html and leave only json how ever i think i disable this feature for now because it vas not available in yaml conf and i was not happy to release it when users dont have control on on/of of this feature next release should have it

GamerClassN7 commented 1 year ago

Addressed in new version