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] Simplify homeassistant thing types, and use AbstractStorageBasedTypeProvider #16600

Merged
merged 11 commits into from
Aug 12, 2024

Commits on Jul 26, 2024

  1. [mqtt.homeassistant] don't dynamically generate channel types

    Instead, use state descriptions for the varying parts, which means that
    there is not an explosion of channel types for every single Home Assistant
    channel, which can cause performance issues if you have a lot of
    devices/channels
    
    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    1c0bdcb View commit details
    Browse the repository at this point in the history
  2. [mqtt.homeassistant] dynamically change thing type after creation

    This has two important impacts, and one not-as-important-but-still-
    beneficial impact:
     * ThingTypes are not created for Things that are never actually
       created, but only discovered, reducing bloat.
     * Avoids warnings about things types not being in the registry
     * Thing IDs end up like
       mqtt:homeassistant:broker:mydevice instead of
       mqtt:homeassistant_mydevice:broker:mydevice
    
    Note that already-created things will maintain their original ID,
    and it's only new things created from auto-discovery that will have
    the new, shorter thing IDs.
    
    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    b3e4feb View commit details
    Browse the repository at this point in the history
  3. [mqtt.homeassistant] simplify channel ids for newly discovered things

    This is triggered by a property only set by discovery, so will only apply
    to newly created things.
    
    Channel groups are now named after simply the component type and object_id,
    if possible, and without additional encoding, instead off encoding the
    unique_id. Most devices will encode the component type and device identifiers
    into the unique_id, and of arbitrary format, so it is far more complicated
    than necessary, when a channel group is already only within the scope of
    the thing/device.
    
    Many component types that can only ever have one channel (button, switch,
    sensor, select, scene, etc.) will not be in a channel group anymore. In this
    case their channel id is what their group id would have been, without the
    repetitiveness of "sensor_<unique_id>#sensor".
    
    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    bbdfdc3 View commit details
    Browse the repository at this point in the history
  4. [mqtt] Use AbstractStorageBasedTypeProvider

    Includes both homie and homeassistant dynamic things.
    It also fixes all ordering issues in both bindings in order to
    be consistent in how types are persisted:
     * For Homie, Nodes (channel groups) and Properties (channels)
       are ordered in the way they are defined in $nodes and $properties
     * For Home Assistant, Components are ordered by label. This
       includes both single channel components that are not in a channel
       group, as well as channel groups. We also ensure that on the
       Thing itself non-grouped channels consistently sort before grouped
       channels.
    
    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    2e86a4e View commit details
    Browse the repository at this point in the history
  5. fix spotless warning

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    c377dcd View commit details
    Browse the repository at this point in the history
  6. address itests compilation errors

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    cb2a0ec View commit details
    Browse the repository at this point in the history
  7. address review comments

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    9c1f7f0 View commit details
    Browse the repository at this point in the history
  8. fix errors introduced by last commit

    the ternary accidentally got swapped
    
    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    c835743 View commit details
    Browse the repository at this point in the history
  9. fix itest for new channel names

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    d2685f2 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2024

  1. Use ChannelType ID constants, not strings

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    Co-Authored-By: Anton Kharuzhy <publicantroids@gmail.com>
    ccutrer and antroids committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    a88d40b View commit details
    Browse the repository at this point in the history
  2. remove unused variables

    Signed-off-by: Cody Cutrer <cody@cutrer.us>
    ccutrer committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    4c90379 View commit details
    Browse the repository at this point in the history