Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

actions on google - Unable to access custom modes from HomeGraph

I am trying to make a Google Smart Home action for a standing desk so that a user can change between three presets, but I cannot access the state of the Modes trait from the HomeGraph. I am able to ask the Google Assistant to change modes, and the assistant is able to recognize that I want to change modes (ex. Hey Google, change my desk to standing), but I am unable to report the state of the desk to the Home Graph. Subsequently, I am unable to access the state of the mode of the desk.

I figure it has something to do with the sync response I give which is the following:

{
   agentUserId: USER_ID,
   devices: [{
     id: 'desk2',
     type: 'action.devices.types.AIRFRESHENER',
     traits: [
       'action.devices.traits.Modes',
       'action.devices.traits.OnOff',
       'action.devices.traits.Brightness',
     ],
     name: {
       defaultNames: ['Smart Desk'],
       name: 'Desk',
       nicknames: ['My Desk'],
     },
     deviceInfo: {
       manufacturer: 'Ergonomyx',
       model: 'standing-desk',
       hwVersion: '1.0',
       swVersion: '1.0.1',
     },
     willReportState: true,
     attributes: {
       availableModes: [{
           name: "desk_height",
           name_values: [
               {
                   name_synonym: [
                       "height",
                       "position",
                   ],
                   lang: "en"
               },
           ],
           settings: [
              {
                   setting_name: "sitting_position",
                   setting_values: [
                       {
                           setting_synonym: [
                              "sitting",
                              "low"
                           ],
                           lang: "en"
                       }
                   ]
               },
               {
                   setting_name: "standing_position",
                   setting_values: [
                       {
                           setting_synonym: [
                               "standing",
                               "upright"
                           ],
                           lang: "en"
                       }
                  ]
               },
               {
                   setting_name: "biking_position",
                   setting_values: [
                      {
                           setting_synonym: [
                              "biking",
                           ],
                           lang: "en"
                       }
                  ]
               },
           ],
           ordered: true
       }],
         commandOnlyModes: false,
         queryOnlyModes: false,
         commandOnlyOnOff: false,
         queryOnlyOnOff: false
       },
    }],
  },
};

I added the OnOff, and Brightness traits to see if the issue was with the HomeGraph communication, but I was able successfully connect to the HomeGraph, store the values for brightness and power, and access them with the assistant. The only trait I've had issues with is the Modes trait.

Can someone let me know if I'm missing something obvious in the sync response.

question from:https://stackoverflow.com/questions/65928027/unable-to-access-custom-modes-from-homegraph

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...