Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT enum index option leads to error in HA #1280

Closed
MichScha opened this issue Sep 3, 2023 · 7 comments
Closed

MQTT enum index option leads to error in HA #1280

MichScha opened this issue Sep 3, 2023 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@MichScha
Copy link

MichScha commented Sep 3, 2023

PROBLEM DESCRIPTION

I have set enum format to index but it seems that HA doesn´t like it. The discovery option for HA should not be affected by this setting but from logs I get the following error which seems that the index is been used instead of value?

Example

2023-09-03 22:01:43.610 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_dhw_disinfection_day: '1' (valid options: ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'all'])

@proddy mentioned: Setting the enum format to Index doesn't change the MQTT Discovery topics (the options attribute). Would it work for you if we fix this and use the index's as well here instead of the real values?

I am currently not too familiar with HA if this is a good idea :-D From OH perspective I definitly love the index version as a mapping of enum is pretty simple and well implemented.

REQUESTED INFORMATION

"System Info": {
    "version": "3.6.1-dev.0",
    "platform": "ESP32",
@proddy proddy added the enhancement New feature or request label Sep 4, 2023
@proddy
Copy link
Contributor

proddy commented Sep 4, 2023

if the _data MQTT topics are showing the index numbers (0,1,2...) then the associated MQTT discovery topics will also need to map in the options attribute, I suspect. I'll look into it.

proddy added a commit to proddy/EMS-ESP32 that referenced this issue Sep 8, 2023
@proddy
Copy link
Contributor

proddy commented Sep 8, 2023

fixed in 3.6.1-dev.2

@proddy proddy closed this as completed Sep 8, 2023
@proddy proddy added bug Something isn't working and removed enhancement New feature or request labels Sep 8, 2023
@proddy proddy added this to the v3.6.1 milestone Sep 8, 2023
@MichScha
Copy link
Author

MichScha commented Sep 8, 2023

Just tested - getting now less errors but still some (there are more than posted here in the list). String vs Number

....
2023-09-08 22:20:42.124 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_dhw_disinfection_day: '1' (valid options: [0, 1, 2, 3, 4, 5, 6, 7])
2023-09-08 22:20:42.138 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_mode: '0' (valid options: [0, 1])
2023-09-08 22:20:42.139 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_nofrost_mode: '1' (valid options: [0, 1, 2])
2023-09-08 22:20:42.139 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_control_mode: '0' (valid options: [0, 1, 2, 3, 4, 5])
2023-09-08 22:20:42.140 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_program: '0' (valid options: [0, 1])
2023-09-08 22:20:42.140 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_reduce_mode: '2' (valid options: [0, 1, 2])
2023-09-08 22:20:42.141 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.thermostat_hc1_hp_mode: '1' (valid options: [0, 1, 2])
....

@proddy
Copy link
Contributor

proddy commented Sep 8, 2023

Thanks for testing. I think we need to rethink the logic. Although there is probably a use case to use enum index values instead of the string value in the mqtt payload, but it messes up the loveliness of home assistant. Perhaps we should publish both enum index & string values in the _data payload?

@proddy proddy reopened this Sep 8, 2023
proddy added a commit to proddy/EMS-ESP32 that referenced this issue Sep 9, 2023
@proddy
Copy link
Contributor

proddy commented Sep 9, 2023

made a fix, so the indexes are seen as strings. I still think it looks strange, but now no errors hopefully.

proddy added a commit that referenced this issue Sep 9, 2023
fix for MQTT enum index option leads to error in HA #1280
proddy added a commit to proddy/EMS-ESP32 that referenced this issue Sep 9, 2023
proddy added a commit that referenced this issue Sep 9, 2023
#1280 sample value is a string for enums
@proddy proddy closed this as completed Sep 9, 2023
@MichScha
Copy link
Author

No errors now with latest version - Thanks! Just as I am not that familiar with HA - how do you map the enum index to a string or should for HA the mqtt discovery always map the real string for the index without using the enum setting (index)?

Just another thing I currently don´t understand
In HA I see 3 devices where the first one is the device itself. But there should be at least 4 devices based on my setup (EMS-ESP, Boiler, Thermostat, Room-Thermostat. Or is it the idea to collect all thermostat devices in one HA-Device?
image
image

@proddy proddy reopened this Sep 11, 2023
@proddy
Copy link
Contributor

proddy commented Sep 11, 2023

How do you map the enum index to a string or should for HA the mqtt discovery always map the real string for the index without using the enum setting (index)?

You will need to create a template yourself and code the logic. But can you remind me why you wanted to use Index's in the first place?

Just another thing I currently don´t understand In HA I see 3 devices where the first one is the device itself. But there should be at least 4 devices based on my setup (EMS-ESP, Boiler, Thermostat, Room-Thermostat. Or is it the idea to collect all thermostat devices in one HA-Device?

I'm not sure anymore. Probably you'll see all the data in HA as separate heating circuits?

@proddy proddy closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants