DewGew / Domoticz-Google-Assistant

Google Assistant for Domoticz
https://github.com/DewGew/Domoticz-Google-Assistant/wiki
Apache License 2.0
79 stars 41 forks source link

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

Closed mealgi closed 1 year ago

mealgi commented 1 year ago

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):

Smartphone (please complete the following information):

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).

DewGew commented 1 year ago

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

mealgi commented 1 year ago

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

mealgi commented 1 year ago

The issue with selectors is still opened

mealgi commented 1 year ago

The issue with selectors is still opened

mealgi commented 1 year ago

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

github-actions[bot] commented 1 year ago

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

mealgi commented 1 year ago

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