You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-7Lines changed: 29 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,30 +171,52 @@ You may use VSCode either:
171
171
- Simpler setup because no file transfer is necessary
172
172
- I would still recommended to use `git` to save versions of your code (learn it by using a graphical git client such as VSCode + Git Graph extension), but you could also choose to rely only on Home Assistant backups.
173
173
174
+
#### Install Python extension
175
+
176
+
Open your editor (e.g. VSCode), and browse to your AppDaemon apps folder (e.g. if using the VSCode addon, `File > Open folder > /addon_configs/a0d7b954_appdaemon`).
177
+
178
+
- If you are using the VSCode addon of Home Assistant (or any other non-packed-by-microsoft flavor), install the [BasedPyright](https://open-vsx.org/extension/detachhead/basedpyright) extension.
179
+
- If you are using the Microsoft-packed VSCode, you may install the [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) extension (which contains Pylance, which uses Pyright).
180
+
174
181
#### Python configuration & venv
175
182
176
-
Install python, [create a virtual environment and install appdaemon in there](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/), then [select the venv in `VSCode`](https://code.visualstudio.com/docs/python/environments).
183
+
We need to make appdaemon accessible to the type checker.
184
+
185
+
1. Create a virtual environment in your VSCode workspace:
186
+
- Press Ctrl+Shift+P (or Cmd+Shift+P on mac) to open the command palette (Ctrl+P then type `>` if that doesn't work)
187
+
- Type `> Python: Select Interpreter`
188
+
- Click "Create virtual environment"
189
+
- Once that [complates](https://code.visualstudio.com/docs/python/environments#_using-the-create-environment-command), at the bottom right of the editor, if you have any `.py` file open, it should show `3.11.2 ('.venv': venv)`
190
+
2. Install appdaemon in the virtual env:
191
+
- Press Ctrl+Shift+C to open a terminal
192
+
- It should show `.venv` at the beginning of the prompt, to signify that it is running within the context of the virtual env.
193
+
- Type `pip install --upgrade appdaemon` in the VSCode terminal. It should complete without any error after some time.
177
194
178
195
#### Typer configuration
179
196
180
197
To have the typer catch as many mistakes as possible right from your editor, you should configure [`pyright`](https://github.com/microsoft/pyright) (default typer of VsCode) with appropriate typing constraints in the project where you develop your own automations (with `hapt.py` copied there).
181
198
182
199
Suggested parameters are available in this repository's `pyrightconfig.json`.
183
200
184
-
It is recommended to copy the same parameters over to the folder that you open in VSCode when working on your AppDaemon Apps.
201
+
It is recommended to copy the same parameters over to the folder that you open in VSCode when working on your AppDaemon Apps:
You probably also want to enable checking all files and not only those you currently have open:
206
+
You probably also want to enable checking all files and not only those you currently have open, by adding to the `.vscode/settings.json` file (may need to be created):
187
207
188
-
With Pylance (official VSCode on local machine):
208
+
With BasedPyright (if running e.g. the VSCode home assistant addon):
0 commit comments