ha-mqtt-discoverable
ha-mqtt-discoverable copied to clipboard
Support normal sensors
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:

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.
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
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: