Submit Binary Sensor state as integer to InfluxDB

I’m using the InfluxDB database integration, but I’m having an issue with Binary Sensors. The current integration submits values for these as strings (on/off) but I want to be able to do some charts showing when two binary sensors where not on at the same time.

Is there a way to submit a secondary measurement for InfluxDB in which the state is cast as an integer (in cases of on/off states)?

Thanks,

Yes that should be possible by using a Template Sensor Template - Home Assistant