RS 1.2.1 and HomeAssistant Integration broken?

I just updated from RS 1.2.0 to 1.2.1 and the entities no longer appear in HomeAssistant.

I have had HA and RS working together for a good 6 months and never had an issue before with upgrades..

Anything I can check to see why its not working? The webcam feed, not via the RS API, works still.

Comments

  • edited December 2021
    HomeAssistant setup as per https://www.home-assistant.io/integrations/repetier
    This is the setup:
    #RS
    repetier:
      - host: 127.0.0.1
        api_key: KEY_HERE
    camera:
      - platform: mjpeg
        name: RS Camera
        still_image_url: http://127.0.0.1:8080/?action=snapshot
        mjpeg_url: http://localhost:8080/?action=stream
    
    
    The HA Log reports an error with the RS integration, it is missing "activeExtruder":

    Logger: homeassistant.setup
    Source: components/repetier/__init__.py:237 < https://github.com/marthoc/home-assistant/blob/dev/homeassistant/components/repetier/__init__.py >
    First occurred: 10:06:59 PM (1 occurrences)
    Last logged: 10:06:59 PM

    Error during setup of component repetier
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/setup.py", line 249, in _async_setup_component
        result = await task
      File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/usr/src/homeassistant/homeassistant/components/repetier/__init__.py", line 192, in setup
        api.update()
      File "/usr/src/homeassistant/homeassistant/components/repetier/__init__.py", line 237, in update
        printer.get_data()
      File "/usr/local/lib/python3.9/site-packages/pyrepetier/clsprinter.py", line 104, in get_data
        self._activeextruder = data['activeExtruder']
    KeyError: 'activeExtruder'
    

    It seems someone reported an issue earlier on another location - https://github.com/home-assistant/core/issues/59430 . this was working for me 2 days ago on the current HA version with RS 1.2.0; I updated to 1.2.1 today and noticed it was not; maybe something else is the cause?
  • edited December 2021
    Looking at the API: IPAddress/printer/list/?apikey=KEY

    {"data":[{"active":true,"job":"none","jobid":0,"name":"Aquila","online":1,"pauseState":0,"paused":false,"slug":"Aquila"},{"active":true,"job":"none","jobid":0,"name":"Ender 3 v2","online":0,"pauseState":0,"paused":false,"slug":"Ender_3_v2"},{"active":true,"job":"none","jobid":0,"name":"Ender 6","online":0,"pauseState":0,"paused":false,"slug":"Ender_6"}]}

    And then the printer slug level IPAddress/printer/api/Aquila?a=stateList&apikey=KEY

    {"Aquila":{"activeExtruder":0,"autostartNextPrint":false,"condition":1,"conditionReason":"","debugLevel":6,"doorOpen":false,"extruder":[{"error":0,"output":0.0,"tempRead":29.2,"tempSet":0.0}],"fans":[{"on":false,"voltage":0}],"filterFan":false,"firmware":"Marlin","firmwareStyle":"marlin","firmwareURL":"","flowMultiply":100,"hasXHome":true,"hasYHome":true,"hasZHome":true,"heatedBeds":[{"error":0,"output":0.0,"tempRead":34.7,"tempSet":0.0}],"heatedChambers":[],"layer":2,"lights":0,"notification":"Aquila Ready.","numExtruder":1,"powerOn":true,"rec":false,"sdcardMounted":true,"shutdownAfterPrint":false,"speedMultiply":100,"volumetric":false,"x":150.5229949951172,"y":148.2550048828125,"z":0.2000000029802322},"Ender_3_v2":{"condition":5,"conditionReason":"","firmwareStyle":"marlin"},"Ender_6":{"condition":5,"conditionReason":"","firmwareStyle":"marlin"}}

    Should the SLUG level API return to the other printers as well? Should it be limited to just in my query the Aqulia? I have not updated the HomeAssistant for several months and on the 2021.8 build.


    Looking inside the clsprinter.py file on my HA installation, the error is around the ActiveExtruder -

    rawdata = self._request(self._baseurl + '/printer/api/' + self._slug + '?a=stateList&' + self._apikey)
            data = None
            try:
                data = rawdata[self._slug]
            except:
                pass
    
            if data is None:
                return
    
            if self._job == "none":
                self._job = None
    
            self._activeextruder = data['activeExtruder']

    To my understanding of the code, its fetching the same URL as I tested above. Then going into the array under the slug. Therefore, it should work as expected.. or am I crazy..

    Near the top of the PY file is the set command for the apikey as follows: self._apikey = apikey
    >> is it missing the apikey= part for the URL like in my manual query or is this stored in "apikey"
  • I don't have HA so can not say much about it. stateList only has gotten some more fields, but as your test already showed it is still returning activeExtruder. stateList returns for all printers, so queried slug should always be included, except you did a fresh install and slug name has changed.

    One problem might be that it uses
    https://pypi.org/project/pyrepetier/3.0.5/#files

    which points to non existent github url, so guess that project was abadonned.

    On the other side our answer has not really changed, so see no reason that it should not work if it did before.
  • edited December 2021
    Thank you. I am not sure what would cause the issue other than the upgrade to 1.2.1 for RS.

    Is it safe to downgrade my RPi back to 1.2.0 for testing?

    Would there be any logs within RS for the API calls to see if its calling the correct endpoint/apikey?
  • I think downgrading for testing is no problem. Only wizards might be a weak point but they already existst in some form in 1.2.0. I think format was the same.

    There is no log for all the communication. Normally you see it in server for our gui if needed so wanting to reduce writes for pi and safe a lot of disk space. Only way would be a network sniffer like wireshark on windows. 
  • Thanks. Ill hopefully get some time next week to have a play.

    Im not sure how easily i can get wireshark on the Pi for local traffic.. maybe ill install RS on another box and see if i can trouble shoot it that way.

    Once i get it fixed, ill post back
  • I am SO happy I go through these forums once a week or so. I had no idea that HA had integration with RS!
  • I have the same issue.

    Today I updated Repetier Server to 1.2.1 and the HA integration is not working anymore.
    The HA integration is also outdated and definitely needs some love, but the developer has no time/interest doing so.
  • edited December 2021
    Just upgraded to RS 1.2.1 this morning and I can confirm the Home Assistant integration now fails to startup. As mentioned above, it is erroring with: KeyError: 'activeExtruder'

    Looking at the WebSocket responses, activeExtruder is (now) only returned if a printer is powered on. The HA integration is explicitly looking for that key so fails on startup if it is not present (for any installed printer). I tried powering on all of my printers, restarted Home Assistant and with all the printers on, the Home Assistant integration starts without issue. I have posted my findings on the HA Github, but there has obviously been a change in RS 1.2.1 which no longer exposes the activeExtruder key if a printer is off.

  • Update to the above. Although my actions allowed the HA integration to start, it is still borked. Sensors are not updating. This has to be down to a change (intentional or otherwise) in the latest RS version. The integration was working perfectly well before updating to 1.2.1
  • The problem is that we now send a state also for disconnected printers as we had added 2 variables that are needed in that case. But not connected the other variables make no sense and are not send. So there needs one line be changed in clsprinter.py to test if this is the case. We are checking a way to commit that change to HA.
  • Repetier said:
    The problem is that we now send a state also for disconnected printers as we had added 2 variables that are needed in that case. But not connected the other variables make no sense and are not send. So there needs one line be changed in clsprinter.py to test if this is the case. We are checking a way to commit that change to HA.
    Thank you!
    I would be happy to test on my HA installation if it would assist.
  • edited December 2021
    As an aside question - with the changes to the API in 1.2.1 to include the offline printers - would it be feasible to have the offline ones not returned in a different endpoint/param to exclude?

    Having said that, the Try/Catch to obtain the Raw Data based on the Slug (data = rawdata[self._slug]) in clsprinter.py should not actually be fetching the other printers data anyway..

    Anyway, I am happy to test as needed as well. Thanks again for the awesome support!


  • I just created a pull request on HA github page with a fix, so its pretty likely that in the next homeassistant update the issue will be gone
  • Thank you!
Sign In or Register to comment.