Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rachio] Initial contribution #10434

Closed
wants to merge 7 commits into from

Conversation

markus7017
Copy link
Contributor

This binding integrates Rachio sprinkler controllers. The binding uses the Rachio Cloud API. Event callback can be configured to utilized myopenhab.org as a proxy.

@markus7017 markus7017 requested a review from a team as a code owner April 2, 2021 14:31
@markus7017 markus7017 added the new binding If someone has started to work on a binding. For a new binding PR. label Apr 2, 2021
@markus7017 markus7017 added this to the 3.1 milestone Apr 2, 2021
@markus7017 markus7017 self-assigned this Apr 2, 2021
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/rachio-smart-sprinkler-controller/7078/352

@robnielsen
Copy link
Contributor

@markus7017, I'm trying out the rachio binding, and noticed some messages getting logged with INFO. These will need to be changed to debug or higher.

Thing rachio:zone:1:XXXXXXXXXXXX-5 "Rachio zone 5" @ "Sprinkler"
Thing rachio:zone:1:XXXXXXXXXXXX-6 "Rachio zone 6" @ "Sprinkler"
Thing rachio:zone:1:XXXXXXXXXXXX-7 "Rachio zone 7" @ "Sprinkler"
Thing rachio:zone:1:XXXXXXXXXXXX-8 "Rachio zone 8" @ "Sprinkler"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing the following in openhab.log with my 8 zone rachio:

2021-04-13 12:47:27.271 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'rachio.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>

