Skip to content

Latest commit

 

History

History
133 lines (79 loc) · 4.85 KB

File metadata and controls

133 lines (79 loc) · 4.85 KB

Scripting

Overview

The Wiser-by-Feller µGateway provides a script-engine to extend the Wiser-by-Feller functionality of smartbuttons with 3rd party services.

Some infos about the script-engine:

  • Minimum required Wiser-by-Feller µGateway SW-Version >= 5.1.25
  • Script-langauge is (Micro-)Python
  • The script-engine is still in Beta/Experimental state!

Using scripting allows you to invoke an action on 3rd party devices e.g. smart-lights that provides a REST-API by pressing a Wiser-by-Feller smartbutton.

The execution of a script is configured in a job and a job can be marriage with a smartbutton. That means, by pressing a smartbutton your script will be executed.

Uses-Cases:

  • Turn on or off a smart-light via REST-API.

    • Button-type: scene
    • Example: hue_scene.py
  • Increase or decrease the volume of your music-box via REST-API.

    • Button-type groupctrl
    • Example: sonos.py

On the Wiser-by-Feller µGateway there is a simple Web-GUI used for Customer-Support. Use a browser and enter the IP-address or hostname of your µGateway e.g. "http://192.168.1.123". On first-time use, you need to create an account.

Create a script and link it with a scene-smartbutton

There is an easy way to create a script and link it with a smartbutton, without breaking your head by using the µGateway Web-GUI. Of course, you can do all the steps using the µGateway REST-API.

  1. Login to the Web-GUI of your Wiser-by-Feller µGateway e.g. "http://192.168.1.123" and click on tab scripts.

    Here you can upload your script or you can create a new one.

    uGW Script-1

  2. Lets create a new script by pressing button [Create File 🆕] and named it cowsay.py.

    Note: Have a look at the script examples/templates in the dropdown-list:

    • hue_scene.py
    • hue_ctrl.py
    • sonos.py

    uGW Script-2

  3. The new script file is created.

    File-Actions:

    Action Description
    uGW Scripts-Action-Start Run/start the script. This will invoke first the function onStop and then onStart
    uGW Scripts-Action-Stop Stop the script. This will invoke the function onStop
    uGW Scripts-Action-Edit Edit the script
    uGW Scripts-Action-Delete Delete the script

    uGW Script-3

  4. Lets write some code. Press the pencil-button [✎] and copy the code inside.

    #!/usr/bin/env micropython
    
    from sf.lib import alog
    
    # Called from job on smart-button event
    async def onButtonEvent(*argv):
        await alog(str(argv))
    
        await alog('%s %s on smartbutton %s', argv[0], argv[1], argv[2])
    
    
    # Called from the Web-GUI 'start'-button
    async def onStart(*argv):
        await alog(str(argv))
    
        await alog('Lets dance...')
    
    
    # Called from the Web-GUI 'stop'-button
    async def onStop(*argv):
        await alog(str(argv))
    
        await alog('Stop dance!')

    uGW Script-4

  5. Press the start-button [🚀]

    uGW Script-5

  6. To link the script-file with a smartbutton, press the button [Link to SmartButton🔗].

    Now a popup-window will appears. Choose your file cowsay.py and button-type scene.

    Afterwards press button [Link to SmartButton].

    uGW Script-6

  7. At this moment all available smartbuttons from type scene will start blinking (color: purple) and wait until one is pressed.

    uGW Script-7

  8. After pressed smartbutton from type scene the script is linked and ready for use.

    uGW Script-3

  9. Now click the smartbutton (that you linked before) and your script will be executed.

    uGW Script-8

Wiser-by-Feller button decoration

Lets decorate your Wiser-by-Feller buttons with different icons such as: play, stop, ...

Example (EDIZIOdue push button size 1/4):

wiser-button-music-symbols

🐮 Click button below for clean up this mess

wiser-button-clean-mess