This project contains:
-
A Factorio 2.0 mod (in
control.lua&info.json) that periodically writes a JSON snapshot (factory_state.json) with:- Machine status
- Inventories
- Pollution
- Fluid info
- Production counts
-
A Python script (
main.py) that watches the generatedfactory_state.jsonand publishes updates to an MQTT broker with structured JSON messages.
- Mario Gonsales Ishikawa (GitHub: marioishikawa)
For Intellic Integration
Licensed under the Apache 2.0 License.
- Copy or zip the
mqtt_notifyfolder (withcontrol.lua&info.json) into your Factoriomodsdirectory. - Ensure your Factorio version is 2.0 or compatible with no direct
write_filerestrictions.
-
Install Python 3.
-
From this folder, create a virtual environment (optional) and install dependencies:
python -m venv .venv source .venv/bin/activate # or .\.venv\Scripts\activate on Windows pip install -r requirements.txt
-
Edit
main.pyif needed:FACTORY_STATE_FILEpoints to yourscript-output/factory_state.json.BROKERandPORTto your MQTT broker settings.
-
Run
main.py:python main.py
It will monitor the Factorio JSON file and publish MQTT messages at
factorio/<category>/<type>/<id>/....
- When Factorio starts or loads, the mod scans for existing tracked entities (assembling machines, furnaces, mining drills, containers, etc.).
- Every 1 second (60 ticks), it updates:
- Production progress
- Inventories
- Status (bitmask integer)
- Pollution, fluids
- Writes
script-output/factory_state.json.
The JSON file has a structure like:
{
"tick": 123456,
"assets": [
{
"unit_number": 14,
"name": "assembling-machine-2",
"type": "assembling-machine",
"last_status": 53
}
]
}The Python script picks this up and publishes to MQTT.
- Entity Types: If you want to track belts, inserters, etc., add them to
TRACKED_TYPESincontrol.lua. - MQTT Topic Structure: Edit
publish_asset_data()inmain.pyif you want different subtopic naming.
- Machine state is not correctly identifying the downtime state, due to the lack of proper information on the API documentation.
This project is licensed under Apache License 2.0.