Coffee Watcher solution is based on image recognition, this post will show how the Canvas App is developed. Most secure and compliant solution for production use would be use wifi camera, that sends image every minute i.e. to email address. But I did not have it and wanted to test my idea, I created Power Apps Canvas App and my old mobile phone for testing it.

1. Go to Maker Portal and to navigate to solutions
2. Create new solution
3. Add existing item AI Model which you created in previous post

Add existing AI Model to a solution
Add existing AI Model to a solution

4. Create new App -> Canvas app
Add there following controls: Camera, Drop down, Timer and Image.

Coffee Watcher app edit view
Coffee Watcher app edit view

5. Modify drop down control

Set drop down items getting camera devices
Set drop down items getting camera devices
Set OnChange changing the camera feed with variable selectedCamera
Set OnChange changing the camera feed with variable selectedCamera

6. Modify camera control

Set camera property use the selectedCamera variable
Set camera property use the selectedCamera variable
Set StreamRate for 100
Set StreamRate for 100

7. Close the app and re-open
This is for getting the new stream rate working

8. Add the OnStart of the App
Create global variables selectedCamera, varMessageId and wasFull for the app to use

Adding global variables to app OnStart property
Adding global variables to app OnStart property

9. Modify the Timer control
Select the control and set duration, repeat, auto start and auto pause

Configuring the timer control
Configuring the timer control

Add to the OnTimerStart property the following code.
Code will get a screenshot of the camera stream when the timer starts and sends it for further processing via Power Automate flow which we will be implementing in the next post. The code will send picture to flow and then get information was the coffee pot full and message id.

Message id will be used for updating the same Teams adaptive card instead of creating new one every minute. WasFull is used in the flow understandin, when to inform in chat when there is new coffee, so that it does not inform it every minute as new message as long as there is full coffee pot detected in the picture.

UpdateContext({varPhoto:Camera1.Stream});
ClearCollect(PictureColl, varPhoto);
If(!IsBlankOrError(varPhoto),
    
    IfError( // Try
        Set(response, ProcessPictureandInformOthers.Run(wasFull, varMessageId, 
        {
            file: {
                contentBytes: First(PictureColl).Value,
                name: "anyname.jpg"
                }
        }));
    , // Catch
        // Reset the variables
        Set(varMessageId, "0000");
        Set(wasFull, false);
    );
    Set(varMessageId, Text(response.messageid));
    Set(wasFull, response.isfull);
)
//Notify("Kuva lähetetty tulkittavaksi", NotificationType.Success);

Other posts in this solution

  1. Solution presentation “Is there and coffee left”
  2. Teaching custom AI model for object detection
  3. Power Apps Canvas to capture picture every minute
  4. Solution architecture and trigger errors
  5. Flows to use Object Detection and informing of fresh Coffee
  6. Adaptive card updating every minute with thumbnail picture