i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

Need help with action.devices.types.AC_UNIT and action.devices.traits.Modes trait #54

Closed shady2k closed 5 years ago

shady2k commented 5 years ago

Trying to implement Air Conditioner. New item show in Google home application, but has no any controls, just common information. It works? And problem with action.devices.traits.Modes trait, if add new trait, I can't see any modes to select. Can you help?

{
  "availableModes": [{
    "name": "mode",
    "name_values": [{
      "name_synonym": ["mode"],
      "lang": "en"
    }],
    "settings": [{
      "setting_name": "Off",
      "setting_values": [{
        "setting_synonym": ["off"],
        "lang": "en"
      }]
    }, {
      "setting_name": "On",
      "setting_values": [{
        "setting_synonym": ["on"],
        "lang": "en"
      }]
    },
    {
      "setting_name": "Eco",
      "setting_values": [{
        "setting_synonym": ["eco"],
        "lang": "en"
      }]
    }
                ],
    "ordered": false
  }]
}
{
  "action.devices.commands.SetModes": {
    "updateModeSettings.input source": "iobroker/javascript/0/test5"
  }
}
{
  "currentModeSettings.input source": {
    "topic": "iobroker/javascript/0/test5",
    "googleType": "numeric",
    "on": [{
      "mqtt": "0",
      "type": "value",
      "google": "off"
    }, {
      "mqtt": "1",
      "type": "value",
      "google": "on"
    }, {
      "mqtt": "2",
      "type": "value",
      "google": "eco"
    }
          ]
  }
}
i8beef commented 5 years ago

Google's documentation for the device type is here. It can be worth it to try and follow along with their docs as their API is... different. One thing to be aware of with mods is that Google doesn't allow anything outside their small library of settings for it (see here).

That said I think your "attributes" are ok. Your command there is setting "input source" but I think you want that to be "updateModeSettings.mode". Same thing for your state definition.

Outside of THAT I think you have it setup right. You should be able to use the right phrases to voice control it at that point... whether the Home Hub will show you any CONTROLS for it though, I don't know. I know if I have on/off and modes turned on on the same device that Google Home Hub will only show the controls for the On/Off state.

shady2k commented 5 years ago

Ok, I change my commands to:

{
  "action.devices.commands.SetModes": {
    "updateModeSettings.mode source": "iobroker/javascript/0/test5"
  }
}

Assistant tells me, that I change mode successfully, but no MQTT message produced. What am I doing wrong?

i8beef commented 5 years ago

Drop the " source" part. It should just be

''' { "action.devices.commands.SetModes": { "updateModeSettings.mode": "iobroker/javascript/0/test5" } } '''

Remember to change the state "currentModeSettings.mode" as well!

shady2k commented 5 years ago

Yes, it's working! Thank you. And one more question: can I map commands mode name to another values, as it done for states?

    "on": [{
      "mqtt": "0",
      "type": "value",
      "google": "off"
    }, {
      "mqtt": "1",
      "type": "value",
      "google": "on"
    }, {
      "mqtt": "2",
      "type": "value",
      "google": "eco"
    }

At now it return to mqtt string "on", "off" or "eco".

i8beef commented 5 years ago

Change that first "on" to "valueMap". Also the googleType for your example should be "string".

shady2k commented 5 years ago

Yes! Got it! Thank you. I will leave my current config here for history.

{
  "availableModes": [
    {
      "name": "mode",
      "name_values": [
        {
          "name_synonym": [
            "mode"
          ],
          "lang": "en"
        }
      ],
      "settings": [
        {
          "setting_name": "Off",
          "setting_values": [
            {
              "setting_synonym": [
                "off"
              ],
              "lang": "en"
            }
          ]
        },
        {
          "setting_name": "On",
          "setting_values": [
            {
              "setting_synonym": [
                "on"
              ],
              "lang": "en"
            }
          ]
        },
        {
          "setting_name": "Eco",
          "setting_values": [
            {
              "setting_synonym": [
                "eco"
              ],
              "lang": "en"
            }
          ]
        }
      ],
      "ordered": false
    }
  ]
}
{
  "action.devices.commands.SetModes": {
    "updateModeSettings.mode": "iobroker/enum/rooms/bedroom/conditioner"
  }
}
{
  "currentModeSettings.mode": {
    "topic": "iobroker/enum/rooms/bedroom/conditioner",
    "googleType": "string",
    "valueMap": [
      {
        "mqtt": "0",
        "type": "value",
        "google": "Off"
      },
      {
        "mqtt": "1",
        "type": "value",
        "google": "On"
      },
      {
        "mqtt": "2",
        "type": "value",
        "google": "Eco"
      }
    ]
  }
}
i8beef commented 5 years ago

Glad you got it! Closing as completed.