i8beef / HomeAutio.Mqtt.GoogleHome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Online status

sognen opened this issue · comments

Hi
I got homegraph configured and I can see from the log that it is being updated. My devices are however reported being offline. On the google developer site, it appears that online status is part of the response to the device.query call - https://developers.google.com/assistant/smarthome/reference/rest/v1/devices/query#queryresponsepayload.

I am not sure if there is something wrong with my home graph setup or if "online status" is something that is not currently implemented.

Any insight into this is much appreciated.

Cato

There is nothing right now that decorates that on if it isn't provided (You could fake it with an "online" state property using a "Static" mapper to true....) there probably should be. Ill add something in the next release for that and the undocumented "status" property.

Where are you seeing it being "reported being offline" though? I haven't seen anywhere that tells you that, nor have I found any issues around this being missing in terms of functionality, so you must be looking at something I haven't seen before.

Nest hub has these quick tiles that will tell you the status of each device, for example, for a tile for a bulb it will tell you whether it is off or on and brightness in percentage. Example: https://9to5google.com/wp-content/uploads/sites/4/2020/10/chrome_0PrmdOKA42.png?w=1000

Tiles for devices connected through Homeautio just say offline. Devices do however respond to voice commands.

I followed your advice and added the static online:true. When issueing a voice command I can see the device changing status to "online" for a brief moment for then to change status to offline again.

Response with online to true:
{"requestId":"14844550806288342576","payload":{"devices":{"livingroom/fan":{"on":true,"online":true,"currentFanSpeedSetting":"medium","currentFanSpeedPercent":74,"timerRemainingSec":0,"timerPaused":false}}}

I then see a response to query which lists device without device states:

{"inputs":[{"intent":"action.devices.QUERY","payload":{"devices":[{"id":"livingroom/thermostat"},{"id":"livingroom/ac"},{"id":"livingroom/fan"},{"id":"livingroom/airPurifier"},{"id":"livingroom/airFreshener"},{"id":"bedroom/thermostat"},{"id":"other/camera/danmarksplass"},{"id":"other/camera/festplassen"},{"id":"other/camera/floyen"},{"id":"other/camera/puddefjordsbroen"},{"id":"other/camera/torgallmenningen"},{"id":"bedroom/vacuumCleaner"}]}],"requestId":"7138190270187865614"}

Could it be the second response that returns offline status?

Got ya. None of mine are showing offline even with the current setup here. While Ill definitely include the "online" status in a future update for completeness, and because Google's own schema files dictate it be present (even though it seems to work without), I'm wondering if you are seeing a different issue...

That second "response" looks like a QUERY request body, not a response to a request, just FYI.

Is your HomeGraph setup working correctly? The behavior you are describing sounds like the initial response works, and then the HomeGraph update fires and something goes wrong. Do you see anything like "Google Home Graph update failed for devices" in the logs?

First, thank you for your assistance. Second, my devices are"online" now.
I found an error I missed yesterday in my log. The error was Value cannot be null. (Parameter 'source')" errors. This reminded me of a device that I have configured in homeautio but never gotten around to feeding it with values/states.

After publishing some default values to it, the other devices started to come "online" in the nest hub. I also removed the online:true added yesterday.

Conscious that this may be a coincidence, but it appears to me that if a device is without state values other devices does not report online as they should. Under you can find the error that prompted me to populate the device with values.

2020-11-27 05:00:10.497 +00:00 [Error] Connection id ""0HM4I937OBB59"", Request id ""0HM4I937OBB59:00000001"": An unhandled exception was thrown by the application.
System.ArgumentNullException: Value cannot be null. (Parameter 'source')
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at HomeAutio.Mqtt.GoogleHome.Models.State.Device.GetGoogleStateFlattened(IDictionary2 stateCache) in /app/HomeAutio.Mqtt.GoogleHome/Models/State/Device.cs:line 137 at HomeAutio.Mqtt.GoogleHome.Models.State.Device.GetGoogleQueryState(IDictionary2 stateCache) in /app/HomeAutio.Mqtt.GoogleHome/Models/State/Device.cs:line 76
at HomeAutio.Mqtt.GoogleHome.IntentHandlers.QueryIntentHandler.<>c__DisplayClass5_0.b__8(String queryDeviceId) in /app/HomeAutio.Mqtt.GoogleHome/IntentHandlers/QueryIntentHandler.cs:line 77
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at HomeAutio.Mqtt.GoogleHome.IntentHandlers.QueryIntentHandler.Handle(QueryIntent intent) in /app/HomeAutio.Mqtt.GoogleHome/IntentHandlers/QueryIntentHandler.cs:line 69
at HomeAutio.Mqtt.GoogleHome.Controllers.GoogleHomeController.Post(Request request) in /app/HomeAutio.Mqtt.GoogleHome/Controllers/GoogleHomeController.cs:line 72
at lambda_method(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean i
sCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at HomeAutio.Mqtt.GoogleHome.RequestResponseLoggingMiddleware.LogResponse(HttpContext context) in /app/HomeAutio.Mqtt.GoogleHome/RequestResponseLoggingMiddleware.cs:line 108
at HomeAutio.Mqtt.GoogleHome.RequestResponseLoggingMiddleware.Invoke(HttpContext context) in /app/HomeAutio.Mqtt.GoogleHome/RequestResponseLoggingMiddleware.cs:line 42
at Microsoft.AspNetCore.Builder.Extensions.UsePathBaseMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
2020-11-27 05:00:10.510 +00:00 [Debug] Connection id ""0HM4I937OBB59"" completed keep alive response.

Ah that makes sense, yes. It's interesting that Google interprets an error as "all requested devices are now offline". This would happen anytime a badly configured device is part of the request and has a null topic, but no valueMap defined.

I am actually rewriting how this works at the moment, and the new version already has a fix for this incorporated now, thanks to you pointing this out. Thank you!

Great, thanks for your help.

Added online status as default on all devices now in 2.0.