Closed the78mole closed 2 weeks ago
The raw sensor should be able to receive any number as a hexadecimal coded string. It doesn't say if there should be a leading "0x" in the string though.
The count sensors are available in uint8, uint16 and uint32, which you can use for any (positive number). The raw sensor is a special case, where you have to specify the length of the bytestring first (in the 2nd byte). However, the raw sensor is intended to send a bytestring as is, there won't be any translation to a number in e.g. Home Assistant. But the count sensor should be ok for the unsigned inters at least.
Feel free to add a specific type if you want, by creating a PR.
I understand, that there is a raw sensor, but this does still not address the issue, that some of the sensor values, currently defined only positive, can often go negative (voltage, power, current...). Is it intended to be solved in the future or does someone need to always work around it and introduce quite some overhead on the receiving side?
We can add a count sensors that can go negative (signed int), to at least solve it with a generic sensor type. It is also possible to add some singed int sensors for specific types. But I don't think negative voltage is used very often.
A generic signed int sensor would already serve well. You should also think about integrating a signed power sensor. Thinking about households with solar power and battery storage, a power sensor that measures positive and negative power is needed in every place (main meter, battery sensor,...) and it is totally necessary, if you want to control the power generation in a way, that you get net zero for the main net meter. Thanks for taking it into account!
Added in 3.11.0
Is your feature request related to a problem? Please describe. Currently I'm implementing some device with a magnetic sensor. But since there is no data type for magnetic flux or something similar, I would need at least a workaround, but there is also not a generic data type for non-binary values.
Describe the solution you'd like I would like to have a set of generic data types, someone can use according to their needs. These are:
Additional context I also realized, that some datatypes are defined as uintX, like voltage, but voltage can also go negative...