Flashforge Finder API add-on

Hi!

I made an add-on for exposing Flashforge Finder 3D printers as API endpoints to consume as RESTful sensors. Right now I’m using it to get extruder temperature and build progress data.

Repository: https://github.com/johnpdowling/hassio-addons
README:

Flashforge Finder API hass.io add-on

A hass.io add-on for exposing data from Flashforge Finder(s) as API endpoints for consumption as HA REST sensors. This project is more or less a wrapper around 01F0’s work here: https://github.com/01F0/flashforge-finder-api.

Usage

  1. Install the addon and configure the port that the API will be served on. Default is 5000.

  2. Start the addon. Information about your printer will be available at
    http://{homeassistant_ip}:{fff-api_port}/{printer_ip}/{info|head-location|temp|progress|status}

  3. Configure RESTful sensors in HA as necessary

3 Likes

This is great. I can confirm that it’s working with my Flashforge Adventurer 3 (I did not upgrade the firmware).

However, the default port failed to work for me. I changed it to 8899 and it’s now working fine.

Thanks for building this!

Thanks for this! Couldn’t get it working with the latest version of Flask , had to adjust the docker file to use version 1.0.4 :

RUN pip install flask==1.0.4 flask-cors

Guess it’s a problem in the upstream version. Works fine on Flask version 1.0.4 on my Flashforge Finder

Thanks. This looks very promising, by I haven’t yet gotten it to work with my Finder running firmware v.2.7.2.366 F18 20191224. For example:

http://192.168.86.111:5001/192.168.86.32/status

results in error 500:

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I also tried with Flask v1.04

Here’s the error from the log:

[2020-04-04 12:40:29,889] ERROR in app: Exception on /192.168.86.32/status [GET]
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/fff-api/api/webapi.py", line 59, in status
    printer_info = get_status({'ip': ip_address, 'port': PORT})
  File "/fff-api/api/protocol.py", line 83, in get_status
    send_and_receive(printer_address, request_control_message)
  File "/fff-api/api/socket_handler.py", line 14, in send_and_receive
    data = printer_socket.recv(BUFFER_SIZE)
timeout: timed out
192.168.86.92 - - [04/Apr/2020 12:40:29] "GET /192.168.86.32/status HTTP/1.1" 500 -

Is the request formatted correctly? Any other tips?

Cheers.

I had the chance to try this again. It was my mistake. Another add-on was assigned to port 5000. I changed the port to 5013, and it now works. For example:

http://192.168.86.111:5013/192.168.86.32/status

while printing is in progress yields:

{"Endstop":"X-max:0 Y-max:0 Z-max:0","MachineStatus":"BUILDING_FROM_SD","MoveMode":"READY","Status":"BUILDING_FROM_SD"}

The API is apparently not accessible when FlashPrint is actively connected to the printer, either by WiFi or USB. Calls return 500 Internal Server Error. So, remember to disconnect the printer in FlashPrint or close FlashPrint after sending the GX code.

Example RESTful sensor:

- name: Flashforge Finder Progress
  platform: rest
  resource: http://192.168.86.111:5013/192.168.86.32/progress
  json_attributes:
    - BytesPrinted
    - BytesTotal

The other JSON pair returned is by the API call is PercentageCompleted. Its value is always 0 for some reason, but you can make a template sensor to calculate the percentage:

- platform: template
  sensors:
    flashforge_finder_percent_complete:
      value_template: >
        {{ state_attr('sensor.flashforge_finder_progress', 'BytesPrinted') | float /state_attr('sensor.flashforge_finder_progress', 'BytesTotal') | float * 100 }}
      unit_of_measurement: '%'
1 Like

Hi,
can you please write a step to stpe how to install this addon into Home Assistant ??

Rickard

Does this still work? I get an error when trying to install through Supervisor.

The command '/bin/ash -o pipefail -c apk add --no-cache --virtual build-deps alpine-sdk cmake git python python-dev py-pip build-base' returned a non-zero code: 70
1 Like

I have the same issue today.

The command '/bin/ash -o pipefail -c apk add --no-cache --virtual build-deps alpine-sdk cmake git python python-dev py-pip build-base' returned a non-zero code: 70