GreyEarl / qingping-air-monitor-mqtt

Use local MQTT functionality of the Qingping Air Monitor
19 stars 0 forks source link

HA config #1

Open jamdzl opened 11 months ago

jamdzl commented 11 months ago

Any chance you can share / add your yaml config for HA?

Jozziej commented 11 months ago

This is my Configuration.yaml

mqtt: Sensor:

The part where it says “macaddress” you need to fill in the Mac address of your Qingping Air Monitor

Then restart your HA and then you’ll find the sensors under the Mqtt integration

GreyEarl commented 11 months ago

@jamdzl Mine will more or less match the same, so thanks for replying @Jozziej Just for the formality I'm pasting mine below.

## Qingping measurements extracted from MQTT
# Device 01

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_ppm"
     unit_of_measurement: "ppm"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['co2']['value'] }}"
     name: airmon1_co2
     icon: mdi:molecule-co2

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_hum"
     unit_of_measurement: "%"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['humidity']['value'] |round(2) }}"
     name: airmon1_hum
     icon: mdi:water-percent

   - state_topic: "qingping/enteryourmac/up"
     force_update: true
     unique_id: "airmon1_pm25"
     value_template: "{{ value_json['sensorData'][0]['pm25']['value'] |round(2) }}"
     name: airmon1_pm25
     unit_of_measurement: 'µg/m³'
     icon: mdi:cloud

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_pm10"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['pm10']['value'] |round(2) }}"
     name: airmon1_pm10
     unit_of_measurement: 'µg/m³'
     icon: mdi:cloud

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_tvoc"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['tvoc']['value'] }}"
     name: airmon1_tvoc
     icon: mdi:molecule
     unit_of_measurement: 'ppb'

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_temp"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['temperature']['value'] |round(2) }}"
     name: airmon1_temp
     unit_of_measurement: 'C'
     icon: mdi:thermometer

   - state_topic: "qingping/enteryourmac/up"
     unique_id: "airmon1_bat"
     force_update: true
     value_template: "{{ value_json['sensorData'][0]['battery']['value'] }}"
     name: airmon1_bat
     unit_of_measurement: '%'
     icon: mdi:battery-high
FlyingFinn11 commented 3 months ago

@jamdzl @Jozziej Hmm neither saves correctly in configuration.yaml !! Any other ideas?

Jozziej commented 3 months ago

Could be indentation, but would be more helpfull if you share a logfile error

FlyingFinn11 commented 3 months ago

Thanks man it is definitely indentation but the way you pasted it without formatting got me confused! If you can take a screen grab of how it looks for you...or some other way I can carry it over into configuration.yaml ? This has taken four hours so far today :(

I've test on MQTT Explorer and it's definitely transmitting correctly to HA. Just need to convert the JSON.

jamdzl commented 3 months ago

From configuration.yaml (Last line shows the include for mqtt.yaml)

# Loads default set of integrations. Do not remove.
default_config:

python_script: 

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml
mqtt: !include mqtt.yaml

From mqtt.yaml (same directory as configuration.yaml, did not include all my qingping sensors, just the first two)

sensor:

  # ----------------------
  # Qingping Air Sensor
  # ----------------------

  - object_id: AIR_co2
    name: "Air CO2"
    state_topic: "qingping/YOURIDHERE/up"
    device_class: carbon_dioxide
    unique_id: "qingping_dioxide"
    value_template: >-
      {{ value_json.sensorData.0.co2.value if value_json.type == "12" }}
    unit_of_measurement: "ppm"
    device:
      identifiers: ["YOURIDHERE"]
      name: "Air monitor"
      model: "CGS1"
      manufacturer: "qingping"
  - object_id: AIR_temp
    name: "Air Temperature"
    state_topic: "qingping/YOURIDHERE/up"
    device_class: temperature
    unique_id: "qingping_temp"
    value_template: >-
      {{ value_json.sensorData.0.temperature.value|round(2)
      if value_json.type=="12" and value_json.sensorData.0.temperature.status==0 }}
    unit_of_measurement: "°C"
    device:
      identifiers: ["YOURIDHERE"]
      name: "Air monitor"
      model: "CGS1"
      manufacturer: "qingping"
FlyingFinn11 commented 3 months ago

Thank you!!!!

gavrilov commented 2 months ago

You can use integration to connect qingping sensor to HomeAssistant https://github.com/bob-tm/ha-qingping

Please add to readme