postTemplate method
Render a Home Assistant template.
See template docs for more information. Returns the rendered template in plain text.
Implementation
Future<(String?, HaFailure?)> postTemplate({
required String template,
Map<String, dynamic>? variables,
}) async {
final endpoint = '/api/template';
final data = jsonEncode({
'template': template,
'variables': variables,
});
final response =
await sl.get<HttpClient>().post(url + endpoint, _headers, data);
return response.success
? (response.dataStr, null)
: (null, HaFailure(message: response.dataStr));
}