CyberDNS / Lupusec2Mqtt

Lupusec Alarm System to Mqtt
MIT License
11 stars 5 forks source link

have energy sensor on PowerSwitch #39

Closed scaiandre closed 1 year ago

scaiandre commented 1 year ago

The Power Switch also carries a energy meter. Even though energy aggregation could be done on home assistant itself, I'd rather rely on the internal aggregation of the meter itself, as it is more reliable.

In other cases, as the Power Switch carries the data, I think it is useful to have it available.

I feel the return value of ConversionService.GetDevice and ConversionService.GetStateProvider is a little bit cumbersome currently, as I now have added the new SwitchEnergySensor as an additional return value, which is null for most devices. Maybe should rather return a list of thingies of the same interface.

But that would be another type of change...

CyberDNS commented 1 year ago

Hi @scaiandre and thanks for the pull request.

I was currently working on a new model to make the integration of new devices easier and this includes the problem you are mentioning, I have just now pushed the new model to the master branch.

With the design of the new model you can register 3 different types of "objects":

The devices are now generated by a factory class per device, so that the old conversion class is gone and now every device can handle it's creation on it's own.

Also the poll loop has changed because it is now completely generic, so no special code anymore for alarm panels and switches etc. The class is located in the root folder of the project (MainLoop.cs)

Finally, can I ask you to adapt your code to apply to this new model, I think it should be quite fast and easy.

Best regards, David

scaiandre commented 1 year ago

I will not be able to wrap my head aroung the refactoring you made in the near future. As you are probably know arms deep in the refactoring anyway, maybe you could add the SwitchEnergySensor I provided in the pull request.

CyberDNS commented 1 year ago

Yes no problem, I will integrate it.

CyberDNS commented 1 year ago

A new version 3.0.3 is available on edge lane that integrates the energy sensor. As this version is a pre-release with a lot of code changes, please open issue if you encounter problems.

scaiandre commented 1 year ago

Cool, thank you, I will look into it after the holidays!

Guten Rutsch!