i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
217 stars 29 forks source link

HomeGraph ReportState issue #26

Closed shady2k closed 5 years ago

shady2k commented 5 years ago

I have issue with HomeGraph. Error occurs, when mqtt message received.

In log file: 2018-12-21 08:29:06.078 +03:00 [Information] MQTT message received for topic openhab/stateUpdates/switch_hallway/state: OFF 2018-12-21 08:29:29.113 +03:00 [Error] Unhandled exception while handling application message.

Error in GoogleHomeGraphClient, line 182: var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.RsaSha256Signature);

System.NotSupportedException: "IDX10634: Unable to create the SignatureProvider. Algorithm: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', SecurityKey: 'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey' is not supported."

googleDevices.json

{
  "google/home/switch": {
    "id": "google/home/switch",
    "type": "action.devices.types.SWITCH",
    "willReportState": true,
    "roomHint": "Some Room",
    "name": {
      "defaultNames": [],
      "name": "my switch",
      "nicknames": []
    },
    "deviceInfo": {
      "manufacturer": "Some Company",
      "model": "Some Model",
      "hwVersion": "1.0",
      "swVersion": "1.0"
    },
    "traits": [
      {
        "trait": "action.devices.traits.OnOff",
        "commands": { "action.devices.commands.OnOff": { "on": "nodered/commandUpdates/switch_hallway_manual/command" } },
        "state": {
          "on": {
            "topic": "openhab/stateUpdates/switch_hallway/state",
            "googleType": "bool",
            "valueMap": [
              {
                "mqtt": "ON",
                "type": "value",
                "google": true
              },
              {
                "mqtt": "OFF",
                "type": "value",
                "google": false
              }
            ]
          }
        }
      }
    ]
  },
} 

I tried to change RsaSha256Signature to HmacSha256Signature, but after that I have error in MqttService at line 110: System.Net.Http.HttpRequestException: "Response status code does not indicate success: 500 (Internal Server Error)."

What I am doing wrong?

i8beef commented 5 years ago

You aren't doing anything wrong. I don't use ReportState so this hasn't been fully tested... you just get to be the lucky first person to see how broken it is.

I completely missed that the cert they send over here is just the private key PEM file essentially... which .NET doesn't have native support to read. So it's gonna take me a day or two to find something that can read it and get it patched in. Hang tight.

i8beef commented 5 years ago

Just released 1.0.0.66. Should be on DockerHub momentarily. Try that out and let me know what you get.

i8beef commented 5 years ago

Scratch that, 1.0.0.71 or whatever is latest. I had to fix some Docker build issues and move to .NET Core 2.2.

shady2k commented 5 years ago

Thank you. No errors in log now. I'm keep testing it.

i8beef commented 5 years ago

Excellent! Let me know how it goes, and close the ticket when you're satisfied.