All Projects → tjhowse → modbus4mqtt

tjhowse / modbus4mqtt

Licence: other
Modbus TCP <-> MQTT glue. YAML configuration. Robust.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to modbus4mqtt

Modbridge
Bridge between modbus and MQTT
Stars: ✭ 20 (-4.76%)
Mutual labels:  home-automation, mqtt, modbus
Home Assistant
Home-Assistant-Config
Stars: ✭ 182 (+766.67%)
Mutual labels:  home-automation, mqtt
Openmqttgateway
MQTT gateway for ESP8266, ESP32, Sonoff RF Bridge or Arduino with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility, SMS & LORA.
Stars: ✭ 2,413 (+11390.48%)
Mutual labels:  home-automation, mqtt
homely
🏠 - A bunch of mosquittos. IoT wiring and notification framework, with an unix style.
Stars: ✭ 15 (-28.57%)
Mutual labels:  home-automation, mqtt
Homeautio.mqtt.googlehome
Stars: ✭ 168 (+700%)
Mutual labels:  home-automation, mqtt
Broadlink Mqtt
MQTT client to control BroadLink devices
Stars: ✭ 169 (+704.76%)
Mutual labels:  home-automation, mqtt
Platypush
A versatile and extensible platform for home and life automation with hundreds of supported integrations
Stars: ✭ 192 (+814.29%)
Mutual labels:  home-automation, mqtt
Itead sonoff
Alternative firmware for Itead Sonoff switches, based on the MQTT protocol and a TLS connection
Stars: ✭ 115 (+447.62%)
Mutual labels:  home-automation, mqtt
GoogleSpeak
No description or website provided.
Stars: ✭ 14 (-33.33%)
Mutual labels:  home-automation, mqtt
texecom2mqtt-hassio
Home Assistant add-on. Connect to Texecom Premier Elite alarm panels and publish updates to MQTT. Supports arming/disarming as well as zone updates and alarm events.
Stars: ✭ 15 (-28.57%)
Mutual labels:  home-automation, mqtt
soma-ctrl
Node util for controlling SOMA smart shade via MQTT or HTTP
Stars: ✭ 19 (-9.52%)
Mutual labels:  home-automation, mqtt
Temper Esp8266
Temper is a compact temperature sensor based on ESP8266 and SHT30 with large 13x7 pixel led display.
Stars: ✭ 155 (+638.1%)
Mutual labels:  home-automation, mqtt
Ct Smart Home
A ready-to-use Node-RED setup for home automation
Stars: ✭ 132 (+528.57%)
Mutual labels:  home-automation, mqtt
Home Assistant Config Fr
🏠Configuration de Home Assistant en français. 👨🏻‍💻 N'hésitez pas à ⭐ mon repo et à copier les bonnes idées ! 🇨🇵
Stars: ✭ 175 (+733.33%)
Mutual labels:  home-automation, mqtt
Android Mqtt Alarm Panel
Android Alarm Panel for Home Assistant and Home Automation Platforms (http://thanksmister.com/android-mqtt-alarm-panel/)
Stars: ✭ 124 (+490.48%)
Mutual labels:  home-automation, mqtt
Blynk Server
Blynk is an Internet of Things Platform aimed to simplify building mobile and web applications for the Internet of Things. Easily connect 400+ hardware models like Arduino, ESP8266, ESP32, Raspberry Pi and similar MCUs and drag-n-drop IOT mobile apps for iOS and Android in 5 minutes
Stars: ✭ 8 (-61.9%)
Mutual labels:  home-automation, mqtt
M5Stack-Air-Quality-ESPHome
ESPHome configuration for M5Stack's PM2.5 Air Quality Kit with the PMSA003 particulate matter sensor and the SHT20 temperature and humidity sensor
Stars: ✭ 19 (-9.52%)
Mutual labels:  home-automation, mqtt
Core
🏡 Open source home automation that puts local control and privacy first.
Stars: ✭ 48,265 (+229733.33%)
Mutual labels:  home-automation, mqtt
Cec Mqtt Bridge
A HDMI-CEC to MQTT bridge for connecting HDMI-CEC-devices to your Home Automation system.
Stars: ✭ 110 (+423.81%)
Mutual labels:  home-automation, mqtt
server
MyController 2.x server
Stars: ✭ 14 (-33.33%)
Mutual labels:  home-automation, mqtt

Modbus4MQTT

https://github.com/tjhowse/modbus4mqtt

https://pypi.org/project/modbus4mqtt/

codecov

This is a gateway that translates between modbus TCP/IP and MQTT.

The mapping of modbus registers to MQTT topics is in a simple YAML file.

The most up-to-date docs will always be on Github.

Similar software

There is already good software out there that can do what Modbus4MQTT does, but none that I could find that has this functionality as its focus. Do one thing and do it well. Modbus4mqtt is designed to fit in as a component of other systems, rather than trying to be a complete solution.

Installation

Python module

$ pip3 install --user modbus4mqtt
$ modbus4mqtt --help

Docker container

Alternatively you can run Modbus4MQTT in a Docker container. A Dockerfile example is provided.

$ docker pull tjhowse/modbus4mqtt:latest
$ docker run modbus4mqtt --help

When launching inside the docker container you will either need to use one of the built-in YAMLs like /modbus4mqtt/modbus4mqtt/Sungrow_SH5k_20.yaml, or map your custom YAML into the container in a volume.

YAML definition

Look at the Sungrow SH5k-20 configuration YAML for a working example.

Modbus device settings

ip: 192.168.1.89
port: 502
update_rate: 5
address_offset: 0
variant: sungrow
scan_batching: 100
Field name Required Default Description
ip Required N/A The IP address of the modbus device to be polled. Presently only modbus TCP/IP is supported.
port Optional 502 The port on the modbus device to connect to.
update_rate Optional 5 The number of seconds between polls of the modbus device.
address_offset Optional 0 This offset is applied to every register address to accommodate different Modbus addressing systems. In many Modbus devices the first register is enumerated as 1, other times 0. See section 4.4 of the Modbus spec.
variant Optional N/A Allows variants of the ModbusTcpClient library to be used. Setting this to 'sungrow' enables support of SungrowModbusTcpClient. This library transparently decrypts the modbus comms with sungrow SH inverters running newer firmware versions.
scan_batching Optional 100 Must be between 1 and 100 inclusive. Modbus read operations are more efficient in bigger batches of contiguous registers, but different devices have different limits on the size of the batched reads. This setting can also be helpful when building a modbus register map for an uncharted device. In some modbus devices a single invalid register in a read range will fail the entire read operation. By setting scan_batching to 1 each register will be scanned individually. This will be very inefficient and should not be used in production as it will saturate the link with many read operations.

Register settings

registers:
  - pub_topic: "forced_charge/mode"
    set_topic: "forced_charge/mode/set"
    retain: true
    pub_only_on_change: false
    table: 'holding'
    address: 13140
    value_map:
      enabled: 170
      disabled: 85
  - pub_topic: "forced_charge/period_1/start_hours"
    set_topic: "forced_charge/period_1/start_hours/set"
    pub_only_on_change: true
    table: 'holding'
    address: 13142
  - pub_topic: "voltage_in_mv"
    address: 13000
    scale: 1000
  - pub_topic: "first_bit_of_second_byte"
    address: 13001
    mask: 0x0010
  - pub_topic: "load_control/optimized/end_time"
    address: 13013
    json_key: hours
  - pub_topic: "load_control/optimized/end_time"
    address: 13014
    json_key: minutes
  - pub_topic: "external_temperature"
    address: 13015
    type: int16

This section of the YAML lists all the modbus registers that you consider interesting.

Field name Required Default Description
address Required N/A The decimal address of the register to read from the device, starting at 0. Many modbus devices enumerate registers beginning at 1, so beware.
pub_topic Optional N/A This is the topic to which the value of this register will be published.
set_topic Optional N/A Values published to this topic will be written to the Modbus device. Cannot yet be combined with json_key. See #23 for details.
retain Optional false Controls whether the value of this register will be published with the retain bit set.
pub_only_on_change Optional true Controls whether this register will only be published if its value changed from the previous poll.
table Optional holding The Modbus table to read from the device. Must be 'holding' or 'input'.
value_map Optional N/A A series of human-readable and raw values for the setting. This will be used to translate between human-readable values via MQTT to raw values via Modbus. If a value_map is set for a register the interface will reject raw values sent via MQTT. If value_map is not set the interface will try to set the Modbus register to that value. Note that the scale is applied after the value is read from Modbus and before it is written to Modbus.
scale Optional 1 After reading a value from the Modbus register it will be multiplied by this scalar before being published to MQTT. Values published on this register's set_topic will be divided by this scalar before being written to Modbus.
mask Optional 0xFFFF This is a 16-bit number that can be used to select a part of a Modbus register to be referenced by this register. For example a mask of 0xFF00 will map to the most significant byte of the 16-bit Modbus register at address. A mask of 0x0001 will reference only the least significant bit of this register.
json_key Optional N/A The value of this register will be published to its pub_topic in JSON format. E.G. { key: value } Registers with a json_key specified can share a pub_topic. All registers with shared pub_topics must have a json_key specified. In this way, multiple registers can be published to the same topic in a single JSON message. If any of the registers that share a pub_topic have the retain field set that will affect the published JSON message. Conflicting retain settings are invalid. The keys will be alphabetically sorted.
type Optional uint16 The type of the value stored at the modbus address provided. Only uint16 (unsigned 16-bit integer) and int16 (signed 16-bit integer) are currently supported.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].