Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic miIO simulator #1532

Merged
merged 4 commits into from
Sep 22, 2022
Merged

Add basic miIO simulator #1532

merged 4 commits into from
Sep 22, 2022

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Sep 19, 2022

This makes it easier for developers without a real test device to perform some development and testing on device integrations.

To use the simulator, one needs to create a definition file with available properties, their types, initial values and methods that can be used to change them.
Uses currently pydantic for file parsing, the imports should be guarded if a new dependency for non-developers is unwanted.
These files could be later on used for unit-testing the implementations without custom test files, and maybe more (creating list of supported models, ..).

At the moment, this basic implementation only allows simulating devices that use get_prop for getting the properties and a single setter to change their state.

The token is currently hardcoded to full of 0s.
The MAC address will be generated using the model name to allow make instances on the same host unique (e.g., for homeassistant testing).

Example usage: miiocli devtools miio-simulator --file zhimi_fan.yaml --model zhimi.fan.v2

TBD:

This makes it easier for developers without a real test device to perform some development and testing on device integrations.

To use the simulator, one needs to create a definition file with available properties, their types, initial values and methods that can be used to change them.
Uses currently pydantic for file parsing, the imports should be guarded if a new dependency for non-developers is unwanted.
These files could be later on used for unit-testing the implementations without custom test files, and maybe more (creating list of supported models, ..).

At the moment, this basic implementation only allows simulating devices that use get_prop for getting the properties and a single setter to change their state.

The token is currently hardcoded to full of 0s.
The MAC address will be generated using the model name to allow make instances on the same host unique (e.g., for homeassistant testing).

Example usage: miiocli devtools miio-simulator --file zhimi_fan.yaml  --model zhimi.fan.v2
@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2022

Codecov Report

Merging #1532 (eb1e9ac) into master (9fbff33) will decrease coverage by 0.56%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #1532      +/-   ##
==========================================
- Coverage   82.62%   82.05%   -0.57%     
==========================================
  Files         146      149       +3     
  Lines       14359    14458      +99     
  Branches     3489     3511      +22     
==========================================
  Hits        11864    11864              
- Misses       2262     2361      +99     
  Partials      233      233              
Impacted Files Coverage Δ
miio/devtools/__init__.py 0.00% <0.00%> (ø)
miio/devtools/simulators/__init__.py 0.00% <0.00%> (ø)
miio/devtools/simulators/common.py 0.00% <0.00%> (ø)
miio/devtools/simulators/miiosimulator.py 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rytilahti rytilahti merged commit 966f96a into master Sep 22, 2022
@rytilahti rytilahti deleted the feat/miio_simulator branch September 22, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants