i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

action.devices.commands.SetFanSpeed error #100

Closed glsf91 closed 3 years ago

glsf91 commented 3 years ago

I see a few problems with action.devices.commands.SetFanSpeed.

Problem 1 In the trait action.devices.commands.SetFanSpeed I use for commands:

{
  "action.devices.commands.SetFanSpeed": {
    "fanSpeedPercent": "google/home/fan1/perc/set"
  }
}

Then I get an error: "Trait 'FanSpeed' is missing command param 'fanSpeed' for command 'action.devices.commands.SetFanSpeed'"

There is no error when I use:

{
  "action.devices.commands.SetFanSpeed": {
    "fanSpeed": "google/home/fan1/speed/set",
    "fanSpeedPercent": "google/home/fan1/perc/set"
  }
}

But in the google documentation is mentioned: "The payload contains one of the following:" So suggesting that fanSpeed is not required.

Problem 2 And also in the attribute template the "availableFanSpeeds" part is required, but in the google documentation this is not the case, I think. It says: "Contains any of the following items:" (availableFanSpeeds or supportsFanSpeedPercent)

Problem 3 I also see someting is going wrong in the response on an EXECUTE for the fanspeed. Request:

{
    "requestId": "11139760916098009229",
    "inputs": [{
            "intent": "action.devices.EXECUTE",
            "payload": {
                "commands": [{
                        "devices": [{
                                "id": "google/home/fan1",
                                "customData": null
                            }
                        ],
                        "execution": [{
                                "command": "action.devices.commands.SetFanSpeed",
                                "params": {
                                    "fanSpeedPercent": 100
                                },
                                "challenge": null
                            }
                        ]
                    }
                ]
            }
            ]
        }
}

Response:

{
    "requestId": "11139760916098009229",
    "payload": {
        "commands": [{
                "ids": ["google/home/fan1"],
                "status": "SUCCESS",
                "states": {
                    "currentFanSpeedSettingPercent": 100
                },
                "debugString": null,
                "errorCode": null,
                "challengeNeeded": null
            }
        ]
    }
}

The state currentFanSpeedSettingPercent should be currentFanSpeedPercent. I think because in CommandToStateKeyMapper fanSpeed is replaced by currentFanSpeedSetting. But fanSpeed should by replaced by currentFanSpeedSetting and fanSpeedPercent should be replaced by currentFanSpeedPercent.

In state I have:

{
  "currentFanSpeedSetting": {
    "topic": "google/home/fan1/speed",
    "googleType": "string",
    "valueMap": [
      {
        "google": "low",
        "mqtt": "1",
        "type": "value"
      },
      {
        "google": "high",
        "mqtt": "4",
        "type": "value"
      }
    ]
  },
  "currentFanSpeedPercent": {
    "topic": "google/home/fan1/perc",
    "googleType": "numeric",
    "valueMap": []
  }
}

Problem 4 In state I have to add the currentFanSpeedSetting part but I think this is not required by Google.

i8beef commented 3 years ago

The percentage thing is new. I'll have to look at this as a bug and correct. Its basically all due to the short hand evaluations I do (tradeoff of doing something generically in a less-than-good way to avoid a massive maintenance headache managing 50+ some odd implementations). Basically it just does a find-replace for "fanSpeed", and having two settings like "fanSpeed" and "fanSpeedPercent" like this, it's gonna catch both of them in the replacement.

In addition the fan speed command validator is going to have to be changed to support percentage as a setting... I'll probably do that BEFORE the looking at replacing the validation layer with a generated one (see #101 ) just to limit moving parts, so I'll take a look at including this one in the next release.

i8beef commented 3 years ago

Ok, I just released a version that should fix this for you.

glsf91 commented 3 years ago

Thanks. Which one did you fix, problem 1,2,3 or 4?

FYI When using this fanspeed stuff in the google validator it gives an error. I made a issue at google and they confirm the validator is outdated on this.

i8beef commented 3 years ago

Should fix all 4.

glsf91 commented 3 years ago

I can confirm all 4 are fixed indeed.

Only when using only fanSpeedPercent instead of fanSpeed google does not sent a EXECUTE anymore when changing fanspeed percentage on my google Hub. But I think this is an issue at google. I made an issue at google for this. When using both, it is working.

i8beef commented 3 years ago

Nice. If you find there is some issue with the implementation, reopen and Ill adjust.

glsf91 commented 3 years ago

Only when using only fanSpeedPercent instead of fanSpeed google does not sent a EXECUTE anymore when changing fanspeed percentage on my google Hub. But I think this is an issue at google. I made an issue at google for this.

I know this item is closed but issue is fixed by google.