Smarter Wifi iKettle 2 script for Domoticz

Python and python framework
ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 07 August 2016 11:05

I've updated the script in the first post of this thread, fixed a few things:

1) Script would freeze after about 3 - 6 hours, now it loops the entire connection so as not to do that.

2) Implemented work-around for reliability issue with my kettle in detecting if it is on or off base using the temperature 127 if it's off base to determine the on / off base status (instead of the 07 / 08 which I found to be unreliable).

3) Implemented 4 temperature selection options via command line variables

Starting to think we need a nice web interface or something for the kettle AND coffee machine. Domoticz is ok with just the kettle but there are too many configuration options for the coffee machine, I think a seperate page is needed.
Screen Shot 2016-08-07 at 7.06.58 PM.png
Screen Shot 2016-08-07 at 7.06.58 PM.png (28.78 KiB) Viewed 1713 times
I had to blank out the icon cause I bought it off some icon site :cry:

Also I think it would be great to change the number of cups to the actual ml in the kettle as you suggested.
on base.png
on base.png (19.2 KiB) Viewed 1710 times
off base.png
off base.png (18.37 KiB) Viewed 1710 times

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Sunday 07 August 2016 12:02

I could not get a reliable reading on the ml... there is the base value and the sensor reading... i mapped out some numbers... but i see no relation. ie. the numbers would change too much even with the same amount of water in the kettle if you put the kettle off base and on base again...

you can check it out on the github page...
https://github.com/Tristan79/iBrew

still have some problems with network connection... (the console waits on user input, means message are not read from the socket...
resulting in a backlog of status messages...)

but it's all new for me python, servers, network :-)

i figures this one out...

Code: Select all

  Command Message: 15 Turn on
  ─────────────────────────────────────────────────────────────────────────
  ✓ iKettle 2.0  ? SmarterCoffee

  Argument: <temperature><keepwarm>

  temperature 00..64
  keepwarm  0 (not warming), minutes: 05..1e

  15 32 00 7e start boiling
  15 32 7e     start boiling
  15 32 05 7e 
  
  if it's not on temp it boils first before warming...
  if it's warming you have to send an off command to boil again

The water level is at least in some of the sources:
waterlevelMessage = int(b[4], 0) + 256 * waterlevelMessage = int(b[3], 0)
the calibration base is of the same format... but no correlation

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 07 August 2016 12:22

I have a whole inventory of Gizmos I'm trying to integrate into Domoticz at the moment:

iKettle 2.0 (done)
Smarter Coffee machine (in progress)
Roomba 980 Robotic Wifi vacuum cleaner (in progress, extremely difficult cause all communication is SSL encrypted with what appears to be a self signed cert, I haven't been able to read the packets locally).
Braun Oral B bluetooth toothbrush

:)

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Sunday 07 August 2016 14:17

Ha I figured out how to see traffic... got 2 new command before it didn't work anymore...

Code: Select all

10.0.0.99:iKettle 2.0$message 19

  Command Message: 19 Formula Mode
  ─────────────────────────────────────────────────────────────────────────
  ✓ iKettle 2.0  ? SmarterCoffee

  Arguments: <formulatemperature><keepwarmtime>

  Example raw code: 19 32 19 7e
  Boil water to (default user temperature)
 and cool until 50'C (32) with keep warm time of 25 minutes (19)

iBrew: Ready On Base (72ºC, 1.8l)
10.0.0.99:iKettle 2.0$message 1f

  Command Message: 1f Set Default Values
  ─────────────────────────────────────────────────────────────────────────
  ✓ iKettle 2.0  ? SmarterCoffee

  Arguments <keep warm time><defaulttemp><formula><formulatemp>

  Example raw code: 1f 19 64 01 22 7e
  sets 25 keep warm, 100 default temperature, formula mode = true
  34 formula temperature

  default user defaults are 1f 00 64 00 4b 7e 

iBrew: Ready On Base (71ºC, 1.8l)
10.0.0.99:iKettle 2.0$info
iBrew: Message Send 64 7e 
       Get identify of device
