Created
June 16, 2020 12:59
-
-
Save KoljaWindeler/d0d9ded40405ebbca5ce0d2f69f61b70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime, time | |
def wait_available(self, entity, is_domain): | |
count = 0 | |
dev = [] | |
if(isinstance(entity, str)): | |
dev.append(entity) | |
else: | |
dev = entity | |
while(count < 300): | |
ret = True | |
for i in dev: | |
if(is_domain): | |
#self.log(self.get_state(i)) | |
if(not(self.get_state(i) == None)): | |
break | |
else: | |
if(not(self.entity_exists(i))): | |
self.log("dev "+str(i)+" not ready") | |
ret = False | |
self.terminate() | |
break | |
if(ret): | |
self.log("All devices online after "+str(count)+" sec") | |
return True | |
else: | |
count += 1 | |
time.sleep(1) | |
self.log("entities never came online ") | |
self.log(dev) | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment