ha-mqtt-discoverable icon indicating copy to clipboard operation
ha-mqtt-discoverable copied to clipboard

Support normal sensors

Open Bluscream opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like Normal text and number sensors without the input fields

Describe alternatives you've considered None

Additional context Idk why we can't just have normal sensors like this:

instead of this:

Bluscream avatar Feb 01 '24 10:02 Bluscream

The code just makes an HA-compatible sensor set of mqtt topics. The UI part is all done by HA.

If I've read the doc wrong and there is a way to control the view with a MQTT entry, please let me know.

unixorn avatar Feb 01 '24 21:02 unixorn

Seems to be related to https://github.com/unixorn/ha-mqtt-discoverable/issues/84 but when i try to use that (https://github.com/Bluscream/fritzbox-extended-stats-mqtt/blob/main/stats.py#L161-L163) my app sends nothing to mqtt at all

Bluscream avatar Feb 02 '24 04:02 Bluscream

I just tried it, using this sample code and it looks nearly identical:


import asyncio

from ha_mqtt_discoverable import Settings, DeviceInfo
from ha_mqtt_discoverable.sensors import Sensor, SensorInfo


async  def main():
    mqtt_settings = Settings.MQTT(host="192.168.0.216",
                                  username="someusername",
                                  password="somepassword")
    device_info = DeviceInfo(name="SpeedTest", identifiers="unique_device_id")
    sensor_info = SensorInfo(name="Upload", device=device_info, unique_id="unique_sensor_info_id",
                      state_class="measurement",
                      unit_of_measurement="Mbit/s",
                      device_class="data_rate",
                      icon="mdi:speedometer")
    settings = Settings(mqtt=mqtt_settings, entity=sensor_info)
    sensor = Sensor(settings)
    sensor.set_state(31.26)

    while True:
        # update sensor here
        await asyncio.sleep(1)

if __name__ == '__main__':
    asyncio.run(main())

See this screenshot:

Image

kratz00 avatar Feb 25 '25 15:02 kratz00