I normally use one decimal point of precision for my temp/humidity sensors and I searched but could not find any way to do this with zigbee2mqtt.
I know I could manually do it in a Home Assistant template but this would prevent the use of MQTT auto-discovery.
Thanks in advance.
P.S. Oh and I set pressure to zero decimal points of precision (ie whole numbers).
Implemented, see documentation on how to use it.
Thank you!
Would it also make sense to have a global config equivalent to the device specific config in the main section of the configuration.yaml for when you always want parameters measured with a particular level of precision (including all future sensors)?
I also noticed that even with precision set to 1 if the value returned by the sensor happens to be a whole number it returns an int rather than a float (ie missing the .0)
I've installed 1.0.0 yesterday and made changes to the configuration.yaml to set the precision to 1 decimal instead of the default of 2. Restarted zigbee2mqtt but still receiving data with 2 decimals.
Is there anything else I should change?
I have set temperature and humidity values to have 1 decimal for 2 devices.
@justmvg checkout the dev branch
device_options (see https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/configuration/device_specific_configuration.md#changing-device-type-specific-defaults)@justmvg checkout the dev branch
Thank you. I managed to make it work with the dev branch.
Thank you so much for implementing device type specific defaults!
Granted, I don't really know what I am talking about and this is based on a quick google search, but couldn't you just use .toFixed(precision) where precision is a variable containing the number of decimal points of precision desired?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
The problem of toFixed is that it returns a string, the values should be kept numerical.
Does it matter when the intended output is a JSON string? Internally it can be numerical, but when being reported as part of a MQTT JSON string it could be considered seperate.
I don't know, can home assistant still handle it? Does it automatically do the numeric conversion?
My understanding of MQTT was that value types were inferred from the presentation of the JSON string. But I am about as far from an expert in the field as is possible.
Yes that's true, but this JSON string can contain textual and numerical values.
I guess trying it and seeing what happens is the only ay to be sure. But as far as I understand it's all a string until context turns it into whatever type it needs to be.
Hey guys, I'm running the latest version of zigbee2mqtt and after adding the following, I'm still seeing the messages get sent with default precision settings.
device_options:
--temperature_precision: 1
--humidity_precision: 1
--pressure_precision: 1
The - represents space
Can't get it to format right in code format.
This is put right after the serial: section and before the devices: section.
What am I doing wrong?
@mateuszdrab are you using the dev branch?
@mateuszdrab are you using the dev branch?
I'm on master, makes sense. I can try that later, I need to open an issue for another matter as well.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
- Device type specific default can now be set via
device_options(see https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/configuration/device_specific_configuration.md#changing-device-type-specific-defaults)
The link is not working any more :(
EDIT: Never mind, i'm stupid, found it..
EDIT2: Is there any way to change the default of all sensors at once?
@zerofruchtshake http://www.zigbee2mqtt.io/configuration/device_specific_configuration.html#changing-device-type-specific-defaults
@zerofruchtshake http://www.zigbee2mqtt.io/configuration/device_specific_configuration.html#changing-device-type-specific-defaults
Where should I put this:
device_options:
occupancy_timeout: 130
temperature_precision: 1
If I put this to HA configuration.yaml, I get error "Component error: device_options - Integration device_options not found."
Also tried HA Configuration - > Customization -> Entitty: Humidity sensor -> add other attribute -> name: humidity_precision value: 1 -> Reboot
But this also does not work.
@zerofruchtshake http://www.zigbee2mqtt.io/configuration/device_specific_configuration.html#changing-device-type-specific-defaults
Where should I put this:
device_options:
occupancy_timeout: 130
temperature_precision: 1If I put this to HA configuration.yaml, I get error "Component error: device_options - Integration device_options not found."
Also tried HA Configuration - > Customization -> Entitty: Humidity sensor -> add other attribute -> name: humidity_precision value: 1 -> Reboot
But this also does not work.
Put it in devices.yaml or configuration.yaml (add-on) not HA.
Most helpful comment
Implemented, see documentation on how to use it.