Possible implementations:
- Expose the flag as a binary_sensor
or
- Expose them as a switch:
Map flag true to state 'on' and flag false to state 'off'
turn_on service to PUT /sensors/#/state {"flag": true}
turn_off service to PUT /sensors/#/state {"flag": false}
I would prefer the second one.