Giter Site home page Giter Site logo

Comments (12)

zxdavb avatar zxdavb commented on July 24, 2024

I have pulled sensor_types out as SENSOR_TYPES (could be called BINARY_SENSOR_TYPES).

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

required keyword-only argument

Should be optional?

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

I am not familiar with this:

@dataclass(kw_only=True)
class RamsesEntityDescription(EntityDescription):
    """Class describing Ramses entities."""

    has_entity_name: bool = True
    extra_attributes: list[str] = field(default_factory=list)  # dict?

from ramses_cc.

trvrnrth avatar trvrnrth commented on July 24, 2024

Odd. It works fine for me. These are the docs for creating a new list for the dataclass. It's a list, not a dict as it is a list of device properties to expose as attributes.

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

But:

    RamsesBinarySensorEntityDescription(
        key="active_fault",
        name="Active fault",
        rf_class=Logbook,
        entity_class=RamsesLogbookBinarySensor,
        device_class=BinarySensorDeviceClass.PROBLEM,
        extra_attributes={                                            # this is a dict
            ATTR_ACTIVE_FAULT: "active_fault",
            ATTR_LATEST_EVENT: "latest_event",
            ATTR_LATEST_FAULT: "latest_fault",
        },

from ramses_cc.

trvrnrth avatar trvrnrth commented on July 24, 2024

🤦 Yes, you're absolutely correct. The default should be a dict (type dict[str, str])! I initially implemented it as a list before changing it to be more flexible but was completely forgetting about that when writing that comment.

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

...but doesn't solve my problem.

from ramses_cc.

trvrnrth avatar trvrnrth commented on July 24, 2024

We don't actually need it to default to an empty dict. I'm confused as to why that's not working for you but does the following work instead?

    extra_attributes: dict[str, str] | None = None

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

Well.

I had tried

extra_attributes: dict[str, str] | None = field(default_factory=dict)

... which didn't work, but your suggestion does!

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

I'll push that.

from ramses_cc.

zxdavb avatar zxdavb commented on July 24, 2024

We're both running dev branch of HA, with Python 3.11.6, right?

from ramses_cc.

trvrnrth avatar trvrnrth commented on July 24, 2024

We're both running dev branch of HA, with Python 3.11.6, right?

I've been running on a slightly out of date dev branch of HA (Dec 3) running with the provided devcontainer which has Python 3.11.4. I also tested on my main install of 2023.12.3. I'll update to latest dev for good measure.

from ramses_cc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.