Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a simple, full-functioning miot simulator based on miotspec files, making it possible to test both python-miio and downstream implementations. The simulator keeps an internal state constructed based on the defined property constraints (e.g., ranges for int properties or choices for enums). The values are currently randomly generated based on the constraints the spec file does.
The simulator implements the main commands a miot device uses:
Additionally, the available services and properties can be dumped using
dump_services
anddump_properties
commands.Using
miiocli devtools miot-simulator
requires defining the model (--model
) and the path to a miotspec json file (--file
).Example showing an emulated
zhimi.airpurifier.mb4
in homeassistant (miiocli devtools miot-simulator --file urn\:miot-spec-v2\:device\:air-purifier\:0000A007\:zhimi-mb4\:2.json --model zhimi.airpurifier.mb4
):