Code block improvements (#382)

* Use f-strings instead of .format()

* Code block language marker fixes

* Make example code blocks syntactically valid Python

* Run all python code blocks through black

https://github.com/scop/misc/blob/master/black_markdown.py

* Add some missing code block language markers

* Use shell language consistently to mark shell code blocks

* Undo folding of some example dicts

* Remove outdated OrderedDict comments per Python 3.7, replace with plain dict
This commit is contained in:
Ville Skyttä
2020-01-13 21:55:41 +02:00
committed by GitHub
parent 732ee0523b
commit 770185004b
48 changed files with 382 additions and 368 deletions

View File

@@ -4,7 +4,7 @@ title: "Creating your first integration"
Alright, you learned about the [manifest](creating_integration_manifest.md), so it's time to write your first code for your integration. AWESOME. Don't worry, we've tried hard to keep it as easy as possible. From a Home Assistant development environment, type the following and follow the instructions:
```python
```shell
python3 -m script.scaffold integration
```
@@ -15,10 +15,11 @@ This will set you up with everything that you need to build an integration that
The scaffold integration contains a bit more than just the bare minimum. The minimum is that you define a `DOMAIN` constant that contains the domain of the integration. The second part is that it needs to define a setup method that returns a boolean if the set up was successful.
```python
DOMAIN = 'hello_state'
DOMAIN = "hello_state"
def setup(hass, config):
hass.states.set('hello_state.world', 'Paulus')
hass.states.set("hello_state.world", "Paulus")
# Return boolean to indicate that initialization was successful.
return True
@@ -27,10 +28,11 @@ def setup(hass, config):
And if you prefer an async component:
```python
DOMAIN = 'hello_state'
DOMAIN = "hello_state"
async def async_setup(hass, config):
hass.states.async_set('hello_state.world', 'Paulus')
hass.states.async_set("hello_state.world", "Paulus")
# Return boolean to indicate that initialization was successful.
return True