Code Monkey home page Code Monkey logo

Comments (7)

sampsyo avatar sampsyo commented on August 14, 2024 2

Done! Just published v1.4.0.

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024 1

Thanks! The culprit is here:

"Operation": {
  "_comment": "운전On/Off",
  "type": "Enum",
  "default": "0",
  "option": {
    "0": "@AC_MAIN_OPERATION_OFF_W",
    "1": "@AC_MAIN_OPERATION_RIGHT_ON_W"
  }
},

Namely, the "on" state for your model is @AC_MAIN_OPERATION_RIGHT_ON_W. This used to be what we used for "on," but #57 changed the "on/off" states to have separate states for left, right, and both:

wideq/wideq/ac.py

Lines 113 to 116 in 919139d

OFF = "@AC_MAIN_OPERATION_OFF_W"
RIGHT_ON = "@AC_MAIN_OPERATION_RIGHT_ON_W" # Right fan only.
LEFT_ON = "@AC_MAIN_OPERATION_LEFT_ON_W" # Left fan only.
ALL_ON = "@AC_MAIN_OPERATION_ALL_ON_W" # Both fans (or only fan) on.

…which apparently is the right thing to do for some models but not yours.

I'm not sure exactly what to do here. I guess we need to query what type of model it is at setup and adjust the "on" state accordingly? That is, when we create the ACDevice object, it should check whether its Operation option supports @AC_MAIN_OPERATION_ALL_ON_W and, if so, switches the enum value for turning the device on from RIGHT_ON to ALL_ON.

Every time I interact with this LG API, we find another messy mistake…

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024 1

Well, fortunately we wouldn't have to literally hardcode a model->behavior mapping. We could just look in the model information dictionary to check which modes it supports. So at least it would generalize to similar models that have (or don't have) the left & right modes.

In the end, I think you end up sending the number (0 or 1). But we use the string key to avoid hard-coding the specific number for each option.

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024

Got it; thanks! I think the most useful thing here might be the device details from the JSON file that example.py creates. Can you remove your tokens from that file (which are authentication credentials and shouldn't be shared) and include it?

from wideq.

petarvucetin avatar petarvucetin commented on August 14, 2024

Attached. Wow that's a lot of stuff... If you need help let me know.
wideq_state.zip

from wideq.

petarvucetin avatar petarvucetin commented on August 14, 2024

What a PITA.

I like your idea but I am afraid you would perpetually keep adding new mess :) This would require keeping a dictionary of models and their commands. These are pretty volatile going forward?

I would catch exception and try another command until it does not throw exception. This is "programming by exception" which is anti-pattern but their mess will propagate and can only be defended against if you introduce "anti-corruption" layer which I am not convinced is worth your time.

Another idea would be to specify in configuration (somehow) which one to use (or model supports it) e.g. All, Left, Right? Let consumer pick the one that works.

What does 0 and 1 mean here? Not sure how their API works if you have to send @ command or could you just send numerical command?

 "0": "@AC_MAIN_OPERATION_OFF_W",
    "1": "@AC_MAIN_OPERATION_RIGHT_ON_W"

from wideq.

ticky avatar ticky commented on August 14, 2024

Thanks for merging my patch for this - I’d love to get a fresh release out with the fix included soon 😄

from wideq.

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.