Coder Social home page Coder Social logo

Comments (7)

luebbe avatar luebbe commented on August 16, 2024

Yes, that's nice.
One suggestion concerning the "reverse" logic in your relaynode implementation. Why don't you make relayOnValue and relayOffValue uint8_t variables and set them in the constructor? You would get rid of the two functions.

from homie-node-collection.

ivanfmartinez avatar ivanfmartinez commented on August 16, 2024

I have changed the logic to use the variables.

from homie-node-collection.

luebbe avatar luebbe commented on August 16, 2024

Hi @ivanfmartinez , what is your intention behind the timeout implementation? How is it supposed to work? You didn't document anything and from looking at it and my current testing, it's buggy.

from homie-node-collection.

ivanfmartinez avatar ivanfmartinez commented on August 16, 2024

The timeout is working in my devices.

The timeout define maximum time (in seconds) the relay will stay active.

The timeout attribute in the class will have the time when the relay should be deactivated.

The timeout property receives number of seconds to keep the relay active.

The loop method is responsible to check with uptime object to control this.

from homie-node-collection.

luebbe avatar luebbe commented on August 16, 2024

Maybe it's working for you as you intended, but from the implementation it is not clear how it is supposed to work. ;)

Some points are not clear to me:

  • When you send a value to timeout/set, is the relay supposed to turn on for timeout seconds immediately or not at all?
    Is this value going to be used when you send true to on/set?
  • When you send true to on/set, is the relay supposed to turn on for timeout seconds or until you send false?
  • When you send a numeric value to on/set, is this going to turn on the relay and set the new timeout value?
  • You can send negative values to timeout/set and on/set and your implementation accepts them.
  • The relay will turn off after timeout seconds, but the timeout value posted to mqtt topic contains a value relative to the current uptime of the relay. What use does this value have for other nodes (whatever)?

I'd like to to document the timeout feature and the settings in readme.md, but the description has to be correct.

from homie-node-collection.

ivanfmartinez avatar ivanfmartinez commented on August 16, 2024

If you send an integer greather than zero for "timeout" property and the relay is on it will change the time for the relay be in on state for the number of seconds received (5 will keep the relay on for 5 seconds since the message is received)
https://github.com/ivanfmartinez/homie-node-collection/blob/18b90f9b984bbd605f0a98f4e7afde7de0c0caaf/src/RelayNode.cpp#L65

If you send true for "on" property it will go on and use the relayOnLimit or globalOnLimit if defined with values greather than zero.
If you send integer for "on" property it will go on and use the integer received as the time in seconds to keep relay on (since message was received).
https://github.com/ivanfmartinez/homie-node-collection/blob/18b90f9b984bbd605f0a98f4e7afde7de0c0caaf/src/RelayNode.cpp#L51

The current implementation does no check for negative values, considering the current logic using negative numbers will make the timeout to expire and the relay will be turned off..

from homie-node-collection.

luebbe avatar luebbe commented on August 16, 2024

Done using a slightly different approach in ac38d3b

from homie-node-collection.

Related Issues (4)

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.