Using HMI JSON API fastcgi/backend
-
Hello,
I am trying to read/set things via the HMI API JSON backend, but I'm not having any luck so far.
Trying a command like:
curl --header "Content-Type: application/json" --request POST --data '{"ver":"1"}' http://127.0.0.1:9999/
And variations, but I'm not getting any response, although the server does appear to be listening on the port 9999:
root@L203-sn218:/etc/network# netstat -an | grep 9999 tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:9999 127.0.0.1:34224 ESTABLISHED tcp 0 0 127.0.0.1:34230 127.0.0.1:9999 TIME_WAIT tcp 0 0 127.0.0.1:34224 127.0.0.1:9999 ESTABLISHED
It connects, but no data comes back, so it just eventually times out. While this is waiting to timeout, the HMI web interface is also unresponsive. It's not mentioned in API documentation how to connect to which port, or the how to structure the URL, for example.
I tried to structure a query like this and send this with curl to port 80 and port 9999, but I get the same no-response. (or port 80 returns 404 error).
{"ver":1,"v":["svc://defaultConnection/9566[0,1]","svc://defaultConnection/9566[0,1]"]}:
Any pointers would be greatly appreciated.
-
Hello @robl, unfortunately this is very marginal functionality and we have never used it. Please, try contacting the authors of the Mervis for more information: https://mervis.info/#/en/home
May I ask why have you chosen this way of pulling data from Mervis?
Thank you in advance and have a nice day,
Martin -
@martin-kudláček I would like to be able to trigger certain things based on some external data, for example get some weather data, or read from an external calendar or web page, and then trigger something in Mervis. Mervis really could use the ability to call an external script and push the output of that into a variable, for example.
Reading though the forum here, it looks like it's not advisable to have Evok and Mervis in place at the same time.
Whilst the web interface HMI is okay, it's not possible to have HMI and a logic block (say, the Output from a momentary button logic, and HMI controlling it at the same time.) I have to do a hack to read variables set by the HMI, do the logic in the Function block, and then set the variable back again for the HMI. You end up having to awkwardly process a lot of logic state, and this makes it quite complicated if you want to control things from both the web interface and physical inputs.
I may have a look at Evok, but didn't really find a nice web front-end for it that might be suitable for a home automation type project which look like they would be fast enough/don't require a lot of coding. I understand it might be possible to interact with it using say, python and Modbus, but it doesn't look that friendly to work with.
-
Hello @robl,
thanks for such detailed answer.I understand your frustration with the HMI. The complications you are facing are based on the Finite-state machine design of the Mervis, which was picked for easier transition from other/older PLC systems. Realization of some complex logic is not as straightforward as you are probably used to from other programming languages / paradigms.
I would love to dive into your problem with controlling outputs from program and HMI:) I have a solution which was primarily design for our Direct Switch functionality, but it needs a serious documentation because it is quite complicated. I hope I could be able to put it together by the end of this month.
As for the Evok - we are finishing with Node-RED nodes for UniPi which internally use Evok. Here are some quick mockups of how it will be used:
Basic usage of all inputs and outputs:
Some basic regulation of heating with hysteresis:
Generic Node-RED Dashboard:
It's all in the process:) If nothing bad happens, we will release it by the and of this month.
Best regards,
Martin