Giter VIP home page Giter VIP logo

homebridge-brewer's Introduction

homebridge-brewer

verified-by-homebridge npm npm

Homebridge plugin for brewing coffee with your Nespresso machines using HomeKit accessories.

Features

With this plugin you can brew coffee using Siri and schedule your coffee within your 'Good Morning' Scene! The plugin exposes the following switches to Homekit: Ristretto, Espresso, Lungo, Americano, Water. Besides, there are also sensors:

Sensor Description
Brewing Opens whenever the brew starts, closes when the brew finishes.
Descealing Needed Opens whenever descealing is needed.
No Capsules Opens whenever you ran out of capsules. (Make sure to setup correctly)
No Water Opens whenever there is no water in the tank.
Slider Opens/Closes together with the capsule-slider on your machine.
Tray Error Opens whenever a capsule jams the tray or whenever the capsule tray is full.

Capsule Count

The status of the capsule count is reflected using the battery level inside the Home App. By default the 'max_capsule_count' count is 0, this is the maximum number your machine can decrement. First make sure to setup the amount of capsules left inside the Nespresso App. Whenever this plugin runs, you can't connect via the app, because the machine can only connect one device at a time!

Let's say 500. This means that the battery percentage will be 50%; 500 capsules left of the max_capsule_count 1000. Below 10% Homekit will provide a low battery warning to remind you to order new cups.

Installation

Make sure your system matches the prerequisites. Also when using a weaker Bluetooth Homekit-Server (especially a Raspberry Pi), make sure its close to the machine before taking it furhter away. The Nespresso machines require a strong connection otherwise you will see random disconnects before the brew even started. Whenever it works you can try to move the Homekit-Server further away.

Noble is BLE central module library for Node.js used to communicate with the coffee machines.

These libraries and their dependencies are required by the Noble library and provide access to the kernel Bluetooth subsystem:

sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

For more information see the Noble documentation.

Install homebridge and this plugin

[sudo] npm install -g --unsafe-perm homebridge
[sudo] npm install -g --unsafe-perm homebridge-brewer

Homebridge configuration

Update your Homebridge config.json file. See config-sample.json for a complete example.

"platforms": [
        {
            "machines": [
                {
                    "name": "Expert_AHD34DDBADCC",
                    "token": "DA-03-4B-BB-AA-CC-AA-CC",
                    "temperature": "Medium"
                }
            ],
            "platform": "Brewer"
        }
    ],
Key Default Description
Brewer "Brewer" Mandatory. The name provided to Homebridge. Must be "Brewer".
machines [] Array of configured machines, is needed if you want to display one. (Multiple are supported)
displayName "Coffee" The name of this accessory. This will appear in your Home-app.
name Mandatory. The bluetooth name of the machine, can be found on your phone or pc, or any bluetooth discovery app. (see below)
token Authentication token which is required to send any commands see below ho to gather one. Make sure the format is exactly "XX-XX-XX-XX-XX-XX-XX-XX"
temperature "Medium" Mandatory. The temperature which is used to brew your coffees. Can be set to "Low", "Medium" and "High".
disabled_beverages [] Optional. Disable the exposed switches, can be set to a list of items that shouldn't be exposed to the Home-app: ["ristretto", "espresso", "lungo", "americano", "water"]
max_capsule_count 0 Optional. Set your maximum capsule count. The capsule count is displayed as battery percentage: 500 of 1000 (capsule_count) == 50%. Value can be between 1-1000, 0 is disabled (default)

Name

You can find the name quite easily add the platform and check the homebridge log. If your homebridge server has bluetooth enabled and is close enough to the machine you will see something like this: [3/19/2021, 9:19:27 PM] [Brewer] Found new device, please add configuration for: "Expert_AHD34DDBADCC" The value "Expert_AHD34DDBADCC" should be used for the name in the configuration.

Token


