Relay status by db mysql

Good evening
in my house I installed a home automation system based on tcp / ip: that relay boards communicate with a server.
I have setup homeassistant whit this configuration for turn on and turn off the lights/socket but in this moment don’t have the status!
I have to retrieve it from the dbmysql:
switch:
platform: command_line
scan_interval: 5
switches:
relay1:
command_on: “/usr/bin/curl --request POST ‘http://user:[email protected]:81/rest/v1.2/relays/setbyid/109/on/json’”
command_off: “/usr/bin/curl --request POST ‘http://user:[email protected]:81/rest/v1.2/relays/setbyid/109/off/json’”
value_template: “{{ value == ‘IH 1’ }}” friendly_name: Relay 1

how can I do?
thanks a lot to everyone
Sorry for my english
Marco