Closed pgregg88 closed 5 years ago
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.
Thanks I'm giving it a test this weekend. Really appreciate the guidance.
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.
Wow. You already implemented. Major thanks. This is great (and I'm learning from what you did). Thanks twice.
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.
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.
@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.
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.
@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?
I assume I need the equivalent of setCircuitState. Here's the function I'm using to turn the spa on (circuit ID 500) and then call getPoolState() to publish status to my network.
Thoughts?