In order to retrieve the token (you need to snoop the bluetooth packets:

  • Use an Android-Phone
  • Go to developer options in settings, enable BLE HCI snoop
  • Start the Nespresso App (you need to have registered this and connected to your machine already)
  • Brew a cup of coffee
  • Stop BLE HCI snoop.
  • Connect the mobile to USB/PC and copy or email the file (location: \#{name}\Phone\Android\data\btsnoop_hci.log)
  • Use the shell to extract find the token:
hexdump -v -e '/1 "%02X "' btsnoop_hci.log | grep -o '0B 00 04 00 12 14 00 \<.. .. .. .. .. .. .. ..\>'

This will search hexdump the log file (btsnoop_hci.log) and then grep for the sequence and 8bytes wildcards <..>, which is the authKey. Write between the bytes dashes to match the pattern which is required by this plugin. For example you will find:

0B 00 04 00 12 14 00 DA 03 4B BB AA CC AA CC

Take the last part (8 bytes) to creat the token:

DA-03-4B-BB-AA-CC-AA-CC

Legal

Nespresso is an registered trademarks of Nestlé Nespresso S.A.

This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Nespresso or any of its affiliates or subsidiaries.

Credits

These users/repositories helped making the Homekit integration possible:

@farminf - https://gist.github.com/farminf/94f681eaca2760212f457ac59da99f23

@fsalomon - https://github.com/fsalomon/nespresso-expert-ble

@petergullberg - https://github.com/petergullberg/brewbutton

And me and yes, I like coffe ;)

homebridge-brewer's People

Contributors

tritter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

majirosstefan

homebridge-brewer's Issues

brewer and Monterey

Hello, did you notice problems with macOS Monterey?
Now I receive this message
libc++abi: terminating with uncaught exception of type Napi::Error: Attempt to access memory outside buffer bounds
and homebridge reboots continuously. if I disable bluetooth and then re-enable it, homebridge restarts but the plugin is no longer able to connect to nespresso

Keurig support

Is your feature request related to a problem? Please describe:
No, wondering if Keurig support is in the pipeline.

Describe the solution you'd like:
Keurig support for SMART brewers.

Describe alternatives you've considered:
N/A

Additional context:
N/A

Not connecting to Expert&Milk despite being picked up in Bluetoothctl

Describe The Bug: Homebridge instance with brewer is unable to connect to Nespresso Expert&Milk.

To Reproduce: Configure as described, extract key and input details

Expected behavior: Connects successfully

Logs (Homebridge)

[24/08/2023, 16:22:00] [Brewer] [WATCH] Machine Expert&Milk_F61AD08F571A unreachable, still scanning
[24/08/2023, 16:23:00] [Brewer] [WATCH] Unreachable, this seems unintended try to move your hombridge server closer to the machine!

Logs (Bluetoothctl)

root@raspberrypi:~# systemctl status bluetooth
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-08-24 16:02:38 BST; 2min 44s ago
       Docs: man:bluetoothd(8)
   Main PID: 809 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 779)
        CPU: 260ms
     CGroup: /system.slice/bluetooth.service
             └─809 /usr/libexec/bluetooth/bluetoothd

