Add a device to the voice assistants
For Alexa, Google Home, or Yandex to understand a new device type, it's not enough to simply add it to an adapter. The type must be known in four places, and the order is important:
- Add the roles if the existing ones are insufficient.
- Expand the type detector to include the device.
- Add the device to iobroker.devices so that it can be added and tested there.
- Pass the device through the IoT adapter to Alexa, Google, etc.
1. Roles
Before creating a new device type, three sources must be checked, because what the assistants don't know, they can't control:
It is also useful to look at an existing device in an adapter that already replicates the same functionality.
Example: Air conditioning. The three providers describe it with varying degrees of detail:
Yandex has the most complete picture of the states, therefore it is the most sensible basis. During the comparison, it was noticed that no roles were yet documented for thermostat mode and swivel position; these are now listed under state roles . The other states, such as power and setpoint temperature, were already documented.
2. Type detector
Once the role is determined, the type detector is next. The new device type is added to the global list and receives an entry in the...patterns the classChannelDetector one entry; the easiest way to do this is by using a similar device as a template.
Two factors determine whether the recognition works:
- The set of roles must be unambiguous. In the case of air conditioning, these are...
level.temperatureandlevel.mode.thermostat, both asrequiredMarked. The detector recognizes them by this pair. - The order matters. The most complex devices are at the top of the list and are tested first, the simpler ones last. Otherwise, a more general pattern will trigger a test before the more specific one gets its turn.
After that, a new version of the npm package will be released.iobroker.type-detector published.
3. iobroker.devices
In the adapter's device settings , the version of the type detector is updated, and the list of symbols is expanded to include the new type. This also requires a new version.
This allows the device to be created and tested in the adapter device management section without requiring any actual hardware.
4. With the assistant
Finally, the IoT adapter must forward the new device type to Alexa, Google Assistant, or Yandex. Only then will the device appear in the assistant's database.
The sequence cannot be shortened. A device that the type detector does not recognize will not reach the assistants, even if all states are present.