Cannot read /usr/src/ content

Tried file editor, smb and SSH through “Terminal & SSH add-on”, but when I open /usr/src/ none of them reads anything inside. It also seems I cannot SSH into home assistant from an external terminal, like my ubuntu laptop, so I just tried the add-on.
I’d need it to be able to read “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 931, to see if I find something worth to know about what’s generating this:

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_update_ha_state
    raise RuntimeError(f"Attribute hass is None for {self}")
RuntimeError: Attribute hass is None for <entity unknown.unknown=unknown>

I don’t really know if this will actually help me someway, but I already asked for help about this error and got no answer.
Now I’m trying to catch as much informations as I can to try to understand the problem and eventually (ask someone to help me) solve it lately, but I’m stuck even before beginning.
Thanks to anyone for any help.

What type of Home Assistant Install did you use.
The method on how to ssh in changes depending on the way you are running HA.
Link to Version info – My Home Assistant.

AND thin just popped up today…
SSH Development Access (Core SSH, Root CLI).

1 Like

@Innominatapersona - There are a couple separate issues to your post, I’ll divide them to simplify and assure a more likel solution:

  1. Using the “Terminal & SSH add-on”, you’re unable to access
    /usr/src/homeassistant/homeassistant/helpers/entity.py

  2. You cannot connect by SSH to your HA OS using the “Terminal & SSH add-on”.

The easier of the two is to start with #2 – can you paste your YAML configuration (include but obfuscate anything private).

On #1, let’s try something to help locate the issue. From the web-based CLI that you do have access to, try entering the following command:
find / -type f -path '*/helpers/entity.py'

Let’s see if you get any output and if you do, where it’s located.

Sidenote - Thank you to @Sir_Goodenough for linking my new post on using SSH for development. In this instance, I don’t think I covered your issues and that probably won’t be of help to you; however, I hope that the two questions I’ve asked here will help us resolve this quite easily.

2 Likes

Thank you very much for your answers.
There are three separate issues including the main error.
My log is a mess. Sorry.
However,
I have HAOS supervised on a RPI5 with M2 memory boot.
Now on:

  • Core 2024.6.4
  • Frontend 20240610.1

My config.yaml:

#Home assistant integrations:
#default_config:
assist_pipeline:
automation: !include automations.yaml
bluetooth:
camera:
  - platform: xiaomi_cloud_map_extractor
    host: 192.168.1.***
    token: *************************
    username: ************@*******.com
    password: **********
    draw: ['all']
    store_map_raw: true
    attributes:
      - calibration_points
    scan_interval: 30
    auto_update: false
#cloud:
command_line:
  - sensor:
      name: "CPU Temperature"
      command: "cat /sys/class/thermal/thermal_zone0/temp"
      unit_of_measurement: "°C"
      value_template: '{{ value | multiply(0.001) | round(1) }}'
config:
conversation:
counter:
#device_tracker:
dhcp:
energy:
ffmpeg:
frontend:
  themes: !include_dir_merge_named themes
hardware:
history:
homeassistant:
  packages: !include_dir_named packages
homeassistant_alerts:
http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
  ip_ban_enabled: false
image_upload:
input_button:
input_boolean:
input_datetime:
input_number:
input_select:
input_text:
logger:
logbook:
#map:
media_source:
mobile_app:
network:
person:
python_script:
scene: !include scenes.yaml
schedule:
script: !include scripts.yaml
sensor:
  - platform: time_date
    display_options: 
     - 'date_time_iso'
     - 'date'
  - platform: template
    sensors:
      time_formatted_lovelace:
        friendly_name: Ora e Giorno
        value_template: >
          {% set days = ['Lun.', 'Mar.', 'Mer.', 'Gio.', 'Ven.', 'Sab.', 'Dom.'] %}
          {{ now().timestamp() | timestamp_custom('%H:%M') }} {{' - '}} {{ days[now().weekday()] }} {{' '}} {{ now().timestamp() | timestamp_custom('%d-%m-%Y') }}
        icon_template: mdi:calendar-clock
      time_formatted_voice:
        friendly_name: Ora e Giorno (Voce)
        value_template: >
          {% set days = ['Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica'] %}
          {{ now().timestamp() | timestamp_custom('%H:%M') }} {{' di '}} {{ days[now().weekday()] }} {{' ; '}} {{ now().timestamp() | timestamp_custom('%d ;  %m ;  %Y') }}
        icon_template: mdi:calendar-clock
