modrzew / hass-flashforge-adventurer-3

Home Assistant integration providing support for the FlashForge Adventurer 3 3D printer.
20 stars 10 forks source link

Adventurer 3 Pro - No camera entity #5

Open stumain opened 1 year ago

stumain commented 1 year ago

Hello, I have just added an Adventurer 3 Pro connected via wifi. The printer is correctly added and the status including attributes updates properly. However, I only get 2 entities;- .state and .progress as shown. There is no camera. However the camera is enabled to manual (so as the USB port is disabled - only camera or usb be can work at a single time). And the direct stream also functions from a browser (http://ip_addr:8080/?action=stream). Any suggestions on why the other entity wouldn't populate. Have tried removing, re-adding the custom component from HA and of course restarting HA after addition and see an error in the log for the camera.

HA V2022.11.1

Logger: homeassistant.components.camera
Source: custom_components/flashforge_adventurer_3/camera.py:34 
Integration: Camera (documentation, issues) 
First occurred: 5:52:24 PM (3 occurrences) 
Last logged: 7:17:36 PM

Error while setting up flashforge_adventurer_3 platform for camera
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/flashforge_adventurer_3/camera.py", line 27, in async_setup_entry
    FlashforgeAdventurer3Camera(config),
  File "/config/custom_components/flashforge_adventurer_3/camera.py", line 34, in __init__
    self.type = printer_definition['type']
KeyError: 'type'
stumain commented 1 year ago

Update: if I comment out line 34 of camera.py then it works.

self.type = printer_definition['type']

However, I am struggling to understand how I can pull in the attributes. The usual code for an entities card doesn't seem to be showing the values. I would also like to know if I can have these attributes be a trackable entity, so I can show graphs on the bed temperature history for example...

square: false
columns: 2
type: grid
cards:
  - type: entities
    entities:
      - entity: sensor.flashforge_adventurer_3_state
        name: Status
        secondary_info: last-updated
    show_header_toggle: false
    state_color: false
    title: FlashForge Status
  - type: gauge
    entity: sensor.flashforge_adventurer_3_progress
    name: Printing Progress
    unit: '%'
    needle: false
  - type: entities
    entities:
      - type: attribute
        entity: sensor.flashforge_adventurer_3_state
        attribute: Online
      - type: attribute
        entity: sensor.flashforge_adventurer_3_progress
        attribute: Desired nozzle temperature
      - type: attribute
        entity: sensor.flashforge_adventurer_3_state
        attribute: Bed temperature
        name: Bed temperature
      - type: attribute
        entity: sensor.flashforge_adventurer_3_state
        attribute: Desired bed temperature
        name: Desired bed temperature
  - show_state: true
    show_name: true
    camera_view: auto
    type: picture-entity
    entity: camera.flashforge_adventurer_3_camera

Update: My mistake was not using the right attribute names, realised I needed to get these from the developer tools states console. Attribute display is working now. I can create template sensors for the items I want to track over time such as temperature levels.

The commented out line 34 in camera.py is still needed for mine to work though.

Last request, any idea if it's possible to pull the estimated time remaining from the printer?

modrzew commented 1 year ago

Hey! I'm glad that it's working for you now. As for the remaining time, if 3 Pro is the same as 3, then unfortunately the remaining time is only displayed on the printer's LCD screen. I don't know of a way to obtain it programatically — I guess that's the reason why FlashPrint also doesn't display remaining time, but just progress.

stumain commented 1 year ago

Thank you for the reply. I was worried that would be the case. I'm now thinking it could be estimated based on the progress and how long it has taken to progress to a current percentage. When I look at the history for the print jobs, it's fairly linear progression, so while it won't match what the printer shows, it gives a nice estimation in HA dashboard.

I just don't know how to do that - not a developer... I'm researching and will reply if I come up with something, but perhaps you already know how to do this in code? Something like: [time difference] from last 0% to [current percent] devided by [current percent] multiply by remaining percent(difference between [current percent and 100].

image

modrzew commented 1 year ago

That's a nice idea! Let me think about it and see how it can be done. I think you might also be able to achieve something similar using a combination of automations and/or helpers and/or templates, but it'd definitely be easier to have just another attribute showing the ETA.

d-cordes commented 1 year ago

I recently bought and connected a new Adventurer 3 (Standard Edition) and connected it to home assistant with this module. Thanks so far. However, the camera entity does not show up on my end as well. I have the most recent firmware installed on the printer.

patstave commented 1 year ago

I also have the Adventurer 3 Pro and i can confirm:

stumain commented 1 year ago

@d-cordes / @patstave - Did you comment out the line 34 in camera.py like I did. As of now, my adventurer 3 pro camera shows in my lovelace dashboard correctly, both with periodically update images in the card and also as a stream within lovelace when I click on the image. Commenting out of that line is all I did to get it working.

Note, when you are not actually printing something the camera will not display. So I created conditions in the card to hide the camer display unless the status of the printer is 'printing'. Let me know if you want me to provide more details or yaml example.

modrzew commented 1 year ago

Hey everyone, sorry for dropping the ball on this one a bit. I had a brainfart last time I read this issue and the self.type = printer_definition['type'] line is definitely my mistake — I didn't clean it up properly. I just published version 1.0.2, please upgrade and let me know if it solves the issue 🙂

Btw @stumain calculating the ETA is still on my todo list, it really sounds like a cool improvement but needs a bit more work.

d-cordes commented 1 year ago

Hey everyone, sorry for dropping the ball on this one a bit. I had a brainfart last time I read this issue and the self.type = printer_definition['type'] line is definitely my mistake — I didn't clean it up properly. I just published version 1.0.2, please upgrade and let me know if it solves the issue 🙂

Btw @stumain calculating the ETA is still on my todo list, it really sounds like a cool improvement but needs a bit more work.

Hi @modrzew : Thanks for providing the fix. It works now without any issues. Great module.