Controlling Delonghi Primadonna Elite through ST


I have a bluetooth connected coffee machine. (Delonghi Primadonna Elite)
It can be controlled through the Android app via Bluetooth.

Now, I’d like to control it through ST (and then Alexa)

What I decide is to write an app on my Raspberry PI3 which would clone the Bluetooth commands of the Android app.

Then I can call the app with a rest call from the ST cloud.

But I don’t know how to clone the BT commands of the Android app.
Is it possible to sniff/trace the BT connection between Android app and the coffee machine using my Android phone ?


1 Like

I think the usual way to do this is from the other side, with a combination of two third-party apps: Tasker and sharptools. That way you don’t have to reverse engineer anything, you just work through the existing app.



thanks but:

  1. how will sharptools make delonghi app send the correct BT command ? (I don’t think that it has intent for this purpose)

  2. in any case, I don’t really want to use an Android phone for this. I want to use my PI3 server.

It depends on the app you are trying to control. If the app has its own Tasker integration, then you would just use that. Otherwise many people use something like AutoInput to simulate the touches in the app.

If you can clone the Bluetooth commands and run them on your Pi, then more power to you! That sounds like it should be a pretty stable approach if you can figure it out.

The beauty of the Tasker approach is it’s relatively easy to setup. And you can even pick up a cheap Android phone for like $50 at a grocery store these days which you could use as a dedicated ‘hub’ of sorts.


I will check autoinput
so in that method I need to start app with tasker and then use autoinput to do what I want on the delonghi app ?

That’s right. :grinning:

I could not figure out exactly how to use AutoInput with Tasker.
There are 2 possibilities when I want to make a coffee;

  1. the machine is ON : then I just have to open the app and click a button
  2. the machine is OFF : in this case, when I open the app , it first asks me if I want to turn on. Then I have to click YES and when it is ON I have to click the same button in (1)

How can I achieve this scenario in AutoInput ?

And after I do that, how shall I connect this to a SmartThings button/switch ?
(I assume Sharptools can trigger tasker when a button is activated in ST)


AutoInput has a query feature. It’s been a while since I’ve used it, but if I remember correctly, you can effectively look for certain controls on a screen - for example, if a certain button exists on the page.

Then you would use logic in Tasker to determine which AutoInput actions to take.

Alternatively, you could just rely on the state of the switch being correct in SmartThings - it’s simpler, but less ideal since the state can get out of sync. For example, I do this for the white noise on my son’s tablet. It will get out of sync if anyone manually controls the tablet, but everyone knows to always control the virtual switch with Alexa now. (And if it ever gets out of sync I just have to toggle it off and on again to get it back in sync).

Yes, you could setup a virtual switch in SmartThings and then use the SharpTools Thing State event capabilities… when the switch is changed in SmartThings, SharpTools will get a push event and can trigger the profile in Tasker.

thanks . I got the query function now, but…
The app opens and waits random between 5 to 10 seconds searching for the BT device.
Then it either finds it standby (screen 2) or ON (screen 1)
How can I make Tasker wait until it reaches screen 1 or screen 2 ?

Tasker has wait functions. For example, you could wait a predetermined time (eg. 5 seconds) then run your query.

A little bit more complex, but would likely be more efficient each time would be to loop using an AutoInput query looking for something that either shows up during the search or after the search (and maybe even do a small wait in between each loop like 200ms).

What I usually like to do is label a specific action as the starting point of my ‘loop’, then use the ‘Goto’ action with a type of ‘Action Label’ to create a loop of sorts.

You can set a variable to keep track of how many times you’ve looped and then condition certain actions on that as kind of a failsafe so you don’t get stuck in a permanent loop. We’re entering into a bit more advanced Tasker territory here, but it’s something to consider at some point.

Then you can use the Wait action as mentioned above to wait a period of time inside the loop. Again… if the loop sounds a bit confusing, then just waiting 5 seconds or whatever might be the easiest first step and you can go back and add the loop later to increase the performance.

1 Like

ok. I created a virtual switch and created a Tasker profile to watch event state change for the “Coffee Machine” named switch. But I just want to trigger if it becomes “on”
What shall I put in Sharptools “thing” and “attribute” parameters ?

Take a look at the help article I linked above. It goes through the steps of setting up a tasker profile with the Thing State event plugin.

The thing field would be the name of your thing and the attribute field would be switch.

It also includes a video walking through the process and describing the various steps.

Note that by default the Thing State event plugin will trigger anytime the attribute changes. If you only wanted to trigger the Tasker profile for certain values (eg. on) make sure you use a Tasker conditional action using the variables that SharpTools sets.

thanks. it is actually working now.
but it does not work when screen is off.
I used AutoInput’s “screen on” action at the start of my tasker task but that did not turn on the screen.

2 possibilities:

  1. autoinput can not turn on my device
  2. sharptools does not work when screen is off

how can I solve this ?

What type of Android device are you running this on? Modern Android devices and OS versions have become much more restrictive of battery usage by default.

The following article has some details on optimizations that should be applied as well as links to articles on optimizations that should be applied for Tasker and for Samsung devices:

it is a Digiland tablet with Android 7.0
I have all AutoInput, Tasker , Sharptools apps “as battery not optimized”
Also “tasker run in foreground” is selected.
But Autoinput can not turn screen on.

what else can I try ?

I added a “wait 5 seconds” step to the task and started it manually. then turned screen off.
The task turned the screen on after 5 seconds.
So it seems that Tasker and the AUtoinput plugin can turn the screen on.
However, when I try to start the task through Sharptools, it does not turn the screen on.

why is that ?

I also tried running the task every 2 minutes.
it works and turns the screen on.

However, sharptools does not trigger the task when screen is off.
How can I solve it ?

If I wait like 5-6 minutes it actually turns the screen on.
So Sharptools works when screen is off but its checking period is too wide.
How can I force it to check in shorter periods ?

Keep the screen on? :stuck_out_tongue:

SharpTools doesn’t poll or query for events. It’s listening for an event to get pushed down via Google’s push event system. It sounds like the push messages are being slowed down while the device is sleeping for some reason. Using FCM to wake devices which implement Android Doze mode is specifically based on Google’s guidelines, so I’m surprised the device isn’t waking. It could be something Digiland has done in their implementation.

If the device is going to be plugged in at all times, you might further try disabling any battery optimization features it has. You could also try making sure all the Google related services (Google Play Services) are exempted from battery whitelisting.

there is no other setting about battery optimization.
actually the Digiland tablet is free of apps. Only the required apps are installed for this purpose.
it is too bad that Sharptools is triggered with a delay when screen is off.
Anything else that I can try ?

You could try a virtual Pushbullet switch. Pushbullet has a Tasker integration as well.