smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
59 stars 24 forks source link

[viessmann] add uom and consumption channels #293

Closed rogrun closed 2 years ago

rogrun commented 2 years ago

This PR includes a refactoring for UOM and adding channels for consumption.

I have also added the Viessmann logo (Viessmann allowed me to do this / I asked for it) Is it possible to add this logo in the bindings area on OH like on the official bindings?

J-N-K commented 2 years ago

Image: Not currently, because the addon-service is not providing an image to openHAB, but I'll raise a PR for that.

Regarding the UoM change: I didn't have time to check the code yet (hope to find time tomorrow). Are channels that were created with an older version of the binding automatically changed to the new channel-types?

rogrun commented 2 years ago

Image: Sounds good. 😀

UoM: The existing channels are not automatically changed to the new channel-types. Currently the thing has to be deleted and rediscovered.

Is there a way to do this automatically?

Do not hurry, it would be nice if it is in the new release.

J-N-K commented 2 years ago

If I remember correctly, channels are added dynamically when an update is received and the channel is missing, is that correct? If so, it's quite easy to do. How many channels are affected?

rogrun commented 2 years ago

Yes, that's right, channels are added dynamically. About 30 channels are affected.

J-N-K commented 2 years ago

Ok, it's a bit work, but you need to add a dependency

  <dependencies>
    <dependency>
      <groupId>org.smarthomej.addons.bundles</groupId>
      <artifactId>org.smarthomej.commons</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

then inherit the thing handler from UpdatingBaseThingHandler instead of BaseThingHandler.

Then create a file update/device.update with the content

1;REMOVE_CHANNEL;channel1
1;REMOVE_CHANNEL;channel2
1;REMOVE_CHANNEL;channel3
...

and finally add a property <thingTypeVersion>1</thingTypeVersion> to the device-thing (in the OH-INF/things/thing-types.xml.

rogrun commented 2 years ago

All changes are done. But the thingTypeVersion property is not automatically added to the device thing Only deletion and rediscovery works. Is it correct that way?

J-N-K commented 2 years ago

No. It should be added and it works for me. Are you sure it is not added? Do you see the Updating {} from version {} to {} message again on next startup?

rogrun commented 2 years ago

I have made a mistake. I created the update folder in the wrong place. Now it works for me. Thanks :)

rogrun commented 2 years ago

Everything is done. Ready for review.

rogrun commented 2 years ago

Thanks :) I have done the requested changes.

Good to know with Json.fromJson :)