File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed
Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change 1212 "PersistedNumber" , number .Number , cg .Component
1313)
1414
15- PERSISTED_NUMBER_SCHEMA = number .NUMBER_SCHEMA .extend (
15+ BASE_SCHEMA = (
16+ number .number_schema (PersistedNumber )
17+ if hasattr (number , "number_schema" )
18+ else number ._NUMBER_SCHEMA
19+ )
20+
21+ PERSISTED_NUMBER_SCHEMA = BASE_SCHEMA .extend (
1622 {
1723 cv .GenerateID (): cv .declare_id (PersistedNumber ),
1824 cv .Optional (CONF_RESTORE_VALUE , default = True ): cv .boolean ,
Original file line number Diff line number Diff line change 1414CONF_PRESENCE = "presence_sensor"
1515TYPES = [CONF_PRESENCE ]
1616
17+ # ESPHome: BINARY_SENSOR_SCHEMA removed -> use binary_sensor.binary_sensor_schema(...)
18+ BASE_SCHEMA = (
19+ binary_sensor .binary_sensor_schema (binary_sensor .BinarySensor )
20+ if hasattr (binary_sensor , "binary_sensor_schema" )
21+ else binary_sensor ._BINARY_SENSOR_SCHEMA
22+ )
23+
1724CONFIG_SCHEMA = cv .Schema (
1825 {
1926 cv .GenerateID (CONF_ROODE_ID ): cv .use_id (Roode ),
20- cv .Optional (CONF_PRESENCE ): binary_sensor . BINARY_SENSOR_SCHEMA .extend (
27+ cv .Optional (CONF_PRESENCE ): BASE_SCHEMA .extend (
2128 {
2229 cv .GenerateID (): cv .declare_id (binary_sensor .BinarySensor ),
2330 }
2431 ),
2532 }
2633)
2734
28-
2935# def validate_can_use_presence(value):
3036# main = fv.full_config.get()["roode"][0]
3137# presence_sensor = main.get(CONF_USE_PRESENCE)
4046# {cv.Optional(CONF_PRESENCE): validate_can_use_presence}, extra=cv.ALLOW_EXTRA
4147# )
4248
43-
4449async def setup_conf (config , key , hub ):
4550 if key in config :
4651 conf = config [key ]
4752 sens = cg .new_Pvariable (conf [CONF_ID ])
4853 await binary_sensor .register_binary_sensor (sens , conf )
4954 cg .add (getattr (hub , f"set_{ key } _binary_sensor" )(sens ))
5055
51-
5256async def to_code (config ):
5357 hub = await cg .get_variable (config [CONF_ROODE_ID ])
5458 for key in TYPES :
Original file line number Diff line number Diff line change 2020CONFIG_SCHEMA = cv .Schema (
2121 {
2222 cv .GenerateID (CONF_ROODE_ID ): cv .use_id (Roode ),
23+
2324 cv .Optional (VERSION ): text_sensor .text_sensor_schema ().extend (
2425 {
2526 cv .Optional (CONF_ICON , default = "mdi:git" ): cv .icon ,
2627 cv .GenerateID (): cv .declare_id (text_sensor .TextSensor ),
2728 cv .Optional (
28- CONF_ENTITY_CATEGORY , default = ENTITY_CATEGORY_DIAGNOSTIC
29+ CONF_ENTITY_CATEGORY ,
30+ default = ENTITY_CATEGORY_DIAGNOSTIC ,
2931 ): cv .entity_category ,
3032 }
3133 ),
34+
3235 cv .Optional (ENTRY_EXIT_EVENT ): text_sensor .text_sensor_schema ().extend (
3336 {
3437 cv .Optional (CONF_ICON , default = "mdi:sign-direction" ): cv .icon ,
3538 cv .GenerateID (): cv .declare_id (text_sensor .TextSensor ),
3639 cv .Optional (
37- CONF_ENTITY_CATEGORY , default = ENTITY_CATEGORY_DIAGNOSTIC
40+ CONF_ENTITY_CATEGORY ,
41+ default = ENTITY_CATEGORY_DIAGNOSTIC ,
42+ ): cv .entity_category ,
43+ }
44+ ),
45+
46+ cv .Optional (STATUS ): text_sensor .text_sensor_schema ().extend (
47+ {
48+ cv .Optional (CONF_ICON , default = "mdi:check-circle" ): cv .icon ,
49+ cv .GenerateID (): cv .declare_id (text_sensor .TextSensor ),
50+ cv .Optional (
51+ CONF_ENTITY_CATEGORY ,
52+ default = ENTITY_CATEGORY_DIAGNOSTIC ,
3853 ): cv .entity_category ,
3954 }
4055 ),
You can’t perform that action at this time.
0 commit comments