Coder Social home page Coder Social logo

pymee's People

Contributors

actions-user avatar freshlybrewedcode avatar r4nt avatar stklingner avatar taraman17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pymee's Issues

Expose the attributes options in pymee's HomeeAttributes class.

An Attribute in Homee can have options.
The currently known are:

  • can_observe (list of attribute types)
  • observes (list ob attribute IDs)
  • observed_by (list ob attribute IDs)
  • history (dict {'day': ,'week': ,'month': , 'stepped': } )
  • automations (list of automation names)
  • reverse_control_ui (bool)

At least the last one is useful for other applications acessing Homee. So it is desired to expose them in pymee.

There are two possible approaches:

Option 1

Iterate over the options and convert the dict to an object:

def __init__(self, attributeOptions):
    for key, value in attributeOptions.items():
        setattr(self, key, value)
pro con
- just a few lines of code - using code must check for presence of options to avoid errors
- only options that are present are added - intellisense or similiar tools are not available.
- will also add currently unknown entries

Option 2

Add getters for the known possible options and return empty values if they don't exist.

def __init__(self, attributeOptions):
    self._data = attributeOptions

@property
def can_observe(self) -> list:
    if "can_observe" in self._data:
        return self._data["can_observe"]
...
pro con
- parsing options error handling can be done here - longer code
- intellisense or similar tools available for applications using pymee - unknown options will be ignored
- every attribute has all options, but with empty values

@FreshlyBrewedCode: Since it is your project, I want to get your opinion on which approach to use before I do a pull request


Example code of an Attribute with options:

{
  'id': 38,
  'node_id': 3,
  'instance': 0,
  'minimum': 0,
  'maximum': 4, // 0 = Closed; 1 = Open; 2 = Stop; 3 = Closing; 4 = Opening
  'current_value': 1.0,
  'target_value': 1.0,
  'last_value': 4.0,
  'unit': 'n%2Fa',
  'step_value': 1.0,
  'editable': 1,
  'type': 135, // UP_DOWN
  'state': 1,
  'last_changed': 1687175680,
  'changed_by': 1,
  'changed_by_id': 0,
  'based_on': 1,
  'data': '',
  'name': '',
  'options': {
      'can_observe': [300],
      'observes': [75],
      'reverse_control_ui': True,
      'automations': ['toggle']
}

An error occurred: 'list' object is not an iterator

After the last update, my HA logs show the following:

2023-06-26 13:01:20.559 ERROR (MainThread) [pymee] An error occurred: invalid state
2023-06-26 13:01:25.918 ERROR (MainThread) [pymee] An error occurred: 'list' object is not an iterator

The second line gets repeated then every 5 seconds for about 20 minutes
Not sure yet where it comes from - I keep investigating.

Future development of pymee

Hi,

I'm planning some bigger changes to pymee in the near future:

  • support more message types (error, user, settings)
  • use enum classes in const.py
  • refactor code so HA integration does not need to use private properties

Do you still want to be kept in the loop and do it via Pull requests -> release by you or shall we do it the same way as with the HA integration?

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.