MH-Z19 CO_2 and Temperature Sensor
The mhz19 sensor platform allows you to use MH-Z19 CO_2 and temperature sensors
(Revspace_) with ESPHome.
The CO_2 measurement also works with the MH-Z16 and MH-Z14 sensors.

As the communication with the MH-Z19 is done using UART, you need
to have an UART bus in your configuration with the rx_pin connected to the TX pin of the
MH-Z19 and the tx_pin connected to the RX Pin of the MH-Z19 (it’s switched because the
TX/RX labels are from the perspective of the MH-Z19). Additionally, you need to set the baud rate to 9600.
# Example configuration entry
sensor:
  - platform: mhz19
    co2:
      name: MH-Z19 CO2 Value
    temperature:
      name: MH-Z19 TemperatureConfiguration variables
- co2 (Optional): The CO_2 data from the sensor in parts per million (ppm). All options from Sensor. 
- temperature (Optional): The information for the temperature sensor. Please note that this is not officially documented in the datasheet and seems to be quite inaccurate. All options from Sensor. 
- update_interval (Optional, Time): The interval to check the sensor. Defaults to - 60s.
- uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses. 
- id (Optional, ID): Manually specify the ID used for actions. 
- automatic_baseline_calibration (Optional, boolean): MH-Z19 has automatic calibration procedure. The automatic calibration cycle is every 24 hours after powered on. Set this value to - falseto disable ABC on boot (it’s better if you use sensor indoor). Set this value to- trueto enable ABC on boot. Doesn’t send calibration command if not set (default sensor logic will be used).
- warmup_time (Optional, Time): The sensor has a warmup time and before that, it returns bougus readings (eg: 500ppm, 505ppm…). This setting discards readings until the warmup time happened ( - NANis returned). The datasheet says preheating takes 1min, but empirical tests have shown it often takes more, so the 75s default should be enough to accomodate for that.

mhz19.calibrate_zero Action
This action executes zero point calibration command on the sensor with the given ID.
If you want to execute zero point calibration, the MH-Z19 sensor must work in stable gas environment (400ppm) for over 20 minutes and you execute this function.
on_...:
  then:
    - mhz19.calibrate_zero: my_mhz19_idYou can provide an action to perform from Home Assistant
api:
  actions:
    - action: mhz19_calibrate_zero
      then:
        - mhz19.calibrate_zero: my_mhz19_idmhz19.abc_enable Action
This action enables automatic baseline calibration on the sensor with the given ID.
on_...:
  then:
    - mhz19.abc_enable: my_mhz19_idmhz19.abc_disable Action
This action disables automatic baseline calibration on the sensor with the given ID.
on_...:
  then:
    - mhz19.abc_disable: my_mhz19_idYou can provide switch and control ABC from Home Assistant
switch:
  - platform: template
    name: "MH-Z19 ABC"
    optimistic: true
    on_turn_on:
      mhz19.abc_enable: my_mhz19_id
    on_turn_off:
      mhz19.abc_disable: my_mhz19_id