netdaemon icon indicating copy to clipboard operation
netdaemon copied to clipboard

ProximityEntity state should be numeric

Open rumbu13 opened this issue 2 years ago • 4 comments

Problem: State for ProximityEntity is a string

On the contrary, it is always measured in km, miles or other distance units.

Solution: Alter Code Generator

Use NumericEntityState to define ProximityEntity:

public record ProximityEntity : Entity<ProximityEntity, NumericEntityState<ProximityAttributes>, ProximityAttributes>

More Info

Reference: Proximity Integration

rumbu13 avatar Jun 05 '22 05:06 rumbu13

I guess we need to handle proximity separately in codegen @FrankBakkerNl ?

helto4real avatar Jun 13 '22 17:06 helto4real

We basically have 3 types of domains now 1 always string (default) 2 always numeric, like input_number 3 only numeric if there is a unit of measurement attribute

Which of these would fit best here?

FrankBakkerNl avatar Jun 13 '22 18:06 FrankBakkerNl

I would vote for 3, since unit_of_measurement is optional, but if not set, it is considered km and added by default to the state attributes.


Another one: CounterEntity state should also be numeric. Basically it's just an input_number where the value cannot be set but can be incremented, decremented or reset.

CounterEntity will fit best in the 2nd category.

Reference: Counter Integration

public partial record CounterEntity : Entity<CounterEntity, NumericEntityState<CounterAttributes>, CounterAttributes>

rumbu13 avatar Jun 25 '22 14:06 rumbu13

New one: InputDatetimeEntity state should be DateTime?

References: InputDatetime Integration

rumbu13 avatar Jul 19 '22 10:07 rumbu13