19
19
CONF_POWER_BTN = "power_btn"
20
20
CONF_POWER_BOOST_KEEP_ON = "power_boost_keep_on"
21
21
CONF_AUTO_BOOT_ON_LOAD = "auto_boot_on_load"
22
+ CONF_ENABLE_POWER_BTN = "enable_power_btn"
22
23
CONF_LOW_POWER_SHUTDOWN_TIME = "low_power_shutdown_time"
23
24
24
-
25
- async def ids_to_code (config , var , types ):
26
- for key in types :
27
- if key in config :
28
- conf = await cg .get_variable (config [key ])
29
- cg .add (getattr (var , f"set_{ key } " )(conf ))
30
-
31
25
CONFIG_SCHEMA = cv .COMPONENT_SCHEMA .extend (
32
26
{
33
27
cv .GenerateID (): cv .declare_id (IP5306 ),
@@ -39,23 +33,31 @@ async def ids_to_code(config, var, types):
39
33
cv .Optional (CONF_CHARGER_CONNECTED ): binary_sensor .binary_sensor_schema (),
40
34
cv .Optional (CONF_CHARGE_FULL ): binary_sensor .binary_sensor_schema (),
41
35
cv .Optional (CONF_CHARGER_ACTIVE ): binary_sensor .binary_sensor_schema (),
42
- cv .Optional (CONF_POWER_BOOST_ON , default = True ): binary_sensor .binary_sensor_schema (),
43
- cv .Optional (CONF_POWER_BOOST_SET , default = True ): binary_sensor .binary_sensor_schema (),
44
- cv .Optional (CONF_POWER_VIN , default = True ): binary_sensor .binary_sensor_schema (),
45
- cv .Optional (CONF_POWER_BTN , default = True ): binary_sensor .binary_sensor_schema (),
46
- cv .Optional (CONF_POWER_BOOST_KEEP_ON , default = True ): binary_sensor .binary_sensor_schema (),
47
- cv .Optional (CONF_AUTO_BOOT_ON_LOAD , default = False ): binary_sensor .binary_sensor_schema (),
36
+ cv .Optional (CONF_POWER_BOOST_ON , default = True ): cv .boolean ,
37
+ cv .Optional (CONF_POWER_BOOST_SET , default = True ): cv .boolean ,
38
+ cv .Optional (CONF_POWER_VIN , default = True ): cv .boolean ,
39
+ cv .Optional (CONF_POWER_BTN , default = True ): cv .boolean ,
40
+ cv .Optional (CONF_POWER_BOOST_KEEP_ON , default = True ): cv .boolean ,
41
+ cv .Optional (CONF_AUTO_BOOT_ON_LOAD , default = False ): cv .boolean ,
42
+ cv .Optional (CONF_ENABLE_POWER_BTN , default = True ): cv .boolean ,
48
43
cv .Optional (CONF_LOW_POWER_SHUTDOWN_TIME , default = 64 ): cv .uint8_t ,
49
44
}
50
45
).extend (i2c .i2c_device_schema (0x75 ))
51
46
52
- IP5306_TYPES = {
47
+ def keys_to_code (config , var , types ):
48
+ for key in types :
49
+ if key in config :
50
+ conf = config [key ]
51
+ cg .add (getattr (var , f"set_{ key } " )(conf ))
52
+
53
+ IP5306_KEYS = {
53
54
CONF_POWER_BOOST_ON ,
54
55
CONF_POWER_BOOST_SET ,
55
56
CONF_POWER_VIN ,
56
57
CONF_POWER_BTN ,
57
58
CONF_POWER_BOOST_KEEP_ON ,
58
59
CONF_AUTO_BOOT_ON_LOAD ,
60
+ CONF_ENABLE_POWER_BTN ,
59
61
CONF_LOW_POWER_SHUTDOWN_TIME
60
62
}
61
63
@@ -80,4 +82,4 @@ async def to_code(config):
80
82
sens = await binary_sensor .new_binary_sensor (config [CONF_CHARGE_FULL ])
81
83
cg .add (var .set_charge_full (sens ))
82
84
83
- await ids_to_code (config , var , IP5306_TYPES )
85
+ keys_to_code (config , var , IP5306_KEYS )
0 commit comments