ssdp:
stream:
sun:
system_health:
switch:
  - platform: wake_on_lan
    mac: **************** 
    host: 192.168.1.***
    name: TV on
timer:
usb:
wake_on_lan:
#webhook:
zeroconf:
zone:

#Third parties:
daikin_residential:
  email: ***********@***********.com
  password: ********************
shell_command:
 shutdown_tnas: ssh -i /config/.ssh/******* -o 'StrictHostKeyChecking=no' -p 9222 *********@192.168.1.*** /sbin/shutdown

Typing

on the add-on CLI returns no output.

I started reading ssh dev page, I guess it’ll take some time to try one of the methods described, but I’ll do it as soon as I can. Meanwhile I understood why I could not SSH into HA from an external terminal. Thanks for that too.
I’ve seen that daikin residential is not supported anymore. I tried switching to onecta, but for some unspecified reason, I cannot login to the dev site, so for now I’m stuck with it.
I’d say that I need some time to study SSH further and make attempts.

Thank you again for help.

Hi,
thanks again for support.
Thanks to

I guess I correctly managed to access Home Assistant OS through SSH as Ubuntu terminal shows:

Welcome to Home Assistant OS.

Use `ha` to access the Home Assistant CLI.

So I guess the title question is solved. Just don’t know who to assign solution to since @Sir_Goodenough posted @mediamanny’s topic (of course you got a heart on that).

Since I’m still quite stuck trying to understand how to read

/usr/src/homeassistant/homeassistant/helpers/entity.py

from CLI, I could use this as an excuse.

It doesn’t look like the SSH interface I’ve seen before. So I dug a little to see if I could understand something more.
I was wondering if I could use

ha jobs reset

to eventually rebuild jobs index and maybe simply forget this “unknown” entity, but I’m afraid it will delete every other entity too and don’t want to mess up the whole system for an asymptomatic issue, so I’d rather know what to do before doing it.
Would you please help me again?
Thank you very much

Pick either one, the important thing is it gets a solution tag.

Sincerely sorry, I must have misled you with my previous statement. It was a kind of an exhortation joke. I didn’t mean to offend.
The fact is that I still cannot read /urs/src/content, I just gained the ability to SSHish into HA OS.
I posted I could avoid reading it, if the command “ha jobs reset” would rebuild the index of jobs, maybe solve the problem without any further effort and, most important, without bricking anything.
But that’s only my guess and I’d need to be sure of it, otherwise I’d still need to read that file and at the moment I still cannot.
Thanks

No offense taken.
My delivery is a bit abrupt I see.

1 Like

@Innominatapersona - I’m sorry, I would help further if I understood your specific issue; however, there have been a number of different things mentioned and I’m confused as to the question. I’m sure this is my misunderstanding; however, there isn’t much more I can do at this point.

I can do my best to try and address some of the direct statements you’ve made, in the event that helps:

  1. Using the ha jobs reset does not work in the manner you’re suggesting. It should instruct HA to re-enable the protection mechanism to check the system integrity. I don’t think it will rebuilt the jobs index. However, if you feel it’s something you’d like to experiment with, it shouldn’t have any issue re: deleting entities.

  2. I am not sure what it means for the SSH interface to look different as you mentioned and I’m not sure where to start with that.
    However – it might be easier for you to connect an SCP/SFTP client, download the file onto your local machine, and review it there – this will resolve any issues with strange behavior you’ve experienced.
    Just one important note: If you’re in the docker container, remember that you’d have to save changes to the image or the next reboot all changes to the image (not the data, but the image, for example, the .py files) will be restored to the original image’s state.

Wish you the best.

2 Likes

Thanks again,
sorry if I gave you partial informations and for annoying with questions you may find stupid.
My instance info:

  • Core 2024.6.4
  • Supervisor 2024.06.2
  • Operating System12.3
  • Frontend 20240610.1

When I say SSH is different from what I’ve always seen I mean this:


From here I can just run various ha commands and options, like the before mentioned “jobs reset”, but I cannot ‘cd’ anywhere or ‘ls’ anything.
I’m surely mistaking something, but reading around I couldn’t find any instruction or guide about this matter in particular and since sadly I’m not a programmer or a developer, the few things I found are quite incomprehensible to me.
I’ll see if I can at least understand (what it means and then) how to connect an SCP/SFTP client.
Thanks

To clarify, I’m not bothered by anything you’ve said and I don’t find it wrong. I explained I simply do not understand it and cannot answer if I don’t understand. That could be my fault.

The screenshot you provided is very helpful. Also, if it it saves you any time, you don’t need to hide a private IP address, it’s of no value and doesn’t pose any privacy/security risk.

Based on your screenshot/explanation, I understand that you are able to SSH to the 22222 port and gain root-level access. However, many linux commands are not available to you.

The linux commands are working, you just don’t have many of the utilities and there is nothing in your user directory, so it can be confusing.

Try this (go to the root directory, then list all root files, in long format):

cd /
ls -a -l

You will see your typical root directories.

Now remember that HA is running inside a docker container, so you’ll need to use docker to connect to the operating system (it’s not the root operating system you’re in initially).

Therefore, the next thing you will do is to get a list of running docker containers, like this:

docker container ls

It’s easier to understand the output if you drag your screen to be very wide so that you’re not seeing wrapped-lines.

One of the docker containers that’s running is hassio_supervisor.

To get a shell there, you simply run the shell executable, inside that container. The resulting terminal session you’re in, will be the shell running inside that hassio_supervisor container.

To do this, you’ll run docker, telling it to run “bash” in the “hassio_supervisor” container:

docker exec -it hassio_supervisor bash

However, one important thing to understand is that you’re now inside the HA container, which is similar to what you would be able to do with an HA SSH terminal plugin.

When you are done with that terminal session in HA, you can exit with that command, and you’ll be back to the root.

Also, about the SCP/SFTP client–
The good news is that you can connect exactly the same way you do by SSH. In other words, use the same approach to connect using a client, such like WinSCP. If you’re using Ubuntu on your client, use the built-in Nautilus file browser and you can connect that way.

One important note…
Once you’re at this stage or considering modifying something in the docker image, there is much more you’ll have to understand and I highly recommend that you do not move forward until you are more comfortable with the docker architecture, etc.

It would be good to setup a test system with HA, that you plan on destroying and it cannot cause you any problems, then try these techniques to learn. For example, once you make changes to the docker container, you would need to save that docker image. However, this opens another “can of worms” as they say.

I hope this helps.

1 Like

This helps a lot, thank you very much for your patience.
I know my comprehension is way not enough and that I don’t have to touch absolutely anything, I just wanted to see if I could collect some information about the unknown entity generating an error every 5 minutes in my system log.
Since I couldn’t find any informatrion about it, I thought I could try to read “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 931, which is where log tells me there’s an issue, but as I mentioned, I don’t even know if this will help me somehow.
I had written another topic asking for help on that error and got no answer in more than a month, so this is the smartest next step that came to my ingnorant mind.
I thought my topic would have been more likely to be answered if I gave more informations about the error.
Probably this is wrong too, but had no clue.
I’ll try everything you suggested, so I’ll be busy for a while.
Thank you very much, your help has been enormously appreciated.

First attempt
Schermata del 2024-07-02 23-26-48
:crazy_face:

However, even though not sorted, I can
cd . and cd … , but none of theese two brings me to the file I need.
I’ll keep trying

I’m sorry, I made a stupid Windows-user mistake and used a backslash when typing that. You’ll use a forward-slash, being in linux :slight_smile:

cd /
ls -a -l

Remember – you won’t be able to see the file until you’re inside of the Docker container.

You’re in the root OS which only runs docker (HA is not installed there), until you continue with the instructions to:

docker container ls

Thanks, I was so tired I didn’t even try the way I’m used to…