Skip to content
  • There are no suggestions because the search field is empty.

DataHub Can Play a Sound Based on a Tag Value

Can the DataHub play a sound file when a tag changes?

Yes, DataHub can run a command that could cause any file to open including sound files. In this example we play a MP3 file but technically you can open any file type.
The script monitors a single tag for when it changes and then checks the new value against the Condition.  If they match it will play the sound. To get this working for yourself, you only need to change the tag name you are monitoring and the Condition to play the sound.
 
Below is the script and MP3 file to download. Please follow the instructions below to make this work with your DataHub.
  1. Download the files below and unzip the folder.
  2. Place the Alarm.g file in the DataHub Scripts folder "C:\Users\[USERNAME]\AppData\Roaming\Cogent DataHub\scripts"
  3. Make a directory C:\tmp and place the "airhorn.mp3" file in that folder.  
  4. Open the DataHub and go to the Scripting section.  Click Add and choose Alarm.g file from step 2.
  5. Highlight the script and click Edit.
  6. In the top of the script in the Class definition you will see two variables tag name and Condition.
  7. Set the tag name to the name of your tag in DataHub you want to monitor.  This is in the format "domain:tagname".
  8. Last set the Condition. The default condition is 1.
  9. Click the Play button to run the script.
You can now update the tag value and confirm the sound plays.