getState method
Obtains the state of the node with id nodeId
.
Example map output:
{
'Light': {
'brightness': 0,
'output': true,
},
'Switch': {
'output': true,
}
}
Implementation
Future<Map<String, dynamic>> getState(String nodeId) async {
final uri = _urlBase.getPath(_nodeState, {
'node_id': nodeId,
});
final resp = await get(
uri,
headers: {
URLBase.authHeader: accessToken,
},
);
final Map<String, dynamic> bodyResp =
await JsonIsolate().decodeJson(resp.body);
if (resp.statusCode != 200) {
throw bodyResp['description'];
}
return bodyResp;
}