This project is a Python script that synchronizes UniFi devices with Snipe-IT. It fetches devices from a UniFi controller, formats them, and adds or updates them in Snipe-IT. The script can also create new models in Snipe-IT if they don't already exist.
requests
libraryratelimiter
librarytabulate
librarypyunifi
librarytermcolor
libaryThese can all be installed using requirements.txt discribed in the steps below.
`git clone https://github.com/yourusername/unifi-to-snipeit.git cd unifi-to-snipeit`
pip3 install -r requirements.txt
config_example.ini
to config.ini
and update the configuration settings with your UniFi and Snipe-IT credentials and preferences.cp config_example.ini config.ini
There are a few things to take care of in Snipe-IT before you start the configuration
Update the config.ini
file with your UniFi controller and Snipe-IT API credentials and preferences. The following sections are available for configuration:
[UniFi]
: UniFi controller settings (URL, username, password, port, version, and site ID)[SnipeIT]
: Snipe-IT API settings (API URL, API key, manufacturer, model category ID, MAC address field name, IP address field name, default status ID, device name priority, and rate limit)[unifi_model_mapping]
: UniFi model mapping for converting UniFi model names to Snipe-IT model namesUbuiquiti has had some "fun" with their model numbers. When originally adding our Unifi devices into Snipe-IT, we used the model numbers shown of the devices detail page in the control panel. However, the API returns a completely different set of model numbers for devices. The unifi_model_mapping allows you to map the API model numbers to existing models numbers you might have set in Snipe-IT already.
We used the PyUnifi libary to interact with the Unifi API. You might want to read through their docs to debug your particular connection. We included a unifi.py file where you can test your settings. https://github.com/finish06/pyunifi
To run the script, execute the following command:
python main.py
To perform a dry run without making changes to Snipe-IT, use the --dry-run
option:
python main.py --dry-run
During the dry run, the script will output a summary of the changes that would be made to Snipe-IT.
To override the site_id
specified in the config file, use the --site-id
option followed by the new site ID:
python main.py --site-id new_site_id
This is useful if your unifi controller has more than one site. There is not currently support for more than one controller. If you have multible controllers we recommend setting up another instance of the script with a different config file.
Please feel free to open issues or submit pull requests with bug fixes or improvements. Your contributions are welcome and appreciated.
This project is licensed under the MIT License. See the LICENSE file for more information.