@@ -98,7 +98,7 @@ class HTU31D:
98
98
99
99
def __init__ (self , i2c_bus : I2C , address : int = _HTU31D_DEFAULT_ADDR ) -> None :
100
100
if address not in _HTU31D_ADDRESSES :
101
- raise ValueError ("Invalid address: {address:#x}" )
101
+ raise ValueError (f "Invalid address: { address :#x} " )
102
102
self .i2c_device = i2c_device .I2CDevice (i2c_bus , address )
103
103
self ._conversion_command = _HTU31D_CONVERSION
104
104
self ._buffer = bytearray (6 )
@@ -111,7 +111,7 @@ def serial_number(self) -> int:
111
111
with self .i2c_device as i2c :
112
112
i2c .write_then_readinto (self ._buffer , self ._buffer , out_end = 1 , in_end = 4 )
113
113
ser = struct .unpack (">I" , self ._buffer [0 :4 ])
114
- return ser
114
+ return ser [ 0 ]
115
115
116
116
def reset (self ) -> None :
117
117
"""Perform a soft reset of the sensor, resetting all settings to their power-on defaults"""
@@ -128,8 +128,8 @@ def heater(self) -> bool:
128
128
129
129
@heater .setter
130
130
def heater (self , new_mode : bool ) -> None :
131
- # check its a boolean
132
- if not new_mode in ( True , False ):
131
+ # check it is a boolean
132
+ if not isinstance ( new_mode , bool ):
133
133
raise AttributeError ("Heater mode must be boolean" )
134
134
# cache the mode
135
135
self ._heater = new_mode
0 commit comments