@@ -485,6 +485,40 @@ def test_validate_config(my_predbat):
485485 _run (my_predbat , {"car_charging_battery_size" : [77.4 , 64.0 ], "num_cars" : 2 }, expect_clean = ["car_charging_battery_size" ])
486486 _run (my_predbat , {"car_charging_battery_size" : 77.4 , "num_cars" : 2 }, expect_errors = ["car_charging_battery_size" ])
487487
488+ # A pointer to one entity repeated to the maximum car count (8). The validator trims a list to
489+ # num_cars, so one 8-entry list passes for every num_cars up to 8, whereas a single entity name
490+ # is rejected as the wrong type as soon as num_cars exceeds 1.
491+ pointer = ["sensor.test_car_profile_battery_size" ] * 8
492+ for cars in (0 , 1 , 2 , 8 ):
493+ print (" [sensor float] 8-entry car_charging_battery_size pointer passes with num_cars={}" .format (cars ))
494+ _run (
495+ my_predbat ,
496+ {"car_charging_battery_size" : pointer , "num_cars" : cars },
497+ extra_states = {"sensor.test_car_profile_battery_size" : "10.5" },
498+ expect_clean = ["car_charging_battery_size" ],
499+ )
500+
501+ print (" [sensor float] a single entity pointer fails once num_cars exceeds 1" )
502+ _run (
503+ my_predbat ,
504+ {"car_charging_battery_size" : "sensor.test_car_profile_battery_size" , "num_cars" : 2 },
505+ extra_states = {"sensor.test_car_profile_battery_size" : "10.5" },
506+ expect_errors = ["car_charging_battery_size" ],
507+ )
508+
509+ print (" [sensor float] every slot of the pointer resolves the entity as a float" )
510+ saved_args = my_predbat .args .copy ()
511+ saved_states = my_predbat .ha_interface .dummy_items .copy ()
512+ try :
513+ my_predbat .args ["car_charging_battery_size" ] = pointer
514+ my_predbat .ha_interface .dummy_items ["sensor.test_car_profile_battery_size" ] = "10.5"
515+ for slot in (0 , 1 , 7 ):
516+ value = my_predbat .get_arg ("car_charging_battery_size" , 100.0 , index = slot )
517+ assert value == 10.5 , "slot {} resolved {!r}, expected 10.5" .format (slot , value )
518+ finally :
519+ my_predbat .args = saved_args
520+ my_predbat .ha_interface .dummy_items = saved_states
521+
488522 print ("**** test_validate_config PASSED ****" )
489523 return False
490524
0 commit comments