@@ -40,57 +40,63 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_
4040 lp_has_phase_auto_option = load_point_config ["has_phase_auto_option" ]
4141 lp_is_heating = load_point_config ["is_heating" ]
4242 lp_is_integrated = load_point_config ["is_integrated" ]
43+ lp_is_switch_device = load_point_config ["is_switch_device" ]
44+ lp_is_always_charge_present = load_point_config ["is_always_charge_present" ]
45+ lp_is_single_phase_only = load_point_config ["only_single_phase" ]
4346
4447 for a_stub in NUMBER_ENTITIES_PER_LOADPOINT :
45- if not lp_is_integrated or a_stub .integrated_supported :
46- force_celsius = lp_is_heating and a_stub .tag == Tag .LIMITSOC
47- the_key = a_stub .tag .entity_key if a_stub .tag .entity_key is not None else a_stub .tag .json_key
48- description = ExtNumberEntityDescription (
49- tag = a_stub .tag ,
50- lp_idx = lp_api_index ,
51- key = f"{ lp_id_addon } _{ the_key } " ,
52- translation_key = the_key ,
53- name_addon = lp_name_addon if multi_loadpoint_config else None ,
54- icon = "mdi:thermometer" if force_celsius else a_stub .icon ,
55- device_class = SensorDeviceClass .TEMPERATURE if force_celsius else a_stub .device_class ,
56- unit_of_measurement = UnitOfTemperature .CELSIUS if force_celsius else a_stub .unit_of_measurement ,
57- entity_category = a_stub .entity_category ,
58- entity_registry_enabled_default = a_stub .entity_registry_enabled_default ,
59- is_lp_integrated_device = lp_is_integrated ,
60-
61- # the entity type specific values...
62- max_value = a_stub .max_value ,
63- min_value = a_stub .min_value ,
64- mode = a_stub .mode ,
65- native_max_value = a_stub .native_max_value ,
66- native_min_value = a_stub .native_min_value ,
67- native_step = 1 if force_celsius else a_stub .native_step ,
68- native_unit_of_measurement = UnitOfTemperature .CELSIUS if force_celsius else a_stub .native_unit_of_measurement ,
69- step = a_stub .step ,
70- )
71-
72- if a_stub .tag in [Tag .SMARTCOSTLIMIT , Tag .SMARTFEEDINPRIORITYLIMIT , Tag .BATTERYGRIDCHARGELIMIT ]:
73- if coordinator ._cost_type == "co2" :
74- description = replace (
75- description ,
76- translation_key = f"{ a_stub .tag .json_key } _co2" ,
77- icon = "mdi:molecule-co2" ,
78- native_max_value = 500 ,
79- native_min_value = 0 ,
80- native_step = 5 ,
81- native_unit_of_measurement = "g/kWh"
82- )
83-
84- # for SEK, NOK, DKK we need to patch the maxvalue (1€ ~ 10 Krone)
85- elif coordinator ._currency != "€" :
86- description = replace (
87- description ,
88- native_max_value = a_stub .native_max_value * 10 ,
89- native_min_value = a_stub .native_min_value * 10
90- )
91-
92- entity = EvccNumber (coordinator , description )
93- entities .append (entity )
48+ # get rid of all stub's that are not supported by integrated devices
49+ if lp_is_integrated and not a_stub .integrated_supported :
50+ continue
51+
52+ force_celsius = lp_is_heating and a_stub .tag == Tag .LIMITSOC
53+ the_key = a_stub .tag .entity_key if a_stub .tag .entity_key is not None else a_stub .tag .json_key
54+ description = ExtNumberEntityDescription (
55+ tag = a_stub .tag ,
56+ lp_idx = lp_api_index ,
57+ key = f"{ lp_id_addon } _{ the_key } " ,
58+ translation_key = the_key ,
59+ name_addon = lp_name_addon if multi_loadpoint_config else None ,
60+ icon = "mdi:thermometer" if force_celsius else a_stub .icon ,
61+ device_class = SensorDeviceClass .TEMPERATURE if force_celsius else a_stub .device_class ,
62+ unit_of_measurement = UnitOfTemperature .CELSIUS if force_celsius else a_stub .unit_of_measurement ,
63+ entity_category = a_stub .entity_category ,
64+ entity_registry_enabled_default = a_stub .entity_registry_enabled_default ,
65+ is_lp_integrated_device = lp_is_integrated ,
66+
67+ # the entity type specific values...
68+ max_value = a_stub .max_value ,
69+ min_value = a_stub .min_value ,
70+ mode = a_stub .mode ,
71+ native_max_value = a_stub .native_max_value ,
72+ native_min_value = a_stub .native_min_value ,
73+ native_step = 1 if force_celsius else a_stub .native_step ,
74+ native_unit_of_measurement = UnitOfTemperature .CELSIUS if force_celsius else a_stub .native_unit_of_measurement ,
75+ step = a_stub .step ,
76+ )
77+
78+ if a_stub .tag in [Tag .SMARTCOSTLIMIT , Tag .SMARTFEEDINPRIORITYLIMIT , Tag .BATTERYGRIDCHARGELIMIT ]:
79+ if coordinator ._cost_type == "co2" :
80+ description = replace (
81+ description ,
82+ translation_key = f"{ a_stub .tag .json_key } _co2" ,
83+ icon = "mdi:molecule-co2" ,
84+ native_max_value = 500 ,
85+ native_min_value = 0 ,
86+ native_step = 5 ,
87+ native_unit_of_measurement = "g/kWh"
88+ )
89+
90+ # for SEK, NOK, DKK we need to patch the maxvalue (1€ ~ 10 Krone)
91+ elif coordinator ._currency != "€" :
92+ description = replace (
93+ description ,
94+ native_max_value = a_stub .native_max_value * 10 ,
95+ native_min_value = a_stub .native_min_value * 10
96+ )
97+
98+ entity = EvccNumber (coordinator , description )
99+ entities .append (entity )
94100
95101 add_entity_cb (entities )
96102
0 commit comments