@@ -96,8 +96,7 @@ async def async_send_command(call):
96
96
event_id = "_" .join (
97
97
[
98
98
call .data [CONF_PROTOCOL ],
99
- call .data .get (CONF_DEVICE_ID ) or call .data .get (
100
- CONF_DEVICE_ADDRESS ),
99
+ call .data .get (CONF_DEVICE_ID ) or call .data .get (CONF_DEVICE_ADDRESS ),
101
100
]
102
101
)
103
102
device = {
@@ -138,8 +137,7 @@ def event_callback(event):
138
137
if entity_id :
139
138
# Propagate event to every entity matching the device id
140
139
_LOGGER .debug ("passing event to %s" , entity_id )
141
- async_dispatcher_send (
142
- hass , SIGNAL_HANDLE_EVENT .format (entity_id ), event )
140
+ async_dispatcher_send (hass , SIGNAL_HANDLE_EVENT .format (entity_id ), event )
143
141
else :
144
142
# If device is not yet known, register with platform (if loaded)
145
143
if event_type in hass .data [DOMAIN ][DATA_DEVICE_REGISTER ]:
@@ -213,9 +211,7 @@ async def connect():
213
211
EVENT_KEY_COMMAND : defaultdict (list ),
214
212
EVENT_KEY_SENSOR : defaultdict (list ),
215
213
},
216
- DATA_DEVICE_REGISTER : {
217
- EVENT_KEY_COMMAND : {}
218
- },
214
+ DATA_DEVICE_REGISTER : {},
219
215
}
220
216
221
217
if options .get (CONF_AUTOMATIC_ADD , config [CONF_AUTOMATIC_ADD ]) is True :
@@ -294,8 +290,7 @@ def handle_event_callback(self, event):
294
290
if identify_event_type (event ) == EVENT_KEY_COMMAND :
295
291
self .hass .bus .async_fire (
296
292
EVENT_BUTTON_PRESSED ,
297
- {ATTR_ENTITY_ID : self .entity_id ,
298
- ATTR_STATE : event [EVENT_KEY_COMMAND ]},
293
+ {ATTR_ENTITY_ID : self .entity_id , ATTR_STATE : event [EVENT_KEY_COMMAND ]},
299
294
)
300
295
_LOGGER .debug (
301
296
"Fired bus event for %s: %s" , self .entity_id , event [EVENT_KEY_COMMAND ]
@@ -361,10 +356,9 @@ async def async_added_to_hass(self):
361
356
async def async_will_remove_from_hass (self ):
362
357
"""Clean when entity removed."""
363
358
await super ().async_will_remove_from_hass ()
364
- device_registry = dr .async_get (hass )
359
+ device_registry = dr .async_get (self . hass )
365
360
device = device_registry .async_get_device (
366
- (DOMAIN , self .hass .data [DOMAIN ]
367
- [CONF_DEVICE ] + "_" + self ._attr_unique_id )
361
+ (DOMAIN , self .hass .data [DOMAIN ][CONF_DEVICE ] + "_" + self ._attr_unique_id )
368
362
)
369
363
if device :
370
364
device_registry .async_remove_device (device )
0 commit comments