# Add More Traits and Handlers

You can add as many traits to your device model as you wish. These traits are
not tied to just one device type, you can use them as you choose.

This is the process to add any trait and handle the incoming command:

1. Determine which [trait](https://developers.google.com/assistant/sdk/reference/traits) you want
   to add.

2. Open the `pushtotalk.py` file.

   ```
   cd assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc
   ```

   ```
   nano pushtotalk.py
   ```
3. Add the following code block under the existing one that
   handles the `action.devices.commands.OnOff` command (don't delete the existing
   code block).

   ```
   @device_handler.command('action.devices.commands.command-name')
   def my-function(parameter-name):
       if conditional:
           logging.info('Something happened.')
       else:
           logging.info('Something else happened.')
   ```
4. Find the information you need for each variable in the above code block.

   |---|---|
   | `command-name` | Go to the specific trait page from Step 1 (for example, [ColorTemperature](https://developers.google.com/assistant/sdk/reference/traits/colortemperature)). Use a command from the **Device COMMANDS** table. |
   | `my-function` | Name your handler function whatever you want. |
   | `parameter-name` | Look again at the **Device COMMANDS** table on the trait page. Each command has one or more parameters associated with it. These are listed under `"params"` in the EXECUTE request JSON. Use the exact parameter name. Note that some of these parameters are objects that contain other parameters - just use the top-level object. |
   | `conditional` | You don't strictly need to use a conditional in your handler code, but it may help to differentiate how you execute the command on the device. |

   Here are some examples for traits [Brightness](https://developers.google.com/assistant/sdk/reference/traits/brightness)
   and [ColorTemperature](https://developers.google.com/assistant/sdk/reference/traits/colortemperature):

   ```python
   @device_handler.command('action.devices.commands.BrightnessAbsolute')
   def brightnessCheck(brightness):
       if brightness > 50:
           logging.info('brightness > 50')
       else:
           logging.info('brightness <= 50')

   @device_handler.command('action.devices.commands.ColorAbsolute')
   def color(color):
       if color.get('name') == "blue":
           logging.info('color is blue')
       else:
           logging.info('color is not blue')
   ```
5. [Update the device model](https://developers.google.com/assistant/sdk/guides/service/python/extend/register-device-traits)
   with the trait you added in Step 1.

6. Run the modified source code.

   ```
   cd assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc
   ```

   ```
   python pushtotalk.py
   ```
7. Press the Enter key and try a query.

   For example:

   *Set brightness to 65%.*

   *Make it blue.*

## Next step

[Register Custom Device Actions](https://developers.google.com/assistant/sdk/guides/service/python/extend/custom-actions)