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

Improve logic for determining config value boolean type #719

Merged
merged 3 commits into from
Aug 10, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion zwave_js_server/model/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from enum import StrEnum
from typing import TYPE_CHECKING, Any, TypedDict

from ..const import VALUE_UNKNOWN, CommandClass, ConfigurationValueType, SetValueStatus
Expand All @@ -13,6 +14,15 @@
from .node import Node


class ValueType(StrEnum):
"""Enum with all value types."""

ANY = "any"
BOOLEAN = "boolean"
NUMBER = "number"
STRING = "string"


class MetaDataType(TypedDict, total=False):
"""Represent a metadata data dict type."""

Expand Down Expand Up @@ -301,8 +311,9 @@ def configuration_value_type(self) -> ConfigurationValueType:
max_ = self.metadata.max
states = self.metadata.states
allow_manual_entry = self.metadata.allow_manual_entry
type_ = self.metadata.type

if max_ == 1 and min_ == 0 and not states:
if ((max_ == 1 and min_ == 0) or type_ == ValueType.BOOLEAN) and not states:
raman325 marked this conversation as resolved.
Show resolved Hide resolved
return ConfigurationValueType.BOOLEAN

if (
Expand Down