# pyESPMega
This library provides a mean of communicating with the ESPMega Programmable Logic Controller through MQTT<br/>
## **Compatibility**
This library is compatible with:<br/>
- ESPMega R2.4 [2018] (Model e) with IoT FreedomOS v1.2+
- ESPMega R3.0 [2020] (All Model) with IoT Core LT OS V1.4
- ESPMega Plus R1.0 [2020] (All Model) with IoT Core LT+ OS V1.4
- ESPMega R4.0 [2023] (All Model) with IoT Core LT OS V2
- ESPMega PRO R2.0 [2020] (Model c) with IoT Core OS V1
- ESPMega PRO R3.3 [2023] (Model b,c) with IoT Core OS V2.2 (or above)
## **ESPMega Client Types**
There are two type of ESPMega client, ESPMega and ESPMega_standalone<br/>
### ESPMega
ESPMega class requires you to provide and maintain an MQTT connection
This class takes in a Paho-MQTT Client as an input argument<br/>
**Import and Initialization**
```
from espmega.espmega_r3 import ESPMega
plc = ESPMega("/basetopic", MQTT_CLIENT)
```
### ESPMega_standalone
ESPMega_standalone create and maintain the required mqtt connection for you.
**Import and Initialization**
```
from espmega.espmega_r3 import ESPMega_standalone as ESPMega
plc = ESPMega("/basetopic", "MQTT_SERVER", MQTT_PORT)
```
## **ESPMega Client Functions**
- `digital_read(pin: int) -> bool`: Reads the digital value from the specified pin.
- `digital_write(pin: int, state: bool) -> None`: Sets the digital state of a pin.
- `analog_write(pin: int, state: bool, value: int)`: Writes an analog value to the specified pin.
- `adc_read(pin: int) -> int`: Reads the value from the ADC pin.
- `dac_write(pin: int, state: bool, value: int)`: Writes the state and value to the DAC pin.
- `enable_adc(pin: int)`: Enables the ADC (Analog-to-Digital Converter) for the specified pin.
- `disable_adc(pin: int)`: Disable the ADC (Analog-to-Digital Converter) for the specified pin.
- `set_ac_mode(mode: str)`: Sets the mode of the air conditioner.
- `set_ac_temperature(temperature: int)`: Sets the temperature of the air conditioner.
- `set_ac_fan_speed(fan_speed: str)`: Sets the fan speed of the air conditioner.
- `get_ac_mode()`: Returns the current AC mode.
- `get_ac_temperature()`: Returns the current temperature of the air conditioning system.
- `get_ac_fan_speed()`: Get the current fan speed of the air conditioner.
- `read_room_temperature()`: Reads and returns the room temperature.
- `read_humidity()`: Reads and returns the humidity value from the humidity buffer.
- `send_infrared(code: dict)`: Sends an infrared code.
- `request_state_update()`: Update all cached states.
- `handle_message(client: pahomqtt.Client, data, message: pahomqtt.MQTTMessage)`: Handles incoming MQTT messages.
- `get_input_buffer()`: Return all states of the input pins as a list.
- `get_pwm_state(pin: int)`: Return the state of the specified PWM pin.
- `get_pwm_value(pin: int)`: Return the value of the specified PWM pin.
- `get_pwm_state_buffer()`: Return all states of the PWM pins as a list.
- `get_pwm_value_buffer()`: Return all values of the PWM pins as a list.
Raw data
{
"_id": null,
"home_page": "https://github.com/SiwatINC/pyespmega",
"name": "espmega",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "mqtt esp32",
"author": "Siwat Sirichai",
"author_email": "siwat@siwatinc.com",
"download_url": "https://files.pythonhosted.org/packages/96/00/d522d88c4d8707072deabdaeab2f3718381c1a6536d0fa78cd45b659932f/espmega-1.13.tar.gz",
"platform": null,
"description": "# pyESPMega\r\nThis library provides a mean of communicating with the ESPMega Programmable Logic Controller through MQTT<br/>\r\n\r\n## **Compatibility**\r\nThis library is compatible with:<br/>\r\n- ESPMega R2.4 [2018] (Model e) with IoT FreedomOS v1.2+\r\n- ESPMega R3.0 [2020] (All Model) with IoT Core LT OS V1.4\r\n- ESPMega Plus R1.0 [2020] (All Model) with IoT Core LT+ OS V1.4\r\n- ESPMega R4.0 [2023] (All Model) with IoT Core LT OS V2\r\n- ESPMega PRO R2.0 [2020] (Model c) with IoT Core OS V1\r\n- ESPMega PRO R3.3 [2023] (Model b,c) with IoT Core OS V2.2 (or above)\r\n\r\n## **ESPMega Client Types**\r\nThere are two type of ESPMega client, ESPMega and ESPMega_standalone<br/>\r\n### ESPMega\r\nESPMega class requires you to provide and maintain an MQTT connection\r\nThis class takes in a Paho-MQTT Client as an input argument<br/>\r\n**Import and Initialization**\r\n```\r\nfrom espmega.espmega_r3 import ESPMega\r\nplc = ESPMega(\"/basetopic\", MQTT_CLIENT)\r\n```\r\n### ESPMega_standalone\r\nESPMega_standalone create and maintain the required mqtt connection for you.\r\n**Import and Initialization**\r\n```\r\nfrom espmega.espmega_r3 import ESPMega_standalone as ESPMega\r\nplc = ESPMega(\"/basetopic\", \"MQTT_SERVER\", MQTT_PORT)\r\n```\r\n## **ESPMega Client Functions**\r\n- `digital_read(pin: int) -> bool`: Reads the digital value from the specified pin.\r\n- `digital_write(pin: int, state: bool) -> None`: Sets the digital state of a pin.\r\n- `analog_write(pin: int, state: bool, value: int)`: Writes an analog value to the specified pin.\r\n- `adc_read(pin: int) -> int`: Reads the value from the ADC pin.\r\n- `dac_write(pin: int, state: bool, value: int)`: Writes the state and value to the DAC pin.\r\n- `enable_adc(pin: int)`: Enables the ADC (Analog-to-Digital Converter) for the specified pin.\r\n- `disable_adc(pin: int)`: Disable the ADC (Analog-to-Digital Converter) for the specified pin.\r\n- `set_ac_mode(mode: str)`: Sets the mode of the air conditioner.\r\n- `set_ac_temperature(temperature: int)`: Sets the temperature of the air conditioner.\r\n- `set_ac_fan_speed(fan_speed: str)`: Sets the fan speed of the air conditioner.\r\n- `get_ac_mode()`: Returns the current AC mode.\r\n- `get_ac_temperature()`: Returns the current temperature of the air conditioning system.\r\n- `get_ac_fan_speed()`: Get the current fan speed of the air conditioner.\r\n- `read_room_temperature()`: Reads and returns the room temperature.\r\n- `read_humidity()`: Reads and returns the humidity value from the humidity buffer.\r\n- `send_infrared(code: dict)`: Sends an infrared code.\r\n- `request_state_update()`: Update all cached states.\r\n- `handle_message(client: pahomqtt.Client, data, message: pahomqtt.MQTTMessage)`: Handles incoming MQTT messages.\r\n- `get_input_buffer()`: Return all states of the input pins as a list.\r\n- `get_pwm_state(pin: int)`: Return the state of the specified PWM pin.\r\n- `get_pwm_value(pin: int)`: Return the value of the specified PWM pin.\r\n- `get_pwm_state_buffer()`: Return all states of the PWM pins as a list.\r\n- `get_pwm_value_buffer()`: Return all values of the PWM pins as a list.\r\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "",
"version": "1.13",
"project_urls": {
"Homepage": "https://github.com/SiwatINC/pyespmega"
},
"split_keywords": [
"mqtt",
"esp32"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9600d522d88c4d8707072deabdaeab2f3718381c1a6536d0fa78cd45b659932f",
"md5": "8d537ee2684825f135a5a57a3ae4bc7c",
"sha256": "ddc452cb042ec04a45a0fe4463a7b554685083d3d66317a999defec06502a688"
},
"downloads": -1,
"filename": "espmega-1.13.tar.gz",
"has_sig": false,
"md5_digest": "8d537ee2684825f135a5a57a3ae4bc7c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4629,
"upload_time": "2023-12-08T11:22:24",
"upload_time_iso_8601": "2023-12-08T11:22:24.818646Z",
"url": "https://files.pythonhosted.org/packages/96/00/d522d88c4d8707072deabdaeab2f3718381c1a6536d0fa78cd45b659932f/espmega-1.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-08 11:22:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SiwatINC",
"github_project": "pyespmega",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "espmega"
}