Aug 24 16:02:36 raspberrypi systemd[1]: Starting Bluetooth service...
Aug 24 16:02:38 raspberrypi bluetoothd[809]: Bluetooth daemon 5.55
Aug 24 16:02:38 raspberrypi systemd[1]: Started Bluetooth service.
Aug 24 16:02:38 raspberrypi bluetoothd[809]: Starting SDP server
Aug 24 16:02:39 raspberrypi bluetoothd[809]: Bluetooth management interface 1.22 initialized
Aug 24 16:02:39 raspberrypi bluetoothd[809]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Aug 24 16:02:39 raspberrypi bluetoothd[809]: sap-server: Operation not permitted (1)
Aug 24 16:02:39 raspberrypi bluetoothd[809]: Failed to set privacy: Rejected (0x0b)
Aug 24 16:03:26 raspberrypi bluetoothd[809]: Endpoint registered: sender=:1.34 path=/MediaEndpoint/A2DPSink/sbc
Aug 24 16:03:26 raspberrypi bluetoothd[809]: Endpoint registered: sender=:1.34 path=/MediaEndpoint/A2DPSource/sbc
root@raspberrypi:~# hciconfig -a
hci0:	Type: Primary  Bus: UART
	BD Address: B8:27:EB:45:D8:2C  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING 
	RX bytes:547598 acl:0 sco:0 events:14563 errors:0
	TX bytes:3651 acl:0 sco:0 commands:113 errors:0
	Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: SLAVE ACCEPT 
	Name: 'raspberrypi'
	Class: 0x2c0000
	Service Classes: Rendering, Capturing, Audio
	Device Class: Miscellaneous, 
	HCI Version: 5.0 (0x9)  Revision: 0x17e
	LMP Version: 5.0 (0x9)  Subversion: 0x6119
	Manufacturer: Cypress Semiconductor (305)

root@raspberrypi:~# bluetoothctl
Agent registered
[CHG] Controller B8:27:EB:45:D8:2C Pairable: yes
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:45:D8:2C Discovering: yes
...
...
[CHG] Device F6:1A:D0:8F:57:1A RSSI: -61
[CHG] Device F6:1A:D0:8F:57:1A TxPower: 4
[CHG] Device F6:1A:D0:8F:57:1A Name: Expert&Milk_F61AD08F571A
[CHG] Device F6:1A:D0:8F:57:1A Alias: Expert&Milk_F61AD08F571A

Hexdump Log:

jam@Jamess-MacBook-ProDesktop % hexdump -v -e '/1 "%02X "' btsnoop_hci.log | grep -o '0B 00 04 00 12 14 00 \<.. .. .. .. .. .. .. ..\>'
0B 00 04 00 12 14 00 88 74 2D 7B 96 90 14 F4

Plugin Config:

        {
            "machines": [
                {
                    "name": "Expert&Milk_F61AD08F571A",
                    "token": "88-74-2D-7B-96-90-14-F4",
                    "temperature": "Medium"
                }
            ],
            "platform": "Brewer"
        }

Screenshots:
N/A

Environment:

  • Plugin Version: 2.1.1
  • Homebridge Version: 1.6.1
  • Node.js Version: 18.17.1
  • NPM Version: 9.8.1
  • Operating System: Raspbian / Debian 11

Plugin Error

Hello!

Plugin Error noticed. Crash homebridge
Képernyőkép 2022-06-03 115114
.

Token generation not work

Hello! Shell command not working. What am i do wrong? File copied to C:, adminsitrator mode okay.

