co2mini


Nameco2mini JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryMonitor CO2 levels with Prometheus and/or HomeKit
upload_time2023-12-03 13:01:33
maintainer
docs_urlNone
authorJeremy Mayeres
requires_python>=3.9
licenseMIT License Copyright (c) 2020 Jeremy Mayeres Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords co2 co2mini temperature humidity sensors prometheus homekit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CO2 monitoring with Prometheus

This reads from the CO2 Meter and makes it available as a Prometheus service.
The core logic comes from [this hackaday article](https://hackaday.io/project/5301-reverse-engineering-a-low-cost-usb-co-monitor/log/17909-all-your-base-are-belong-to-us).

## Setup

Note this assumes you are running on a Raspberry Pi running Raspberry Pi OS (Bullseye)

1. Install Python 3
2. Install the monitor with `python3 -m pip install co2mini[homekit]` (remove `[homekit]` if you don't use HomeKit)
3. Set up CO2 udev rules by copying `90-co2mini.rules` to `/etc/udev/rules.d/90-co2mini.rules`
4. Set up the service by copying `co2mini.service` to `/etc/systemd/system/co2mini.service`
5. (Optional) Put a configuration file (see Configuration section below) in `/etc/co2mini.env`
6. Run `systemctl enable co2mini.service`

## Configuration

The `/etc/co2mini.env` file contains the environment variables used to configure co2mini beyond the defaults.
This is mostly necessary when enabling MQTT.

Example:

```bash
MQTT_ENABLED=true
MQTT_BROKER=localhost
```

### MQTT/Home Assistant

The MQTT feature is meant to work with Home Assistant, although nothing bad will happen if you just want to use the MQTT messages directly.

When co2mini starts up, it will send out the discovery message that Home Assistant expects, as well as responding to homeassistant's status when coming online.
Be sure those are enabled in the Home Assistant MQTT integration (usually is enabled by default) if you have any issues.

To configure co2mini, the following environment variables are available:

Variable                | Default              | Description
------------------------|----------------------|---------------------------------------------------------------------------------------------------------
`NAME`                  | `co2mini`            | This is used for the default display name of the device in Home Assistant
`MQTT_ENABLED`          | `False`              | Used to enable/disable sending information over MQTT
`MQTT_BROKER`           | `localhost`          | MQTT Broker hostname
`MQTT_PORT`             | `1883`               | MQTT broker port number (1883 is the standard MQTT broker port)
`MQTT_USERNAME`         |                      | Username for authenticating to MQTT broker (leave blank if no authentication is needed)
`MQTT_PASSWORD`         |                      | Password for authenticating to MQTT broker (leave blank if no authentication is needed)
`MQTT_DISCOVERY_PREFIX` | `homeassistant`      | Prefix for sending MQTT discovery and state messages.
`MQTT_RETAIN_DISCOVERY` | `False`              | Flag to enable setting `retain=True` on the discovery messages. You probably don't need this.
`MQTT_OBJECT_ID`        | `co2mini_{HOSTNAME}` | Override for setting the `object_id` in Home Assistant. Default builds using the hostname of the device.

### Homekit

If you have the `homekit` dependencies installed, on the first startup you will need to check the logs to get the setup code to integrate with Homekit.
You can find the code using `journalctl -u co2mini.service` or possibly by checking the status with `systemctl status co2mini.service`.

Note also that it's sometimes possible that co2mini will have some errors logged and won't be reporting in Homekit anymore.
If this happens, it seems like the easiest thing to do is to remove the device from your homekit, remove the `accessory.state` file in your home (`rm accessory.state`) and restart `co2mini` (`sudo systemctl restart co2mini.service`) to get a new code to pair.

## Special notes for Dietpi users

- Be sure to install `Python3 pip` as well (ID `130`)
- Make sure the dietpi user is in `plugdev` group (`sudo usermod -aG plugdev dietpi`)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "co2mini",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "co2,co2mini,temperature,humidity,sensors,prometheus,homekit",
    "author": "Jeremy Mayeres",
    "author_email": "jeremy@jerr.dev",
    "download_url": "https://files.pythonhosted.org/packages/a0/53/1a1171d7c12aa9d57da9e36ab815d4aee960fd67d6a13a78b67c8be80a49/co2mini-0.4.0.tar.gz",
    "platform": null,
    "description": "# CO2 monitoring with Prometheus\n\nThis reads from the CO2 Meter and makes it available as a Prometheus service.\nThe core logic comes from [this hackaday article](https://hackaday.io/project/5301-reverse-engineering-a-low-cost-usb-co-monitor/log/17909-all-your-base-are-belong-to-us).\n\n## Setup\n\nNote this assumes you are running on a Raspberry Pi running Raspberry Pi OS (Bullseye)\n\n1. Install Python 3\n2. Install the monitor with `python3 -m pip install co2mini[homekit]` (remove `[homekit]` if you don't use HomeKit)\n3. Set up CO2 udev rules by copying `90-co2mini.rules` to `/etc/udev/rules.d/90-co2mini.rules`\n4. Set up the service by copying `co2mini.service` to `/etc/systemd/system/co2mini.service`\n5. (Optional) Put a configuration file (see Configuration section below) in `/etc/co2mini.env`\n6. Run `systemctl enable co2mini.service`\n\n## Configuration\n\nThe `/etc/co2mini.env` file contains the environment variables used to configure co2mini beyond the defaults.\nThis is mostly necessary when enabling MQTT.\n\nExample:\n\n```bash\nMQTT_ENABLED=true\nMQTT_BROKER=localhost\n```\n\n### MQTT/Home Assistant\n\nThe MQTT feature is meant to work with Home Assistant, although nothing bad will happen if you just want to use the MQTT messages directly.\n\nWhen co2mini starts up, it will send out the discovery message that Home Assistant expects, as well as responding to homeassistant's status when coming online.\nBe sure those are enabled in the Home Assistant MQTT integration (usually is enabled by default) if you have any issues.\n\nTo configure co2mini, the following environment variables are available:\n\nVariable                | Default              | Description\n------------------------|----------------------|---------------------------------------------------------------------------------------------------------\n`NAME`                  | `co2mini`            | This is used for the default display name of the device in Home Assistant\n`MQTT_ENABLED`          | `False`              | Used to enable/disable sending information over MQTT\n`MQTT_BROKER`           | `localhost`          | MQTT Broker hostname\n`MQTT_PORT`             | `1883`               | MQTT broker port number (1883 is the standard MQTT broker port)\n`MQTT_USERNAME`         |                      | Username for authenticating to MQTT broker (leave blank if no authentication is needed)\n`MQTT_PASSWORD`         |                      | Password for authenticating to MQTT broker (leave blank if no authentication is needed)\n`MQTT_DISCOVERY_PREFIX` | `homeassistant`      | Prefix for sending MQTT discovery and state messages.\n`MQTT_RETAIN_DISCOVERY` | `False`              | Flag to enable setting `retain=True` on the discovery messages. You probably don't need this.\n`MQTT_OBJECT_ID`        | `co2mini_{HOSTNAME}` | Override for setting the `object_id` in Home Assistant. Default builds using the hostname of the device.\n\n### Homekit\n\nIf you have the `homekit` dependencies installed, on the first startup you will need to check the logs to get the setup code to integrate with Homekit.\nYou can find the code using `journalctl -u co2mini.service` or possibly by checking the status with `systemctl status co2mini.service`.\n\nNote also that it's sometimes possible that co2mini will have some errors logged and won't be reporting in Homekit anymore.\nIf this happens, it seems like the easiest thing to do is to remove the device from your homekit, remove the `accessory.state` file in your home (`rm accessory.state`) and restart `co2mini` (`sudo systemctl restart co2mini.service`) to get a new code to pair.\n\n## Special notes for Dietpi users\n\n- Be sure to install `Python3 pip` as well (ID `130`)\n- Make sure the dietpi user is in `plugdev` group (`sudo usermod -aG plugdev dietpi`)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2020 Jeremy Mayeres  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Monitor CO2 levels with Prometheus and/or HomeKit",
    "version": "0.4.0",
    "project_urls": {
        "repository": "https://github.com/jerr0328/co2-mini"
    },
    "split_keywords": [
        "co2",
        "co2mini",
        "temperature",
        "humidity",
        "sensors",
        "prometheus",
        "homekit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92b04490688f5079ec908f2d7f03335448a1fd43c444891a3628ea628cdaef76",
                "md5": "2bed9a876622c7a224cf75d9e2e1b50f",
                "sha256": "5b5d48f3aa80041573c6d603a0b0e075e58fbb054ba90c2f73fee388ed4edbbb"
            },
            "downloads": -1,
            "filename": "co2mini-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2bed9a876622c7a224cf75d9e2e1b50f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10019,
            "upload_time": "2023-12-03T13:01:32",
            "upload_time_iso_8601": "2023-12-03T13:01:32.358106Z",
            "url": "https://files.pythonhosted.org/packages/92/b0/4490688f5079ec908f2d7f03335448a1fd43c444891a3628ea628cdaef76/co2mini-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0531a1171d7c12aa9d57da9e36ab815d4aee960fd67d6a13a78b67c8be80a49",
                "md5": "c2051dd91c3ffc30b77cc7363dcd801a",
                "sha256": "ca63ee2baa05ed509f854bf6de322f7cb872af35b40a66d26d15a19bc940493d"
            },
            "downloads": -1,
            "filename": "co2mini-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c2051dd91c3ffc30b77cc7363dcd801a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 13125,
            "upload_time": "2023-12-03T13:01:33",
            "upload_time_iso_8601": "2023-12-03T13:01:33.316785Z",
            "url": "https://files.pythonhosted.org/packages/a0/53/1a1171d7c12aa9d57da9e36ab815d4aee960fd67d6a13a78b67c8be80a49/co2mini-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-03 13:01:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jerr0328",
    "github_project": "co2-mini",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "co2mini"
}
        
Elapsed time: 0.17480s