iBrew: Message Received: 65 01 13 7e 
       Identify of device iKettle 2.0 Firmware v19
iBrew: Ready On Base (71ºC, 1.8l)
10.0.0.99:iKettle 2.0$

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 07 August 2016 14:32

Nice! How did you see the packets if you don't mind me asking? I've never managed to figure out wireshark.

I'm interested since it might help me to get the Roomba 980 working locally.

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Sunday 07 August 2016 14:52

Since I did not know what I was doing, I tried many options...

In the end i configured the kettle to my local homenetwork like normal,
on my mac i plugged in a cable, cable connects to internet/homenetwork
then i put internet sharing on in the sharing settings, and the wifi becomes an access point... I connected my phone to my mac, and then it just worked,... i was very surprised :o :o

kettle <-> homenetwork <-> cable <-> macbook (wireshark,internet connection sharing) <-> wifi <-> phone

wireshark, if you open it, you select the connection (in this case wifi to capture the phone messages)... and then run the app on the phone...
ofcourse I accidently reset the wifi of the kettle, so now I have to try it again... :|

you should look for messages ending in 7e

screenshot from my own communication kettle <-> ibrew,...
Screen Shot 2016-08-06 at 09.31.32.jpg
Screen Shot 2016-08-06 at 09.31.32.jpg (185.25 KiB) Viewed 1676 times
Last edited by trixwood on Sunday 07 August 2016 14:56, edited 1 time in total.

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 07 August 2016 14:54

Ahh interesting way of doing it making the Mac the wifi access point, I'll try that with the Roomba.

Thanks!

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Sunday 07 August 2016 15:17

im not really sure, but i implemented a little scale to hopefully get the right waterlevel, and after a boiling test I notice, that the temperature has inpact on the value you get.... higher temprature higher waterlevel still not sure how to proceed... :-)

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 07 August 2016 15:20

Trixwood, I noticed the water level jumps around a lot on my kettle as well (and there appears to be a correlation to temperature as you mentioned). Perhaps a filter such as if value above x = 100ml if value above x = 200ml to deliver a somewhat stable value?

Take the cup code of my script as a template for how to do it.

Find the unit level you think is relatively stable, eg 50ml or 100ml, in my case I was lazy and just poured cups of water in it and recorded the values (I have pretty big cups).

Delivering a value that isn't going to change every second is important cause then we can just update Domoticz if the value changes, constantly writing new values to the Domoticz database is bad for the SD cards in devices like Raspberry Pi cause they have a limited number of writes before wearing out so in my script I always check if the value is different before sending the new data to Domoticz which gets written to the Micro SD card.

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Sunday 07 August 2016 15:33

there is a base watersensor value, a watersensor value and the temperature...

not knowing the temp had influence... around 24C i measured
# calibrate nokettlebase: 1120 measure: kettle off: 2010 kettle empty: 2070 kettle full: 2140 (div 890 950 1020)
# calibrate emptykettlebase: 1070 measure: kettle off: 1975 kettle empty: 2020 kettle full: 2085 (div 905 950 1015)
# calibrate fullkettlebase: 1010 measure: kettle off: 1875 kettle empty: 1950 kettle full: 2015 (div 865 940 1005)
# div = measure - base

Code: Select all

#   1.8l
    def water_level(self):
        x = (1.800/72) * (self.waterSensor - self.waterSensorBase - 952)
        return x
50'C

Code: Select all

    def water_level(self):
        x = (1.800/72) * (self.waterSensor - self.waterSensorBase - 1000)
        return x
to het it correct... so that means measuring... ;-)

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Tuesday 09 August 2016 9:04

Hi!

I have really fun figuring this out... :D

Could you run from https://github.com/Tristan79/iBrew

./iBrew sweep (ipofyourcoffee)

And post the relevant output?

I used it to map all commands of the iKettle 2.0 :mrgreen:
(i found the default user settings message (except it does not contains the formula temperature), still have to figure out what some of them do)

