11"""The Detailed Hello World Push integration."""
2+
23import asyncio
3- from homeassistant .components .alarm_control_panel import DOMAIN as PLATFORM_ALARM_CONTROL_PANEL
4+ from homeassistant .components .alarm_control_panel import (
5+ DOMAIN as PLATFORM_ALARM_CONTROL_PANEL ,
6+ )
47from homeassistant .components .binary_sensor import DOMAIN as PLATFORM_BINARY_SENSOR
58from homeassistant .components .sensor import DOMAIN as PLATFORM_SENSOR
69from homeassistant .components .button import DOMAIN as PLATFORM_BUTTON
710from homeassistant .config_entries import ConfigEntry
811from homeassistant .core import HomeAssistant
912from homeassistant .helpers import device_registry as dr , config_validation as cv
10- #from . import hub
11- from .const import (DOMAIN ,DATA_JABLOTRON , DATA_OPTIONS_UPDATE_UNSUBSCRIBER , NAME ,CABLE_MODEL ,MANUFACTURER ,CABLE_MODELS )
13+
14+ # from . import hub
15+ from .const import (
16+ DOMAIN ,
17+ DATA_JABLOTRON ,
18+ DATA_OPTIONS_UPDATE_UNSUBSCRIBER ,
19+ NAME ,
20+ CABLE_MODEL ,
21+ MANUFACTURER ,
22+ CABLE_MODELS ,
23+ )
1224from .jablotron import JA80CentralUnit
25+
1326# List of platforms to support. There should be a matching .py file for each,
1427# eg <cover.py> and <sensor.py>
15- PLATFORMS = [PLATFORM_ALARM_CONTROL_PANEL ,PLATFORM_BINARY_SENSOR ,PLATFORM_SENSOR , PLATFORM_BUTTON ]
28+ PLATFORMS = [
29+ PLATFORM_ALARM_CONTROL_PANEL ,
30+ PLATFORM_BINARY_SENSOR ,
31+ PLATFORM_SENSOR ,
32+ PLATFORM_BUTTON ,
33+ ]
1634CONFIG_SCHEMA = cv .config_entry_only_config_schema (DOMAIN )
1735
36+
1837async def async_setup (hass : HomeAssistant , config : dict ):
1938 # Ensure our name space for storing objects is a known type. A dict is
2039 # common/preferred as it allows a separate instance of your class for each
@@ -27,42 +46,48 @@ async def async_setup(hass: HomeAssistant, config: dict):
2746async def async_setup_entry (hass : HomeAssistant , entry : ConfigEntry ) -> bool :
2847 # Store an instance of the "connecting" class that does the work of speaking
2948 # with your actual devices.
30- # hass.data[DOMAIN][entry.entry_id] = hub.Hub(hass, entry.data["host"])
49+ # hass.data[DOMAIN][entry.entry_id] = hub.Hub(hass, entry.data["host"])
3150
3251 # This creates each HA object for each platform your device requires.
3352 # It's done by calling the `async_setup_entry` function in each platform module.
34-
35- cu = JA80CentralUnit (hass , entry .data , entry .options )
53+
54+ cu = JA80CentralUnit (hass , entry .data , entry .options )
3655 await cu .initialize ()
37-
56+
3857 device_registry = dr .async_get (hass )
3958 device_registry .async_get_or_create (
40- config_entry_id = entry .entry_id ,
41- identifiers = {(DOMAIN , cu .serial_port )},
42- name = "Cable" ,
59+ config_entry_id = entry .entry_id ,
60+ identifiers = {(DOMAIN , cu .serial_port )},
61+ name = "Cable" ,
4362 model = CABLE_MODELS [entry .data [CABLE_MODEL ]],
44- manufacturer = MANUFACTURER
45- )
46-
63+ manufacturer = MANUFACTURER ,
64+ )
65+
4766 hass .data [DOMAIN ][entry .entry_id ] = {
48- DATA_JABLOTRON : cu ,
49- DATA_OPTIONS_UPDATE_UNSUBSCRIBER : entry .add_update_listener (options_update_listener ),
50- }
67+ DATA_JABLOTRON : cu ,
68+ DATA_OPTIONS_UPDATE_UNSUBSCRIBER : entry .add_update_listener (
69+ options_update_listener
70+ ),
71+ }
5172
5273 await hass .config_entries .async_forward_entry_setups (entry , PLATFORMS )
5374 return True
5475
76+
5577async def async_unload_entry (hass : HomeAssistant , entry : ConfigEntry ):
5678 # This is called when an entry/configured device is to be removed. The class
5779 # needs to unload itself, and remove callbacks. See the classes for further
5880 # details
59- options_update_unsubscriber = hass .data [DOMAIN ][entry .entry_id ][DATA_OPTIONS_UPDATE_UNSUBSCRIBER ]
81+ options_update_unsubscriber = hass .data [DOMAIN ][entry .entry_id ][
82+ DATA_OPTIONS_UPDATE_UNSUBSCRIBER
83+ ]
6084 options_update_unsubscriber ()
6185 cu = hass .data [DOMAIN ][entry .entry_id ][DATA_JABLOTRON ]
6286 cu .shutdown ()
6387 hass .data [DOMAIN ].pop (entry .entry_id )
6488 return True
6589
90+
6691async def options_update_listener (hass : HomeAssistant , entry : ConfigEntry ) -> None :
67- cu = hass .data [DOMAIN ][entry .entry_id ][DATA_JABLOTRON ]
68- cu .update_options (entry .options )
92+ cu = hass .data [DOMAIN ][entry .entry_id ][DATA_JABLOTRON ]
93+ cu .update_options (entry .options )
0 commit comments