Flow of the backend of homeassistant

I downloaded home assistant source code of backend from github.

I added some prints and logs in main , bootstrap and core in order to debug the code.

All the prints added in main are visible on console when I run the following command:
python3 main --open-ui

But I am unable to receive the prints added in the other files. Also I even removed core.py but still the home assistant web ui gets opened.

Can you please tell me why I cannot add print statements in these files…From where it is executing core.py if I removed it from the source code folder…How can I debug and understand the flow of this source code?

You could use a tool to create a call graph or check the imports to see where a given part is used like core.

can you suggest a tool for this ? @fabaff

@fabaff

Can you let us know, in which directory, the logs received after running python3 main.py --open-ui are getting saved?

This can help us to add and view some logs in core.py and debug them.

No, but there are pycallgraph and pyan perhaps one of those can help even if they are not able to catch all the dynamic stuff.

Configuration folder

@fabaff

Intsalled pycallgraph and tried executing a script using this module. Getting this error:

Traceback (most recent call last):
  File "/home/ayushi/.local/bin/pycallgraph", line 25, in <module>
    with __pycallgraph.PyCallGraph(config=__config):
  File "/home/ayushi/.local/lib/python3.5/site-packages/pycallgraph/pycallgraph.py", line 32, in __init__
    self.reset()
  File "/home/ayushi/.local/lib/python3.5/site-packages/pycallgraph/pycallgraph.py", line 53, in reset
    self.prepare_output(output)
  File "/home/ayushi/.local/lib/python3.5/site-packages/pycallgraph/pycallgraph.py", line 97, in prepare_output
    output.sanity_check()
  File "/home/ayushi/.local/lib/python3.5/site-packages/pycallgraph/output/graphviz.py", line 63, in sanity_check
    self.ensure_binary(self.tool)
  File "/home/ayushi/.local/lib/python3.5/site-packages/pycallgraph/output/output.py", line 97, in ensure_binary
    'The command "{}" is required to be in your path.'.format(cmd))
pycallgraph.exceptions.PyCallGraphException: The command "dot" is required to be in your path.

Can you please let me know which all files and directories are included in the REST API(services) creation of backend code of home assistant.

Also, how can I create some more new APIs and call services with those APIs?

One of the first hits with a search engine: pycallgraph.exceptions.PyCallGraphException · Issue #177 · gak/pycallgraph · GitHub

There are some API endpoints api.py which are for Home Assistant itself and some are created by integrations. Search inside the source code for /api/.

API endpoints are inheriting from HomeAssistantView which is part of the http component. just create a new custom_component to handle a new API call.