Skip to content

Conversation

kcstonacek
Copy link
Contributor

@kcstonacek kcstonacek commented Oct 11, 2025

This pull request is in response to this topic related to populating TuyaMCU enum types in home assistant.

PR includes the following:

  • Created two new channel type ChType_Enum ChType_ReadOnlyEnum
  • activate and update the dormant code for CMD_SetChannelEnum
  • update HTTP interface to support Enum types with <select> html elements.
  • set home assistant type to Select for the Enum channels, populated the 'options' defined from SetChannelEnum via discovery
  • ReadOnlyEnum channel types are sent to home assistant as Sensors via discovery.
  • configured home assistant value and command templates via discovery populated from SetChannelEnum
  • contributed to enum self tests

Usage Example:
SetChannelType 1 Enum
SetChannelEnum 1 0:Zero "1:Title One" 4:Four

SetChannelType 1 ReadOnlyEnum
SetChannelEnum 1 1:One "0:Zero" 4:Four

Points to note:

  • it appears much of the original Select templates in hass.c that this PR is based on is a work in progress, and as such may require re-work as those progress.
  • the javascript blocking refreshes while focus is on a select box is only based on document.activeElement.tagName != "SELECT"
  • Added ReadOnlyEnum types to the PR as requested in the topic
  • Enum channel types default to TextField when SetChannelEnum has not been defined
  • Adding lots of enums to autoexec.bat can lead to low heap issues when performing HA discovery. I observed this in the main build with 15+ channels without Enums, but Enums certainly aren't helping. Some better memory management during discovery is probably needed.

@openshwprojects openshwprojects merged commit 4ad9a85 into openshwprojects:main Oct 14, 2025
56 checks passed
Copy link

🎉 This PR is included in version 1.18.194 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants