Git Product home page Git Product logo

decent-advanced-rest-api's Introduction

The idea

Before I even received my Decent Espresso Machine I was searching for possibilities to integrate the machine with Home Automation systems.

On the diaspora I stubled upon the Web API created by Johanna Schander (https://github.com/decentespresso/de1app/tree/main/de1plus/plugins/web_api) and also the more detailed API by Henrik Pejer (https://github.com/pejer/decentespresso_module_system/tree/modules/modules/pejer_web_api). The second one was integrated directly to the app. So it will break with every update. Since there is a good working plugin system I thought this should be used.

I talked to both and with their "blessing" I combined both ideas and added mine to it.

What does it do?

  • get a simple or detailed state of the machine
  • change the state to standby or enable it
  • get, display or download shot files
  • get, download or upload profiles

How to use it?

  • Copy the files to the plugin folder into a folder called "advanced_rest_api".
  • Adjust the plugin settings in the settings file if needed.
  • Activate the plugin in the app settings.

API

There is a documentation about all available API endpoints in the attached json - which is also displayed in the Web UI.

Web UI

Navigate to http://DECENT-IP:8888 in your preferred browser. The port can be changed in the settings. 8080 should be prevented if it is used with the webcast feature.

Home Assistant

There is example configuration for Home Assistant (https://home-assistant.io) in the homeassistant directory.

Homebridge

As requested I added a Homebridge accessory config.

Update: there is now a better way to integrate this plugin with Homebridge: https://github.com/muelmx/homebridge-decent-advanced-rest-api / https://www.npmjs.com/package/homebridge-decent-advanced-rest-api Many thanks to muelmx :-)

... please contact me for feature requests.

Disclaimer

Of course the usage of this is at your own risk. It may break your machine. You are creating a web server with an unencypted connection in your network. Please be cautious.

This is my first work in TCL - please be nice ;-)

decent-advanced-rest-api's People

Contributors

incase avatar lorebialas avatar randomcoffeesnob avatar silasg avatar tadelv avatar ulope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

decent-advanced-rest-api's Issues

Errors in logs

Not sure if this is a config issue or what but I am seeing this in the homebridge logs quite a bit:

[03/10/2023, 14:18:42] [decent-advanced-rest-api] error updating machine state SyntaxError: Unexpected token * in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/var/lib/homebridge/node_modules/homebridge-decent-advanced-rest-api/src/de1DeviceService.ts:132:34)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

HB Plugin version: homebridge-decent-advanced-rest-api v1.1.0
Decent Plugin verison: 1.2

Can't real element in array

Hey! just stumbled onto your plugin. I tried giving it a whirl, but when I navigate to the web ui i get this error:

errorinfo: can't read "::plugins::advanced_rest_api::settings(webserver_authentication)": no such element in array
    while executing
"if {$auth eq "" && $::plugins::advanced_rest_api::settings(webserver_authentication) == 1} {
			return [unauthorized $state]
		}"
    (procedure "check_auth" line 5)
    invoked from within
"check_auth $state"
    (procedure "::wibble::indexpage" line 2)
    invoked from within
"{*}$command $state"
    (procedure "getresponse" line 30)
    invoked from within
"getresponse $request"
*** INTERNAL SERVER ERROR (END #10) ***

I've never messed with TCL or the decent plugin system before, but maybe I need to set line 1 to de1_machine 1.39 to match my version? Maybe the settings block on line 22 needs a webserver_authentication property? I see webserver_port and webserver_authentication_key. Let me know if you've got any suggestions. I'm about to dig in do a little guess and test.

Water_Level is missing

here is my configurations.yaml

rest:
    - resource: http://192.168.2.101:8888/api/status/details
      scan_interval: 2
      sensor:
      - name: Decent Espresso State
        unique_id: decentespresso_state
        value_template: "{{ value_json.state }}"
      - name: Decent Espresso Substate
        unique_id: decentespresso_substate
        value_template: "{{ value_json.substate }}"
      - name: Decent Espresso Shot Count
        unique_id: decentespresso_espresso_count
        value_template: "{{ value_json.espresso_count|is_defined }}"
      - name: Decent Espresso Steam Count
        unique_id: decentespresso_steaming_count
        value_template: "{{ value_json.steaming_count|is_defined }}"
      - name: Decent Espresso Head Temperature
        unique_id: decentespresso_head_temp
        value_template: "{{ value_json.head_temperature|default(0)|round(1) }}"
        unit_of_measurement: "  C"
      - name: Decent Espresso Mix Temperature
        unique_id: decentespresso_mix_temp
        value_template: "{{ value_json.mix_temperature|default(0)|round(1) }}"
        unit_of_measurement: "  C"
      - name: Decent Espresso Steam Temperature
        unique_id: decentespresso_steam_temp
        value_template: "{{ value_json.steam_heater_temperature|default(0)|round(1) }}"
        unit_of_measurement: "  C"
      - name: Decent Espresso Water Level
        unique_id: decentespresso_water_level
        value_template: "{{ value_json.water_level|replace(' mL', '')|default(0) }}"
        unit_of_measurement: ml
      - name: Decent Espresso Profile
        unique_id: decentespresso_profile
        value_template: "{{ value_json.profile|replace('_', ' ') }}"

switch:
    - platform: rest
      name: "Decent Espresso"
      resource: http://192.168.2.101:8888/api/status
      body_on: '{"active": "true"}'
      body_off: '{"active": "false"}'
      is_on_template: "{{ value_json.is_active }}"
      headers:
          Content-Type: application/json

In my home assistant:
image

Pure http request:

CleanShot 2023-08-06 at 22 28 59

you can see when i GET from /api/details . water_level is missing in response

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.