pledi / EmberControl

Python experiment to control the Ember Mug
43 stars 18 forks source link

Can't run .py file #1

Closed Ryamonster10 closed 3 years ago

Ryamonster10 commented 3 years ago

When I do sudo python main.py I get

File "main.py", line 46 async def getCurrentTemp(self): ^ SyntaxError: invalid syntax

I am not sure why, any help would be appreciated.

Ryamonster10 commented 3 years ago

Just got it to work with "sudo python3" instead of "sudo python"

pledi commented 3 years ago

Yeah it runs only with Python 3.7+. Another point I might tackle today is a connect button or a retry button if the application fails to connect. Right now I scan for 5 seconds and if I find the mug I connect to it directly. If I dont find it, the program does nothing (needs a restart to scan and connect again).

Ryamonster10 commented 3 years ago

How do you connect the app to your ember mug? I just have this as a screen:

Screen Shot 2021-01-24 at 11 41 06 AM
pledi commented 3 years ago

I'm on it :)

Ryamonster10 commented 3 years ago

Just got it to kind of connect, the program can see the mug but can't connect, I get this: Ember Ceramic Mug <CBPeripheral: 0x7fa46f3f23b0, identifier = BFD88179-0B4D-4A15-97FA-6B906B5AFF4B, name = Ember Ceramic Mug, state = disconnected> Connected: True Error: Pairing is not available in Core Bluetooth. and then this right after: not connected not connected not connected not connected not connected not connected until I close the app.

pledi commented 3 years ago

I'm currently trying to figure out why it sometimes connects but instantly disconnects again. For once, I can fix it with removing the device in the bluetooth settings. Also, what OS are you using ? On Win10 I dont get the Core Bluetooth Error 🤔

Ryamonster10 commented 3 years ago

I am using MacOS, I can try my windows computer though

Ryamonster10 commented 3 years ago

I'm currently trying to figure out why it sometimes connects but instantly disconnects again. For once, I can fix it with removing the device in the bluetooth settings. Also, what OS are you using ? On Win10 I dont get the Core Bluetooth Error 🤔

I will try that and let you know what happens

pledi commented 3 years ago

For mac comment out the line 133 and 134 in the main.py (https://github.com/pledi/EmberControl/blob/65a5c7752a883924bd231a3ce5422bac7d93b78b/main.py#L133) Put your mug into pairing modus and run the app again, it should find it and at least read out the current temp and battery. Without pairing, the mug might stay in pairing mode though. I still need to see how embers connection phase works to replicate it and see if we can somehow add pairing to macOS.

Ryamonster10 commented 3 years ago

That worked! Thank you!

pledi commented 3 years ago

I've added an extra check for macOS to avoid the pairing error in the latest commit. I've also experimented with setting the temperature. It still fails, but I've opened an issue on the bleak repo, maybe they can spot my error and help me out.

Once I figured it out, I will push my local changes, including some basic background animations.

Ryamonster10 commented 3 years ago

Ok! This is amazing! Thanks so much!

pledi commented 3 years ago

@Ryamonster10 the latest version should be able to set the mug to 59°C for Tea and 55°C for Coffee. It's working on Windows 10, I will test if it works on Mac tomorrow morning and update this answer.

If you want to use another temperature, feel free to edit the parameters of https://github.com/pledi/EmberControl/blob/b39ec3b21ddeaf11d3e3b4c3786ca7faba9b022e/main.py#L172 and https://github.com/pledi/EmberControl/blob/b39ec3b21ddeaf11d3e3b4c3786ca7faba9b022e/main.py#L177 Example: For 57.5°C you would need to use 5750 as parameter

The next step is cleaning up the code, maybe splitting and renaming a bunch of stuff and planning a settings menu to change the LED Color, and the two settings for tea and coffee. If you have any ideas, feel free to open an issue or open a PR.

Ryamonster10 commented 3 years ago

Works perfectly on my mac! Even takes the mug out of pairing mode sometimes! Thanks so much!