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

[miio] Add Zhimi Heater za1 #8743

Merged
merged 1 commit into from
Oct 14, 2020
Merged

Conversation

marcelrv
Copy link
Contributor

add model zhimi.heater.za1

Signed-off-by: Marcel Verpaalen [email protected]

add model zhimi.heater.za1

Signed-off-by: Marcel Verpaalen <[email protected]>
@marcelrv marcelrv added the enhancement An enhancement or new feature for an existing add-on label Oct 12, 2020
@marcelrv marcelrv requested a review from cpmeister October 12, 2020 22:31
@TravisBuddy
Copy link

Travis tests were successful

Hey @marcelrv,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Number relative_humidity "Relative Humidity" (G_heater) {channel="miio:basic:heater:relative_humidity"}
Switch childlock "Child Lock" (G_heater) {channel="miio:basic:heater:childlock"}
Switch HWSwitch "HW Switch" (G_heater) {channel="miio:basic:heater:HWSwitch"}
Number temperature "Temperature" (G_heater) {channel="miio:basic:heater:temperature"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use units here?

Suggested change
Number temperature "Temperature" (G_heater) {channel="miio:basic:heater:temperature"}
Number:Temperature temperature "Temperature" (G_heater) {channel="miio:basic:heater:temperature"}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the honest answer is... I don't know.

The documentation https://www.openhab.org/docs/developer/bindings/thing-xml.html#channels does not have much explanation,

I'm not too clear anymore on the difference between the Number:Temperature vs channel-type <category>Temperature</category> vs new QuantityType<>(temperature, SIUnits.CELSIUS));

as I create all channels dynamically, is it enough to just change the datatype to Number:Temperature when the channel is created like: Channel newChannel = ChannelBuilder.create(channelUID, datatype). .withLabel(friendlyName).build();

And if I create it that way, does it require the quantity type in the update or not...

anyway... in my wishlist #7276 I do have the wish to somehow implement this... but is not too high on my priority list... as I don't understand it well enough, don't understand the big advantage if it is there.... and am bit afraid it breaks things...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I create all channels dynamically, is it enough to just change the datatype to Number:Temperature when the channel is created like: Channel newChannel = ChannelBuilder.create(channelUID, datatype). .withLabel(friendlyName).build();

Yes, that is all that would be necessary. At that point you just need to use QuantityType instead of DecimalType for those relevant channels. and also make sure to use QuantityType.toUnit() when processing the state from handleCommand.

QuantityType allows users to use different units for their UI. For example a binding may report temperature in C but the user wants it displayed as F.

You don't need to make the transition just yet, but please plan for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, made placeholder #8756 for it.
Temperature updates are fine, but still need test how to conveniently go from a unit string to a Unit
e.g. from "Celcius" to Units.CELSIUS in a generic way

@cpmeister cpmeister merged commit aef1d10 into openhab:main Oct 14, 2020
@cpmeister cpmeister added this to the 3.0.0.M2 milestone Oct 14, 2020
boehan pushed a commit to boehan/openhab-addons that referenced this pull request Apr 12, 2021
add model zhimi.heater.za1

Signed-off-by: Marcel Verpaalen <[email protected]>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
add model zhimi.heater.za1

Signed-off-by: Marcel Verpaalen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants