Close

Code on GitHub

A project log for WiFi Based Distributed IOT Home Automation

Autonomous intelligent IOT nodes connected to the home network, controlled via simple IFTTT style rules, configured via web interface

andreyAndrey 08/22/2016 at 15:350 Comments

I finally have a more or less stable version of the code. It is far from complete as the web interface is missing the recipe management. The 'recipes' can be added manually in the code as per the following example:

if(!loadFromFileNew("/recipes.json",sRecipes,RECIPE_JSON_SIZE*RECIPES_LEN)){
    arrRecipes[0].id = 1;
    arrRecipes[0].name = "Max Watts/Hour";
    arrRecipes[0].localThingId = 1;
    arrRecipes[0].localValue = 0;
    arrRecipes[0].sourceNodeId = CHIP_ID;
    arrRecipes[0].sourceThingId = 3;
    arrRecipes[0].sourceValue = 0;
    arrRecipes[0].relation = BIGGER_THAN;
    arrRecipes[0].targetValue = 20;
    saveRecipesToFile(&arrRecipes);
    serializeRecipes(&arrRecipes, sRecipes, RECIPE_JSON_SIZE*RECIPES_LEN);
    delay(100);
  } else {
    deserializeRecipes(&arrRecipes,sRecipes);
  }

This 'recipe' turns off the SmartPlug when the daily consumption reaches 20 watt hours. Please, feel free to experiment with the 'recipes'. The other value that you can use is the 'Clock' (arrThings[3]), which gives you 'seconds from midnight'.

The code can be found here: ESP_SyncSmartPlug

Discussions