DewGew/Domoticz-Google-Assistant

ERROR - 400 Client Error: Bad Request for url: https://homegraph.googleapis.com/v1/dev ... tification

mealgi opened this issue · 7 comments

Describe the bug:
I have 50 devices declared in Domoticz version 2022.1 which are interfaced with Domoticz-Google-Assistant v1.11.10
The interface was operating correctly so far.

I have recently upgraded Domoticz to version 2023.1 and DZGA to 1.23.2.
Since then for a set of switch devices of subtypes "door lock", "selector" I can voice control the devices and it reflects correctly in Domoticz but I get the error
"ERROR - 400 Client Error: Bad Request for url: https://homegraph.googleapis.com/v1/dev ... tification" in DZGA.LOG and the state is not reflected in Google Home which creates discrepancies between Domoticz and Google Home.

The other devices (switch lights, blinds) are operating correctly.

Expected behavior:
For the switch devices of subtypes "door lock", "selector" to have report state done correctly in Google Home.

Logs:
ERROR - 400 Client Error: Bad Request for url: https://homegraph.googleapis.com/v1/dev ... tification

Desktop (please complete the following information):

  • Domoticz on RPI3B
  • Version: 2023.1 (build 15182)
  • Build Hash: 34815c1a9-modified
  • Compile Date: 2023-04-10 17:22:59
  • dzVents Version: 3.1.8
  • Python Version: 3.7.3 (default, Oct 31 2022, 14:04:00) [GCC 8.3.0]
  • Domoticz-Google-Assistant 1.23.2

Smartphone (please complete the following information):

  • Device: iPhone6

Additional context, screenshot:
The issue happens in smarthome.py in the method below : ReportState.call_homegraph_api
def report_state(self, states, token):

    data = {
        'requestId': self._request_id,
        'agentUserId': token.get('userAgentId', None),
        'payload': {
            'devices': {
                'states': states,
            }
        }
    }
    ReportState.call_homegraph_api(REPORT_STATE_BASE_URL, data)

The weird thing is that in Google Home a selector is seen as a plain switch (on/off).

Try make do a "sync my devices", or add new devices:

  1. On your mobile device, open the Google Home app.
  2. At the top left, tap Add (+)
  3. Set up device
  4. Works with Google.
  5. Select your device app e.g: "[test]Your Appname"
  6. Search for new devices

or try set those device to report_state = False
https://github.com/DewGew/Domoticz-Google-Assistant/wiki/2.-Configuration#device-configuraton

Hello,

For the switches of subtype 'Door Lock' I fixed the issue by changing:

1 - smarthome.py

Line 143
elif 'Door Lock' == device["SwitchType"]:
return DOMAINS['door'] # 'lock' --> 'door'

2 - trait.py
Line 383 in def query_attributes(self):
if self.state.state in ['Open', 'Off', 'Unlocked']: # add Unlocked

Line 411 in def execute(self, command, params):
elif p == 100 and state in ['On', 'Locked']:# add Locked
Line 415 in def execute(self, command, params):
elif p == 0 and state in ['Off', 'Unlocked']:# add Unlocked

BR

The issue with selectors is still opened

The issue with selectors is still opened

Regarding selectors I started to investigate the issue and noticed in the implementation of dzga v1.32.2 that the flag "LevelOffHidden" in the selector device is not currently managed.

It means that in Google Home we have "Off" displayed whereas in Domoticz it is not.

BR

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

The bug dealing with the use of selector device type is still opened

Device description is

report_state = False

Please let me know if you have a hint to fix it or find a workaround
BR