Closed mplinuxgeek closed 4 years ago
There is a type_name
property on any W1ThermSensor
which does exactly that for you:
while True:
for sensor in W1ThermSensor.get_available_sensors():
sensor_type_name = sensor.type_name
temperature = sensor.get_temperature()
sensor_id = sensor.id
print("%s %s %.2f" % (sensor_type_name, sensor_id, temperature))
Have fun :tada:
Thank you, I was sure I tried that... I feel silly now!
No worries! Happens to everyone once in a while! :tada:
this attribute no longer exists in 2.0.0, is this intentional?
Is there a better way to get the sensor name?
I'm not very well versed in Python, I'm able to put together examples to build scripts to do what I want but that's about it...
I'm using the w1thermsensor library to publish all DS sensors on the 1wire bus to Home Assistant and would also like to include the sensor type in the discovery config, I currently do this by taking some of you code, namely the sensor definitions to convert the sensor type to a name, surely theres a better way but I don't know how I would do it with your library, could you point me in the right direction?