Skip to content

Commit

Permalink
Improve logic for determining config value boolean type (#719)
Browse files Browse the repository at this point in the history
* Improve logic for determining config value boolean type

* fix

* Update zwave_js_server/model/value.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
  • Loading branch information
raman325 and MartinHjelmare authored Aug 10, 2023
1 parent 4fff8e7 commit 8f5743f
Showing 1 changed file with 12 additions and 1 deletion.
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:
return ConfigurationValueType.BOOLEAN

if (
Expand Down

0 comments on commit 8f5743f

Please sign in to comment.