Would be nice to have them for the Coffee machine also.
Also so output from raw commands would be nice

Anyway if you have time ;-)

if it fails (wifi reset, ... could be all sort of things...) you can continue with

Code: Select all

./iBrew sweep 2C (ipofyourcoffee)
start scanning for new command starting at command 2C

ps.. the code is a mess, i know...

Update: Found almost all codes & reply plus meaning for the iKettle! Yeah!

bxlouis
Posts: 35
Joined: Wednesday 16 December 2015 15:30
Target OS: Raspberry Pi
Domoticz version: 3.5510
Location: Belgium
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by bxlouis » Sunday 25 September 2016 1:57

Hi,

I tried everything I can but I wasn't able to make your script work :(

First, I think I had some trouble with screen. Even if I installed it, Monit never detected the process running. I think I did something wrong with the startup.sh file... Chmod is ok, I checked path in every file and still it won't work.

Anyway, I just tried to run your python script with sudo python kettle.py and I get an "IndentationError:" on line 25.
I fixed that and I get errors somewhere else, etc. I can't figure it out.
Could you provide the files you are using in order to help me get it working?


Thank you very much!

Andyb
Posts: 2
Joined: Wednesday 26 October 2016 22:01
Target OS: Linux
Domoticz version:
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by Andyb » Thursday 27 October 2016 0:27

Are there any instruction anywhere to get iBrew working on ubuntu? I'm a newbie to Linux although working IT forever... I have ubuntu server running with Homebridge and looking to get iBrew working with the Smarter 2.0 kettle I have either with Domoticz or Homebridge...

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Saturday 29 October 2016 16:17

He!

It has no package since most linux distros pack python ;-), download the source in a folder, open up a terminal go into the folder where the source is and run either "make" or "pip install requirements.txt" :-) That will download any missing python packages. After that you are ready to go...
Note to myself, I will add more instructions when I finish the web part... kinda did not expect anybody else to use it ;-) :-) :-) Probably christmas depends how fast I recovery and can walk again... (yeah bummer for me, everything is on hold for me at the moment)
For binding it with domoticz you can use either the rest api (the part of the webstuff that is finished) or just script it using the command line options.

If you spend more then an hour getting it to work, stop. Post an issue on the github page, (since i get mail from that).
And please do not spend 11 hours ;-)

Signed me!

the rest api which returns json, docs are in the web part (old screeshot):
Screen Shot 2016-09-04 at 13.09.35.png
Screen Shot 2016-09-04 at 13.09.35.png (36.87 KiB) Viewed 1377 times

Andyb
Posts: 2
Joined: Wednesday 26 October 2016 22:01
Target OS: Linux
Domoticz version:
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by Andyb » Sunday 30 October 2016 23:50

Hi Trixwood, Thanks for the reply, I've got a bit further now, but still having issues (me not know how to run stuff) I will post in GitHub.

Thanks Andy

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by trixwood » Thursday 15 December 2016 5:32

https://github.com/Tristan79/iBrew/

Updated iBrew with trigger support & mini guide to integrate the ikettle 2.0 and the smarter coffee in domoticz :-)

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Sunday 24 September 2017 11:30

If anyone runs into this error message:

root@domoticz:~/scripts/smarter# python kettle.py on
Traceback (most recent call last):
File "kettle.py", line 1, in <module>
import requests
ImportError: No module named requests

Solution (on Debian / Ubuntu) is:
apt-get install python-requests

ben53252642
Posts: 364
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by ben53252642 » Wednesday 10 January 2018 10:57

trixwood, are you finding that often the iKettle will not join the Wifi network and just sit with its own SSID broadcasting requiring a manual restart of the kettle?

pazzje
Posts: 36
Joined: Thursday 12 March 2015 18:53
Target OS: Windows
Domoticz version:
Contact:

Re: Smarter Wifi iKettle 2 script for Domoticz

Post by pazzje » Friday 12 January 2018 20:07

I have now an ikettle 2.0 and i wanted to download ibrew.exe for windows but it is no longer avileble. Who has a copy for my?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests