Sensor: get state via MQTT, set state via REST

Hello.
I have a device that can publish its state via MQTT and it can receive REST commands to change state (on, off, toggle).
Any ideas how to set up such (binary) sensor in HA that gets (receives) state via MQTT, but sets state via REST API command?