@@ -46,6 +46,21 @@ def get_solvis_modules(data: ConfigType) -> Schema:
46
46
)
47
47
48
48
49
+ def get_solvis_modules_options (data : ConfigType ) -> Schema :
50
+ return vol .Schema (
51
+ {
52
+ vol .Required (CONF_OPTION_1 , default = data .get (CONF_OPTION_1 )): bool , # HKR 2
53
+ vol .Required (CONF_OPTION_2 , default = data .get (CONF_OPTION_2 )): bool , # HKR 3
54
+ vol .Required (
55
+ CONF_OPTION_3 , default = data .get (CONF_OPTION_3 )
56
+ ): bool , # solar collectors
57
+ vol .Required (
58
+ CONF_OPTION_4 , default = data .get (CONF_OPTION_4 )
59
+ ): bool , # heat pump
60
+ }
61
+ )
62
+
63
+
49
64
def get_host_schema_options (data : ConfigType ) -> Schema :
50
65
return vol .Schema (
51
66
{
@@ -72,23 +87,23 @@ async def async_step_user(
72
87
errors = {}
73
88
if user_input is not None :
74
89
self .data = user_input
75
- try :
76
- self .client = ModbusClient .AsyncModbusTcpClient (
77
- user_input [CONF_HOST ], user_input [CONF_PORT ]
78
- )
79
- await self .client .connect ()
80
- # Perform a simple read to check the connection
81
- await self .client .read_input_registers ( 32770 , 1 , 1 )
82
- except (ConnectionException , ModbusException ) as exc :
83
- _LOGGER .error (f"Modbus connection failed: { exc } " )
84
- errors ["base" ] = "cannot_connect"
85
- else :
86
- await self .client .close ()
87
- await self .async_set_unique_id (
88
- self .data [CONF_HOST ], raise_on_progress = False
89
- )
90
- self ._abort_if_unique_id_configured ()
91
- return await self .async_step_features ()
90
+ # try:
91
+ # self.client = ModbusClient.AsyncModbusTcpClient(
92
+ # user_input[CONF_HOST], user_input[CONF_PORT]
93
+ # )
94
+ # await self.client.connect()
95
+ # # Perform a simple read to check the connection
96
+ # await self.client.read_holding_registers(2818 , 1, 1)
97
+ # except (ConnectionException, ModbusException) as exc:
98
+ # _LOGGER.error(f"Modbus connection failed: {exc}")
99
+ # errors["base"] = "cannot_connect"
100
+ # else:
101
+ # await self.client.close()
102
+ # await self.async_set_unique_id(
103
+ # self.data[CONF_HOST], raise_on_progress=False
104
+ # )
105
+ self ._abort_if_unique_id_configured ()
106
+ return await self .async_step_features ()
92
107
93
108
return self .async_show_form (
94
109
step_id = "user" , data_schema = get_host_schema_config (self .data ), errors = errors
@@ -131,19 +146,19 @@ async def async_step_init(
131
146
errors = {}
132
147
if user_input is not None :
133
148
self .data = user_input
134
- try :
135
- self .client = ModbusClient .AsyncModbusTcpClient (
136
- user_input [CONF_HOST ], user_input [CONF_PORT ]
137
- )
138
- await self .client .connect ()
139
- # Perform a simple read to check the connection
140
- await self .client .read_input_registers ( 32770 , 1 , 1 )
141
- except (ConnectionException , ModbusException ) as exc :
142
- _LOGGER .error (f"Modbus connection failed: { exc } " )
143
- errors ["base" ] = "cannot_connect"
144
- else :
145
- await self .client .close ()
146
- return await self .async_step_features ()
149
+ # try:
150
+ # self.client = ModbusClient.AsyncModbusTcpClient(
151
+ # user_input[CONF_HOST], user_input[CONF_PORT]
152
+ # )
153
+ # await self.client.connect()
154
+ # # Perform a simple read to check the connection
155
+ # await self.client.read_holding_registers(2818 , 1, 1)
156
+ # except (ConnectionException, ModbusException) as exc:
157
+ # _LOGGER.error(f"Modbus connection failed: {exc}")
158
+ # errors["base"] = "cannot_connect"
159
+ # else:
160
+ # await self.client.close()
161
+ return await self .async_step_features ()
147
162
148
163
return self .async_show_form (
149
164
step_id = "init" ,
@@ -157,7 +172,7 @@ async def async_step_features(
157
172
"""Handle the feature step."""
158
173
if user_input is None :
159
174
return self .async_show_form (
160
- step_id = "features" , data_schema = get_solvis_modules (self .data )
175
+ step_id = "features" , data_schema = get_solvis_modules_options (self .data )
161
176
)
162
177
self .data .update (user_input )
163
178
return self .async_create_entry (title = self .config .get (CONF_NAME ), data = self .data )
0 commit comments