@@ -62,7 +62,7 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
6262 hass .data [DOMAIN ].start ()
6363
6464 discovery .load_platform (hass , Platform .SENSOR , DOMAIN , {}, config )
65- discovery .load_platform (hass , Platform .BINARY_SENSOR , DOMAIN , {}, config )
65+ # discovery.load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
6666 return True
6767
6868
@@ -76,41 +76,13 @@ class DeviceData(threading.Thread):
7676
7777 def __init__ (self , hass , client : device .Device ) -> None :
7878 super ().__init__ ()
79+ self .name = "Ph803wThread"
7980 self .hass = hass
8081 self .client = client
8182 self .unit = self .client .host
8283 self ._shutdown = False
8384 self ._fails = 0
8485
85- # def _reconnect(self):
86- # """Reconnect on a failure."""
87-
88- # self._fails += 1
89- # if self._fails > MAX_FAILS:
90- # _LOGGER.error("Failed to reconnect. Thread stopped")
91- # persistent_notification.create(
92- # self.hass,
93- # "Error:<br/>Connection to PH-803W device failed "
94- # "the maximum number of times. Thread has stopped",
95- # title=NOTIFICATION_TITLE,
96- # notification_id=NOTIFICATION_ID,
97- # )
98-
99- # self._shutdown = True
100- # return
101-
102- # # sleep first before the reconnect attempt
103- # _LOGGER.debug("Sleeping for fail # %s", self._fails)
104- # time.sleep(self._fails * ERROR_INTERVAL.total_seconds())
105-
106- # try:
107- # self.client.run(once=False)
108- # except:
109- # _LOGGER.exception("Failed to reconnect attempt %s", self._fails)
110- # else:
111- # _LOGGER.debug("Reconnected to device")
112- # self._fails = 0
113-
11486 def run (self ):
11587 """Thread run loop."""
11688
@@ -163,46 +135,3 @@ def shutdown(event):
163135 )
164136 self .client .reset_socket ()
165137 time .sleep (sleep_time )
166-
167- # while True:
168- # if self._shutdown:
169- # _LOGGER.debug("Graceful shutdown")
170- # return
171-
172- # try:
173- # self.data = self.client.run(once=False)
174-
175- # except WFException:
176- # # WFExceptions are things the WF library understands
177- # # that pretty much can all be solved by logging in and
178- # # back out again.
179- # _LOGGER.exception("Failed to read data, attempting to recover")
180- # self._reconnect()
181-
182- # else:
183- # dispatcher_send(self.hass, UPDATE_TOPIC)
184- # time.sleep(SCAN_INTERVAL.total_seconds())
185-
186-
187- # async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
188- # """Set up Hello World from a config entry."""
189- # # Store an instance of the "connecting" class that does the work of speaking
190- # # with your actual devices.
191- # hass.data.setdefault(DOMAIN, {})[entry.entry_id] = hub.Hub(hass, entry.data["host"])
192-
193- # # This creates each HA object for each platform your device requires.
194- # # It's done by calling the `async_setup_entry` function in each platform module.
195- # hass.config_entries.async_setup_platforms(entry, PLATFORMS)
196- # return True
197-
198-
199- # async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
200- # """Unload a config entry."""
201- # # This is called when an entry/configured device is to be removed. The class
202- # # needs to unload itself, and remove callbacks. See the classes for further
203- # # details
204- # unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
205- # if unload_ok:
206- # hass.data[DOMAIN].pop(entry.entry_id)
207-
208- # return unload_ok
0 commit comments