@@ -62,22 +62,26 @@ async def async_update_crownstone_data(self) -> None:
6262 for crownstone_id in removed_items :
6363 del self .crownstones [crownstone_id ]
6464
65- def find (self , crownstone_name : str ) -> object or None :
65+ def find (self , crownstone_name : str ) -> "Crownstone" or None :
6666 """Search for a crownstone by name and return crownstone object if found."""
6767 for crownstone in self .crownstones .values ():
6868 if crownstone_name == crownstone .name :
6969 return crownstone
70+
71+ return None
7072
71- def find_by_id (self , crownstone_id ) -> object or None :
73+ def find_by_id (self , crownstone_id ) -> "Crownstone" or None :
7274 """Search for a crownstone by id and return crownstone object if found."""
73- return self .crownstones [ crownstone_id ]
75+ return self .crownstones . get ( crownstone_id )
7476
75- def find_by_uid (self , crownstone_uid ) -> object or None :
77+ def find_by_uid (self , crownstone_uid ) -> "Crownstone" or None :
7678 """Search for a crownstone by uid and return crownstone object if found."""
7779 for crownstone in self .crownstones .values ():
7880 if crownstone_uid == crownstone .unique_id :
7981 return crownstone
8082
83+ return None
84+
8185
8286class CrownstoneAbility :
8387 """Represents a Crownstone Ability"""
@@ -112,10 +116,9 @@ def __init__(self, cloud, data: Dict[str, Any]) -> None:
112116 self .cloud = cloud
113117 self .data : Dict [str , Any ] = data
114118 self .abilities : Dict [str , CrownstoneAbility ] = {}
115- # power usage (W )
119+ # Not cloud data, store your own data here (from Crownstone USB )
116120 self .power_usage = 0
117- # energy usage (Joule)
118- self .energy_usage = None
121+ self .energy_usage = 0
119122
120123 @property
121124 def name (self ) -> str :
0 commit comments