@@ -240,13 +240,13 @@ class Switch(BaseModel):
240240 display : Optional [SwitchDisplayType ] = None
241241
242242 def _uses_single_gpio (self : "Switch" ) -> bool :
243- return bool (self .gpio or self . pin )
243+ return bool (self .pin )
244244
245245 def _uses_two_gpios (self : "Switch" ) -> bool :
246- return bool (self .gpio_high or self . pin_high or self . gpio_low or self .pin_low )
246+ return bool (self .pin_high or self .pin_low )
247247
248248 def _uses_gpio (self : "Switch" ) -> bool :
249- return self ._uses_single_gpio () or self ._uses_two_gpios ( )
249+ return bool ( self .gpio_high or self .gpio_low or self . gpio )
250250
251251 @model_validator (mode = "after" )
252252 def check_hardware (self : "Switch" ) -> "Switch" :
@@ -264,11 +264,6 @@ def check_hardware(self: "Switch") -> "Switch":
264264 )
265265
266266 if self ._uses_single_gpio ():
267- if not self .gpio or not self .pin :
268- raise PydanticCustomError (
269- "SwitchHardwareError" ,
270- "Switch missing either 'gpio' or 'pin'" ,
271- )
272267 if str (self .type ) not in ["2POS" , "FSWITCH" ]:
273268 raise PydanticCustomError (
274269 "SwitchHardwareError" ,
@@ -277,15 +272,10 @@ def check_hardware(self: "Switch") -> "Switch":
277272 # TODO: check 'default' as well?
278273
279274 if self ._uses_two_gpios ():
280- if (
281- not self .gpio_high
282- or not self .pin_high
283- or not self .gpio_low
284- or not self .pin_low
285- ):
275+ if not self .pin_high or not self .pin_low :
286276 raise PydanticCustomError (
287277 "SwitchHardwareError" ,
288- "Switch missing 'gpio_high' or ' pin_high' or 'gpio_low ' or 'pin_low'" ,
278+ "Switch missing 'pin_high' or 'pin_low'" ,
289279 )
290280 if str (self .type ) != "3POS" :
291281 raise PydanticCustomError (
0 commit comments