Alexa and Microsoft ToDo

Again, my mission statement was:
After amazon changed the shopping list integrations and we as a family don’t want to add a skill-name to our yearslong used “Alexa, add XYZ to the list” to “Alexa, open BringIt and add XYZ to the list”.
And last not least, MS offers an overall solution of App, API and stuff to (re-)integrate the shopping list for showing it within openHAB and the MS Todo App, we would like to stay within that eco-system.

Mission is clear: Use openHAB as a means to listening in to the commands and the re-routing them to MS ToDo.

Prerequisites:

  • lastVoiceCommand working (it does for me now again)
  • install tod0 (and configure it to be used from within openHAB and executeCommandLine [1])

What you have to do

  1. define a Group for all lastVoiceCommand-items I use (We have 6 echos in the house)
  2. add a rule to filter onChange on those items
  3. add in the rule to execute a commandline with tod0 and add items to my shopping list.

So, it’s simple indeed, if you have a group for all your lastVoiceCommand-items, use the following rule, but change:

  • AMZ_LetzteSprachbefehle: Name of the Group with all your lastVoiceCommand
  • “auf die Liste” / “zur Liste”: your Triggerword in your language, to add items to a shopping list
  • Listname: name of the list within Microsoft ToDo
  • YourEmail: your email address, if you want to use notifications within openHAB App
configuration: {}
triggers:
  - id: "1"
    configuration:
      groupName: AMZ_LetzteSprachbefehle
    type: core.GroupStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: >
        // search for "auf die liste" as trigger word
        var befehl = event.itemState.toString();
        var listePos = befehl.search("auf die liste");

        // backup for only "liste", if the trigger was "zur Liste" or similar
        if (listePos == -1) {
          listePos = befehl.search("liste");
        }

        console.debug("DEBUG amazonShoppingliste: Trigger word is on pos " + listePos);

        if (listePos != -1) {
          // name of your list (be sure to leave the trailing "/" as the entry is done via that
          var eintrag = "Einkaufliste/"; 

          // delete trigger word(s)
          befehl = befehl.replace(" auf die liste", "");
          befehl = befehl.replace(" zur liste", "");
          
          // add the desired product to the list
          eintrag = eintrag.concat(befehl);
          console.info("INFO amazonShoppingliste: per tod0 added to the list " + eintrag);
          console.debug("DEBUG amazonShoppingliste: command is: todocli new " + eintrag);

          // fire command
          var Duration = Java.type('java.time.Duration');
          var exec = actions.Exec.executeCommandLine(Duration.ofSeconds(15), "todocli", "new",  eintrag);
          console.debug("DEBUG amazonShoppingliste: response of tod0 was: " + exec);
          if (exec != "") {
            console.warn("INFO amazonShopingliste: WARN ", exec);
            actions.NotificationAction.sendNotification("your@email.com", "AMZ Shoppingliste: " + exec, "siren", "warning");
          }
        }
    type: script.ScriptAction

[1] after installing tod0 as described in the github, you have to

  1. add the keys from the GET_KEY-readme to sudo nano /var/lib/openhab/.config/tod0/keys.yml (if running e.g. openHABian, other installation may require different paths)
  2. run it once via ssh sudo -u openhab tod0 and do as the prompt says.
1 Like