@NonNullByDefault
public class RachioDiscoveryService extends AbstractDiscoveryService implements DiscoveryService, ThingHandlerService {

private static final int DISCOVERY_REFRESH_SEC = 900;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary every 15 minutes? Once a controller is configured why does this need to continually occur?

logger.info("Zone#{} '{}' (id={}) added, enabled={}", zone.zoneNumber, zone.name, zone.id,
zone.getEnabled());

if (zone.getEnabled() == OnOffType.ON) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all zones be added, even if they are currently be disabled? The zones can be ignored in the inbox if needed.

// register thing if it not already exists
ThingUID zoneThingUID = new ThingUID(THING_TYPE_ZONE, bridgeUID, zone.getThingID());
zone.setUID(devThingUID, zoneThingUID);
logger.info("Zone#{} '{}' (id={}) added, enabled={}", zone.zoneNumber, zone.name, zone.id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

.withLabel(dev.name + "[" + zone.zoneNumber + "]: " + zone.name).build();
thingDiscovered(zoneDiscoveryResult);
} else {
logger.info("Zone#{} '{}' is disabled, skip thing creation", zone.name, zone.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}
}
}
logger.info("{}  Rachio device initialized.", deviceList.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

// register thing if it not already exists
ThingUID devThingUID = new ThingUID(THING_TYPE_DEVICE, bridgeUID, dev.getThingID());
dev.setUID(bridgeUID, devThingUID);
logger.info(" Rachio device discovered: '{}' (id {}), S/N={}, MAC={}", dev.name, dev.id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info(" Rachio device discovered: '{}' (id {}), S/N={}, MAC={}", dev.name, dev.id,
dev.serialNumber, dev.macAddress);
logger.debug(" latitude={}, longitude={}", dev.latitude, dev.longitude);
logger.info(" device status={}, paused/sleep={}, on={}", dev.status, dev.getSleepMode(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

zone.setEvent(evt, getTimestamp()); // and funnel all zone events to the device
if (event.type.equals("ZONE_STATUS")) {
if (event.zoneRunStatus.state.equals("ZONE_STARTED")) {
logger.info("{}: Zone {} STARTED watering ({}).", thingId, zoneName, event.timestamp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Zone {} STARTED watering ({}).", thingId, zoneName, event.timestamp);
updateChannel(CHANNEL_ZONE_RUN, OnOffType.ON);
} else if (event.subType.equals("ZONE_STOPPED") || event.subType.equals("ZONE_COMPLETED")) {
logger.info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

event.durationInMinutes, event.flowVolume);
updateChannel(CHANNEL_ZONE_RUN, OnOffType.OFF);
} else {
logger.info("{}: Event for zone {}: {} (status={}, duration = {}sec)", thingId, event.zoneName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}
update = true;
} else if (event.subType.equals("ZONE_DELTA")) {
logger.info("{}: DELTA Event for zone {}: {}.{}", thingId, zone.name, event.category, event.action);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}
}

logger.info("RachioCloud: Connector initialized");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

RachioDevice checkDev = de.getValue();
RachioDevice dev = deviceList.get(checkDev.id);
if (dev == null) {
logger.info("RachioCloud: New device detected: {} - {}", checkDev.id, checkDev.name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}

public void shutdown() {
logger.info("RachioCloud: Shutting down");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}
} else if (channel.equals(RachioBindingConstants.CHANNEL_DEVICE_STOP)) {
if (command == OnOffType.ON) {
logger.info("STOP watering for device '{}'", dev.name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

}
} else if (channel.equals(RachioBindingConstants.CHANNEL_DEVICE_RAIN_DELAY)) {
if (command instanceof DecimalType) {
logger.info("Start rain delay cycle for {} sec", command.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

if (checkApi.getLastApiResult().isRateLimitWarning()) {
skipCalls++;
if (skipCalls % RACHIO_RATE_SKIP_CALLS > 0) {
logger.info("RachioCloud: API limit is getting critical -> skip update ({} / {})", skipCalls,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

// RAIN_SENSOR_DETECTION_ON, RAIN_SENSOR_DETECTION_OFF, RAIN_DELAY_ON, RAIN_DELAY_OFF
logger.debug("Device {} ('{}') changed to status '{}'.", d.name, d.id, event.subType);
if (event.subType.equals("COLD_REBOOT")) {
logger.info("{}: Device {} was restarted, ip={}/{}, gw={}, dns={}/{}, wifi rssi={}.", thingId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

dev.setNetwork(event.network);
}
} else if (event.subType.equals("ONLINE")) {
logger.info("{}: Device is ONLINE.", thingId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Device is ONLINE.", thingId);
dev.setStatus(event.subType);
} else if (event.subType.equals("OFFLINE") || event.subType.equals("OFFLINE_NOTIFICATION")) {
logger.info("{}: Device is OFFLINE (subType = '{}').", thingId, event.subType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Device is OFFLINE (subType = '{}').", thingId, event.subType);
dev.setStatus(event.subType);
} else if (event.subType.equals("SLEEP_MODE_ON")) {
logger.info("{}: Device switch to sleep mode.", thingId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Device reporterd Rain Delay ON.", thingId);
update = false; // details missing
} else if (event.subType.equals("RAIN_DELAY_OFF")) {
logger.info("{}: Device reporterd Rain Delay OFF.", thingId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Device reporterd Rain Delay OFF.", thingId);
update = false; // details missing
} else if (event.subType.equals("RAIN_SENSOR_DETECTION_ON")) {
logger.info("{}: Device reporterd a Rain Sensor ON.", thingId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

logger.info("{}: Device reporterd a Rain Sensor ON.", thingId);
update = false; // details missing
} else if (event.subType.equals("RAIN_SENSOR_DETECTION_ON")) {
logger.info("{}: Device reporterd Rain Sensor OFF.", thingId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

update = false; // details missing
}
} else if (event.type.equals("SCHEDULE_STATUS")) {
logger.info("{}: Status {} for schedule {}: {} (start={}, end={}, duration={}min)", thingId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.debug

TimeUnit.SECONDS);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing:

    @Override
    protected void stopBackgroundDiscovery() {
        logger.debug("Stopping background discovery for new Rachio controllers");
        if (discoveryJob != null) {
            discoveryJob.cancel(true);
            discoveryJob = null;
        }
    }

Signed-off-by: Markus Michels <markus7017@gmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
myopenhab.org)

Signed-off-by: Markus Michels <markus7017@gmail.com>
properties

Signed-off-by: Markus Michels <markus7017@gmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
@kaikreuzer
Copy link
Member

@markus7017 Did you see @robnielsen's review comments?

@wborn wborn removed this from the 3.1 milestone Jun 28, 2021
@fwolter fwolter added the awaiting feedback Awaiting feedback from the pull request author label Jul 25, 2021
@fwolter
Copy link
Member

fwolter commented Dec 11, 2021

@markus7017 Did you see @kaikreuzer's question if you saw @robnielsen comments?

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting PR status according to pending review comments.

@lolodomo
Copy link
Contributor

lolodomo commented Jun 11, 2022

Marked as "stale", last activity was 14 months ago and there were unfortunately no answers to review comments.

@lolodomo lolodomo added the stale As soon as a PR is marked stale, it can be removed 6 months later. label Jun 11, 2022
@markus7017
Copy link
Contributor Author

Hi gusy, sorry. I set other priorities, but just some people asked for OH 3.3 support so I'll work on this shortly

@markus7017 markus7017 removed awaiting feedback Awaiting feedback from the pull request author stale As soon as a PR is marked stale, it can be removed 6 months later. labels Jul 8, 2022
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.1.0-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<version>3.1.0-SNAPSHOT</version>
<version>3.4.0-SNAPSHOT</version>

Signed-off-by: Markus Michels <markus7017@gmail.com>
@wborn wborn added the awaiting feedback Awaiting feedback from the pull request author label Nov 5, 2022
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

See #11833

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.4.0-SNAPSHOT</version>
Copy link
Member

@wborn wborn Dec 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<version>3.4.0-SNAPSHOT</version>
<version>4.2.0-SNAPSHOT</version>

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be adapted to the new addon.xml, the PR to adapt the developer docs is not merged yet, so if you need more details, the corresponding issue is here: openhab/openhab-core#2058
But you can also update your branch and look at another binding's addon.xml and adapt it to this initial contribution.

@lsiepel
Copy link
Contributor

lsiepel commented Dec 29, 2023

This PR is 2,5 years old. In #10434 (comment) @markus7017 (PR author) commented that his priorities have changed. Now (over a year later) the status quo has not changed. As this PR needs some work (review, fixes etc), i don't think some one else will bring it to a mergable state.
If ever needed it can be re-opened at any time.

@lsiepel lsiepel closed this Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting feedback from the pull request author new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants