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