PS C:> hexdump -v -e '/1 "%02X "' btsnoop_hci.log | grep -o '0B 00 04 00 12 14 00 <.. .. .. .. .. .. .. ..>'
hexdump : The term 'hexdump' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • hexdump -v -e '/1 "%02X "' btsnoop_hci.log | grep -o '0B 00 04 00 12 ...
  •   + CategoryInfo          : ObjectNotFound: (hexdump:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

Capsule count

Superb idea, would it be possible to implement the capsule count?

Working in Conjunction With Other Noble/Bluetooth Devices on The Same Pi/Homebridge

Describe Your Problem:
Heyo; This isnt exactly an issue with your plugin, but a higher level issue I'm hoping you can help me resolve to allow your plugin to work smoother alongside my others.

I have been using brewer for a few months now and have it running in some wicked cool automation (My fave being having it trigger a cup of coffee and cancel it to heat up the machine 1 minute before my alarm, then pouring the cup when I get out of bed based on a pressure sensor under my mattress). Anyway.

I recently installed a plugin that uses the same Noble protocol to connect to my SOMA smart shades, at first all was well however as soon as I tried to use the brewer home bridge went crazy on me, essentially not being able to connect to either device. I've done some digging and it seems the issue is that noble can effectively only do one thing at once. This information was gathered from this support thread in the SOMA repo mylylyl/homebridge-soma-shades#2, and then this further link more detailing the problem that someone posted in the respective thread. abandonware/noble#26
I would normally be bugging those guys, however the dev seems to be inactive there.

From what I understand based on the second link I posted there, the solution would be to connect a USB adapter to the Pi, and have one plugin use the onboard adapter, and one use the external USB adapter.

I'm somewhat savvy, however when it comes to dealing with things like noble, and even worse, noble integrated within a homebrdige plugin, I'd be at a loss as far as how to do this. I'd figure as someone who has dealt with both of these in building a rather fanatic plugin, you may. be able to help. Would be happy to send a coffee or two your way/a tip of some sort in return for the help here if you are willing.

Logs:

Show the Homebridge logs here, remove any sensitive information.

Plugin Config:

Show your Homebridge config.json here, remove any sensitive information.

Screenshots:

Environment:

  • Plugin Version:
  • Homebridge Version:
  • Node.js Version:
  • NPM Version:
  • Operating System:

Link to package bluetooth_hci_socket-0.5.3-10-node-v108-linux-arm.tar.gz is no longer valid

Describe The Bug:
Homebridge-Brewer 2.1.1 is not working correctly due to missing package bluetooth_hci_socket-0.5.3-10-node-v108-linux-arm.tar.gz . The link which it refers to errors out to a 404: https://github.com/abandonware/node-bluetooth-hci-socket/releases/download/0.5.3-10/bluetooth_hci_socket-0.5.3-10-node-v108-linux-arm.tar.gz

To Reproduce:
Install Homebridge-Brewer 2.1.1 via Homebridge.

Expected behavior:
Install is succesfull without errors

Logs:

Show the Homebridge logs here, remove any sensitive information.

Plugin Config:

Show your Homebridge config.json here, remove any sensitive information.

Screenshots:

Environment:

  • Plugin Version: 2.1.1
  • Homebridge Version: 1.6.1
  • Node.js Version:
  • NPM Version:
  • Operating System: Raspbian

Bluetooth disconnects immediately after connecting

Hello,
I have tried setting up my Nespresso Expert with Brewer in homebridge both on a Mac running MacOS and a Raspberry Pi Zero W, but I haven't been able to successfully brew a coffee. It seems like the bluetooth connection drops immediately after connecting. I have tried to manually connect but it still doesn't work.

I get this inside the logs:
[Brewer] [WATCH] Machine Expert_CDD376ED07FE unreachable, still scanning

And also sometimes I get this:
noble warning: unknown handle 64 disconnected!

The Raspberry Pi is litterally behind the machine so I don't think it's a proximity problem.

I'm new to Raspberry Pi so any detailed help would be greatly appreciated.

Thanks

Machine disconnected

Thanks for creating this plugin, I'd love to get it to work and get Siri to brew me a fresh coffee in the morning.

I've used Bluetooth HCI Snoop on an Android phone to get the btsnoop_hci.log file. I tried the hexdump command, but gave me no results. Tried with Wireshark, but was not abled to get the key.

Then I followed the instructions by n2k here [ https://gist.github.com/farminf/94f681eaca2760212f457ac59da99f23 ] and tried extracting the key from the database by using a rooted Android phone.

$ sqlite3 nespresso_app_fusion.db 'SELECT pairing_key FROM MyMachines;'
2FAECC7DFF8C42E6BBBCAC1810F011E8

Running the pairing_key.java script gave me this result
Current key: 2FAECC7DFF8C42E6BBBCAC1810F011E8
Current key hex: 82FAECC7DFF8C42E

So now I have a key, but how do I convert this into a valid token?

Firmware 6.0
Connectivity Firmware 1.27

Wifi support

Does this plugin support wifi on the Vertuo Next model?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.