Code Monkey home page Code Monkey logo

Comments (9)

parnic avatar parnic commented on June 3, 2024 1

FYI from your code snippet - you can, if you want, leave the client connected and react to the events returned instead of just waiting a half-second (setup an "on" for 'circuitStateChanged', like the example script does). This will get you both a faster program (the pool equipment returns a response much faster than 500ms) and less overhead waiting on logins to happen again the next time you want to query the pool status or set a circuit.

from node-screenlogic.

parnic avatar parnic commented on June 3, 2024 1

I don't know that it matters all that much, honestly. It's possible that someone trying to connect with the ScreenLogic app on their phone or pc would interrupt your app if you held the connection, or maybe they would both work together. In this case I haven't done enough research to answer that, but if it's working for you, feel free to stick with what you have.

from node-screenlogic.

parnic avatar parnic commented on June 3, 2024

Looks like we need to implement the MSG_POOL_SETHEATSP message which has query ID 12528 and consists of 3 ints: bodyType, controllerIndex, temp. For the spa it looks like bodyType is always 1 and controllerIndex is always 0. The pool's bodyType is 0. I assume temp is in whatever temperature units you have the equipment set to.

from node-screenlogic.

pgregg88 avatar pgregg88 commented on June 3, 2024

Thanks I'm giving it a test this weekend. Really appreciate the guidance.

from node-screenlogic.

pgregg88 avatar pgregg88 commented on June 3, 2024

Wow. You already implemented. Major thanks. This is great (and I'm learning from what you did). Thanks twice.

from node-screenlogic.

pgregg88 avatar pgregg88 commented on June 3, 2024

Works! Was able to set the setPoint for both Pool (bodyType 0) and Spa (bodyType 1) by passing a static value. Next, I need to extend this to pass a value from an MQTT message and pass that as the SetPoint variable. It shouldn't be hard.

I also need to refactor my code. Based on your comment above, I'm doing a lot of unnecessary work, connects, etc.

Would this be in line with your recommendation (above)?

function connect(client) {
    client.on('loggedIn', function() {
      this.setSetPoint(0, 1, 75)
    }).on('setPointChanged', function() {
      this.getPoolState()
    })
    client.close();  
    client.connect();
  }

instead of "getPoolState()" I could publish to MQTT directly or any other function I've created.

from node-screenlogic.

parnic avatar parnic commented on June 3, 2024

Sure. I don't know that the client.close() needs to be there, but that's up to you. You'd probably want to listen to the 'poolStatus' event to get the response from getPoolState() as well. Once you've done all the operations you want to do, that would be the time to close the client.

from node-screenlogic.

pgregg88 avatar pgregg88 commented on June 3, 2024

@parnic I'm monitoring for and then publishing changes 24x7. Currently, I open and close connection for just about every discrete action. I likely consume a lot more resource on open and closing connections vs the actual work I do.

Is it bad practice to leave a connection open until the app closes? Thanks.

from node-screenlogic.

mikemucc avatar mikemucc commented on June 3, 2024

@pgregg88 So I see you got the setPoint set, but were you able to figure out how to set the Heater to Active/Inactive on a per circuit basis?

from node-screenlogic.

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.