IOT Communications - REST API vs Websockets

Have a question regarding when to use websockets over rest apis for bi directional communications between device and server.

I have a device that is capable of hosting a web server (such as my android phone), I can host a rest server on my device and whenever the web server needs something from my device I can call it and vice versa.

Being that web sockets are bidirectional, my first thought is to use a websocket server between the two and let them communicate.

So my question is, which one is better? My only hesitation about using websockets is because I need to update an array on the webserver fairly often and this seems like a PUT rest operation. Thanks

It depends on what kind of websockets you are using. For example, if you are using socket.io than passing arrays in the form of json exists.

Performance wise websockets perform better and in the use case you are using, I don't think there is a wrong way but I think websockets are the way to go here.