|
22 | 22 | DEFAULT_MIN_HUMIDITY, |
23 | 23 | ) |
24 | 24 | from homeassistant.components.template.const import CONF_AVAILABILITY_TEMPLATE |
25 | | -from homeassistant.components.template.helpers import async_setup_template_platform |
| 25 | +from homeassistant.components.template.helpers import ( |
| 26 | + async_create_template_tracking_entities, |
| 27 | + validate_template_scripts, |
| 28 | +) |
26 | 29 | from homeassistant.components.template.schemas import make_template_entity_base_schema |
27 | 30 | from homeassistant.components.template.template_entity import TemplateEntity |
28 | 31 | from homeassistant.const import ( |
|
58 | 61 | CONF_TARGET_HUMIDITY_TEMPLATE = "target_humidity_template" |
59 | 62 | CONF_TURN_OFF_ACTION = "turn_off" |
60 | 63 | CONF_TURN_ON_ACTION = "turn_on" |
| 64 | +SCRIPT_OPTIONS = ( |
| 65 | + CONF_TURN_ON_ACTION, |
| 66 | + CONF_TURN_OFF_ACTION, |
| 67 | + CONF_SET_HUMIDITY_ACTION, |
| 68 | + CONF_SET_MODE_ACTION, |
| 69 | +) |
61 | 70 |
|
62 | 71 | DEFAULT_NAME = "Template Humidifier" |
63 | 72 | DEFAULT_TARGET_HUMIDITY = 50 |
64 | 73 | DEFAULT_TARGET_HUMIDITY_STEP = 1.0 |
65 | 74 | DOMAIN = "humidifier_template" |
66 | | -PLATFORMS = ["humidifier"] |
| 75 | +PLATFORMS = [HUMIDIFIER_DOMAIN] |
67 | 76 |
|
68 | 77 |
|
69 | 78 | def _humidity(value): |
@@ -109,15 +118,13 @@ async def async_setup_platform( |
109 | 118 | ): |
110 | 119 | """Set up the Template Humidifier.""" |
111 | 120 | await async_setup_reload_service(hass, DOMAIN, PLATFORMS) |
112 | | - await async_setup_template_platform( |
113 | | - hass, |
114 | | - HUMIDIFIER_DOMAIN, |
115 | | - config, |
| 121 | + await validate_template_scripts(hass, config, SCRIPT_OPTIONS) |
| 122 | + async_create_template_tracking_entities( |
116 | 123 | TemplateHumidifier, |
117 | | - None, |
118 | 124 | async_add_entities, |
119 | | - discovery_info, |
120 | | - {}, |
| 125 | + hass, |
| 126 | + [config], |
| 127 | + None, |
121 | 128 | ) |
122 | 129 |
|
123 | 130 |
|
|
0 commit comments