getStates method

Future<(HaStates?, HaFailure?)> getStates()

Returns an array of state objects. Each state has the following attributes: entity_id, state, last_changed and attributes.

Implementation

Future<(HaStates?, HaFailure?)> getStates() async {
  const endpoint = '/api/states';
  final response = await sl.get<HttpClient>().get(url + endpoint, _headers);
  return response.success
      ? (HaStates.fromResponse(jsonDecode(response.dataStr)), null)
      : (null, HaFailure(message: response.dataStr));
}