Changed names
parent
8e097a426b
commit
b0b9292568
16
README.md
16
README.md
|
@ -89,7 +89,7 @@ Then status messages will be posted to the sub topics listed below, with appropi
|
|||
sprinklerd/zone/1
|
||||
sprinklerd/zall
|
||||
sprinklerd/24hdelay
|
||||
sprinklerd/system
|
||||
sprinklerd/calendar
|
||||
```
|
||||
|
||||
To turn something on, or set information, simply add `set` to the end of the above topics, and post 1 or 0 in the message for a button. Topics sprinklerd will act on.
|
||||
|
@ -98,12 +98,13 @@ Turn stuff on/off (1 is on, 0 is off, but can use txt if you want)
|
|||
sprinklerd/zone/1/set 1
|
||||
sprinklerd/zone/zall/set 1 // Cycle all zones using default runtimes.
|
||||
sprinklerd/24hdelay/set 1
|
||||
sprinklerd/system/set 1
|
||||
sprinklerd/calendar/set 1
|
||||
```
|
||||
|
||||
|
||||
## All other hubs (excluding Apple HomeKit) Amazon,Samsung,Google etc
|
||||
Create a device for each piece of pool equiptment you have, eg Filter Pump, Spa Mode, Pool Light, Cleaner. Then add the following URL to program the switching of each device
|
||||
Obviously details will be diferent on each device, and I won't document them all. Basic idea is create a switch for item you want to control (zone(s), 24hdelay, calendar schedule etc). Then add the following URL to program the switching of each device.
|
||||
If you use a hub on you local lan like smartthings, then this is super simple. If you use cloud only device, like Alexa then you need to make a connection from your lan to amazon cloud since you should not put this web interface on the internet (since there is no security). There are 1001 ways to do this, but a MQTT bridge may be the easiest, search `MQTT to <my cloud-based hub> bridge` and pick one you like.
|
||||
```
|
||||
http://sprinklerd.ip.address:port?type=option&option=24hdelay&state=off
|
||||
```
|
||||
|
@ -114,17 +115,18 @@ http://sprinklerd.ip.address:port?type=option&option=24hdelay&state=off
|
|||
<host>?type=json // JSON full array style, need full parser to pass.
|
||||
|
||||
* // Cfg options
|
||||
<host>?type=option&option=24hdelay&state=off // turn off 24h delay
|
||||
<host>?type=option&option=calendar&state=off // turn off calendar
|
||||
<host>?type=option&option=24hdelay&state=off // turn off 24h delay
|
||||
<host>?type=option&option=24hdelay&state=reset // reset time on 24h delay
|
||||
<host>?type=option&option=24hdelay&state=reset&time=1529328782 // reset custom time on delay (utime in seconds)
|
||||
|
||||
* // Calendar
|
||||
<host>?type=calcfg&day=3&zone=&time=07:00 // Use default water zone times
|
||||
<host>?type=calcfg&day=2&zone=1&time=7 // Change water zone time
|
||||
<host>?type=calcfg&day=3&zone=&time=07:00 // Add day schedule and use default water zone times
|
||||
<host>?type=calcfg&day=2&zone=1&time=7 // Change water zone time (0 time is off)
|
||||
<host>?type=calcfg&day=3&zone=&time= // Delete day schedule
|
||||
|
||||
* // Run options
|
||||
<host>?type=option&option=allz&state=on // Run all zones default times
|
||||
<host>?type=option&option=allz&state=on // Run all zones default times (ignore 24h delay & calendar settings)
|
||||
<host>?type=zone&zone=2&state=on&runtime=3 // Run zone 2 for 3 mins (ignore 24h delay & calendar settings)
|
||||
<host>?type=zrtcfg&zone=2&time=10 // change zone 2 default runtime to 10
|
||||
<host>?type=cron&zone=1&runtime=12' // Run zone 1 for 12 mins (calendar & 24hdelay settings overide this request)
|
||||
|
|
8
config.c
8
config.c
|
@ -55,7 +55,7 @@ void write_cache() {
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf(fp, "%d\n", _sdconfig_.system);
|
||||
fprintf(fp, "%d\n", _sdconfig_.calendar);
|
||||
fprintf(fp, "%d\n", _sdconfig_.delay24h);
|
||||
fprintf(fp, "%li\n", _sdconfig_.delay24h_time);
|
||||
for (zone=1; zone <= _sdconfig_.zones; zone ++) {
|
||||
|
@ -80,8 +80,8 @@ void read_cache() {
|
|||
}
|
||||
while (EOF != fscanf (fp, "%d", &i)) {
|
||||
if (c == 0){
|
||||
_sdconfig_.system = i;
|
||||
logMessage(LOG_DEBUG, "Read System '%s' from cache\n", _sdconfig_.system?"ON":"OFF");
|
||||
_sdconfig_.calendar = i;
|
||||
logMessage(LOG_DEBUG, "Read calendar '%s' from cache\n", _sdconfig_.calendar?"ON":"OFF");
|
||||
} else if (c == 1){
|
||||
_sdconfig_.delay24h = i;
|
||||
logMessage(LOG_DEBUG, "Read delay24h '%s' from cache\n", _sdconfig_.delay24h?"ON":"OFF");
|
||||
|
@ -234,7 +234,7 @@ void readCfg(char *inifile)
|
|||
logMessage (LOG_DEBUG,"Config mqtt 'disabeled'\n");
|
||||
}
|
||||
|
||||
_sdconfig_.dzidx_system = ini_getl("SPRINKLERD", "DZIDX_SYSTEM", 0, inifile);
|
||||
_sdconfig_.dzidx_calendar = ini_getl("SPRINKLERD", "DZIDX_CALENDAR", 0, inifile);
|
||||
_sdconfig_.dzidx_24hdelay = ini_getl("SPRINKLERD", "DZIDX_24HDELAY", 0, inifile);
|
||||
_sdconfig_.dzidx_allzones = ini_getl("SPRINKLERD", "DZIDX_ALL_ZONES", 0, inifile);
|
||||
_sdconfig_.dzidx_status = ini_getl("SPRINKLERD", "DZIDX_STATUS", 0, inifile);
|
||||
|
|
4
config.h
4
config.h
|
@ -66,7 +66,7 @@ struct sprinklerdcfg {
|
|||
char mqtt_dz_sub_topic[50];
|
||||
char mqtt_dz_pub_topic[50];
|
||||
char mqtt_ID[MQTT_ID_LEN];
|
||||
int dzidx_system;
|
||||
int dzidx_calendar;
|
||||
int dzidx_24hdelay;
|
||||
int dzidx_allzones;
|
||||
int dzidx_status;
|
||||
|
@ -74,7 +74,7 @@ struct sprinklerdcfg {
|
|||
bool enableMQTTaq;
|
||||
int zones;
|
||||
//int pincfgs;
|
||||
bool system;
|
||||
bool calendar;
|
||||
bool delay24h;
|
||||
long delay24h_time;
|
||||
bool master_valve;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"Sprinklerd System": {
|
||||
"Sprinklerd Calendar": {
|
||||
"id": "SprinklerdCalendar",
|
||||
"name": "Calendar",
|
||||
"manufacturer": "Feakes Inc",
|
||||
|
@ -35,8 +35,8 @@
|
|||
"name": "Calendar",
|
||||
"service": "Switch",
|
||||
"topic": {
|
||||
"setOn": "sprinklerd/system/set",
|
||||
"statusOn": "sprinklerd/system"
|
||||
"setOn": "sprinklerd/calendar/set",
|
||||
"statusOn": "sprinklerd/calendar"
|
||||
},
|
||||
"payload": {
|
||||
"onTrue": 1,
|
||||
|
|
|
@ -53,9 +53,9 @@ int build_sprinkler_JSON(char* buffer, int size)
|
|||
else
|
||||
status[0] = '\0';
|
||||
|
||||
length += sprintf(buffer+length, "{ \"title\" : \"%s\",\"system\" : \"%s\", \"24hdelay\" : \"%s\", \"allz\" : \"%s\", \"zones\" : \"%d\", \"24hdelay-offtime\" : %li, \"status\" : \"%s\"",
|
||||
length += sprintf(buffer+length, "{ \"title\" : \"%s\",\"calendar\" : \"%s\", \"24hdelay\" : \"%s\", \"allz\" : \"%s\", \"zones\" : \"%d\", \"24hdelay-offtime\" : %li, \"status\" : \"%s\"",
|
||||
_sdconfig_.name,
|
||||
_sdconfig_.system?"on":"off",
|
||||
_sdconfig_.calendar?"on":"off",
|
||||
_sdconfig_.delay24h?"on":"off",
|
||||
_sdconfig_.currentZone.type==zcALL?"on":"off",
|
||||
_sdconfig_.zones,
|
||||
|
@ -84,8 +84,8 @@ int build_advanced_sprinkler_JSON(char* buffer, int size)
|
|||
memset(&buffer[0], 0, size);
|
||||
int length = 0;
|
||||
|
||||
length += sprintf(buffer+length, "{ \"title\" : \"%s\",\"system\" : \"%s\", \"24hdelay\" : \"%s\", \"allz\" : \"%s\", \"#zones\" : %d, \"24hdelay-offtime\" : %li",
|
||||
_sdconfig_.name, _sdconfig_.system?"on":"off",
|
||||
length += sprintf(buffer+length, "{ \"title\" : \"%s\",\"calendar\" : \"%s\", \"24hdelay\" : \"%s\", \"allz\" : \"%s\", \"#zones\" : %d, \"24hdelay-offtime\" : %li",
|
||||
_sdconfig_.name, _sdconfig_.calendar?"on":"off",
|
||||
_sdconfig_.delay24h?"on":"off",
|
||||
_sdconfig_.currentZone.type==zcALL?"on":"off",
|
||||
_sdconfig_.zones,
|
||||
|
|
|
@ -225,7 +225,7 @@ int sprinklerdstatus(char *status, int length)
|
|||
struct tm * timeinfo = localtime (&_sdconfig_.delay24h_time);
|
||||
strftime (status,length,"24h delay: end time %a %I:%M%p",timeinfo);
|
||||
return 3;
|
||||
} else if (_sdconfig_.system == true) {
|
||||
} else if (_sdconfig_.calendar == true) {
|
||||
sprintf(status,"Calendar schedule");
|
||||
return 2;
|
||||
} else {
|
||||
|
@ -299,8 +299,8 @@ void broadcast_sprinklerdstate(struct mg_connection *nc)
|
|||
}
|
||||
if (is_mqtt(c)) {
|
||||
if (_sdconfig_.enableMQTTaq == true) {
|
||||
sprintf(mqtt_topic, "%s/system", _sdconfig_.mqtt_topic);
|
||||
sprintf(mqtt_msg, "%s", (_sdconfig_.system?MQTT_ON:MQTT_OFF) );
|
||||
sprintf(mqtt_topic, "%s/calendar", _sdconfig_.mqtt_topic);
|
||||
sprintf(mqtt_msg, "%s", (_sdconfig_.calendar?MQTT_ON:MQTT_OFF) );
|
||||
send_mqtt_msg(c, mqtt_topic, mqtt_msg);
|
||||
sprintf(mqtt_topic, "%s/24hdelay", _sdconfig_.mqtt_topic);
|
||||
sprintf(mqtt_msg, "%s", (_sdconfig_.delay24h?MQTT_ON:MQTT_OFF) );
|
||||
|
@ -313,8 +313,8 @@ void broadcast_sprinklerdstate(struct mg_connection *nc)
|
|||
send_mqtt_msg(c, mqtt_topic, mqtt_msg);
|
||||
}
|
||||
if (_sdconfig_.enableMQTTdz == true) {
|
||||
if (_sdconfig_.dzidx_system > 0 && update_dz_cache(_sdconfig_.dzidx_system,(_sdconfig_.system==true ? DZ_ON : DZ_OFF) )) {
|
||||
build_dz_mqtt_status_JSON(mqtt_msg, 50, _sdconfig_.dzidx_system, (_sdconfig_.system==true ? DZ_ON : DZ_OFF), TEMP_UNKNOWN);
|
||||
if (_sdconfig_.dzidx_calendar > 0 && update_dz_cache(_sdconfig_.dzidx_calendar,(_sdconfig_.calendar==true ? DZ_ON : DZ_OFF) )) {
|
||||
build_dz_mqtt_status_JSON(mqtt_msg, 50, _sdconfig_.dzidx_calendar, (_sdconfig_.calendar==true ? DZ_ON : DZ_OFF), TEMP_UNKNOWN);
|
||||
send_mqtt_msg(c, _sdconfig_.mqtt_dz_pub_topic, mqtt_msg);
|
||||
}
|
||||
if (_sdconfig_.dzidx_24hdelay > 0 && update_dz_cache(_sdconfig_.dzidx_24hdelay,(_sdconfig_.delay24h==true ? DZ_ON : DZ_OFF) )) {
|
||||
|
@ -392,15 +392,9 @@ int serve_web_request(struct mg_connection *nc, struct http_message *http_msg, c
|
|||
} else if (strcmp(buf, "option") == 0) {
|
||||
//logMessage(LOG_DEBUG, "WEB REQUEST option %s\n",buf);
|
||||
mg_get_http_var(&http_msg->query_string, "option", buf, buflen);
|
||||
if (strncasecmp(buf, "system", 6) == 0 ) {
|
||||
if (strncasecmp(buf, "calendar", 6) == 0 ) {
|
||||
mg_get_http_var(&http_msg->query_string, "state", buf, buflen);
|
||||
enable_system(is_value_ON(buf));
|
||||
/*
|
||||
if ( is_value_ON(buf) )
|
||||
_sdconfig_.system = true;
|
||||
else
|
||||
_sdconfig_.system = false;
|
||||
*/
|
||||
enable_calendar(is_value_ON(buf));
|
||||
length = build_sprinkler_JSON(buffer, size);
|
||||
} else if (strncasecmp(buf, "24hdelay", 8) == 0 ) {
|
||||
mg_get_http_var(&http_msg->query_string, "state", buf, buflen);
|
||||
|
@ -408,7 +402,8 @@ int serve_web_request(struct mg_connection *nc, struct http_message *http_msg, c
|
|||
if (val == true || val == false) {
|
||||
enable_delay24h(val);
|
||||
} else if (strncasecmp(buf, "reset", 5) == 0) {
|
||||
reset_delay24h_time();
|
||||
mg_get_http_var(&http_msg->query_string, "time", buf, buflen);
|
||||
reset_delay24h_time(atoi(buf));
|
||||
}
|
||||
length = build_sprinkler_JSON(buffer, size);
|
||||
} else if (strncasecmp(buf, "allz", 8) == 0 ) {
|
||||
|
@ -548,11 +543,11 @@ void action_domoticz_mqtt_message(struct mg_connection *nc, struct mg_mqtt_messa
|
|||
if (parseJSONmqttrequest(msg->payload.p, msg->payload.len, &idx, &nvalue, svalue)) {
|
||||
if (check_dz_cache(idx, nvalue))
|
||||
return;
|
||||
if (idx == _sdconfig_.dzidx_system) {
|
||||
if (idx == _sdconfig_.dzidx_calendar) {
|
||||
//_sdconfig_.system=(nvalue==DZ_ON?true:false);
|
||||
enable_system(nvalue==DZ_ON?true:false);
|
||||
enable_calendar(nvalue==DZ_ON?true:false);
|
||||
//_sdconfig_.eventToUpdateHappened = true;
|
||||
logMessage(LOG_INFO, "Domoticz MQTT request to turn %s system",(nvalue==DZ_ON?"ON":"OFF"));
|
||||
logMessage(LOG_INFO, "Domoticz MQTT request to turn %s calendar",(nvalue==DZ_ON?"ON":"OFF"));
|
||||
} else if (idx == _sdconfig_.dzidx_24hdelay) {
|
||||
enable_delay24h((nvalue==DZ_ON?true:false));
|
||||
logMessage(LOG_INFO, "Domoticz MQTT request to turn %s 24hDelay",(nvalue==DZ_ON?"ON":"OFF"));
|
||||
|
@ -627,10 +622,10 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg){
|
|||
} else if (pt2 != NULL && pt3 != NULL && strncmp(pt2, "24hdelay", 8) == 0 && strncmp(pt3, "set", 3) == 0 ) {
|
||||
enable_delay24h(status==zcON?true:false);
|
||||
logMessage(LOG_DEBUG, "MQTT: Enable 24 hour delay %s\n",status==zcON?"YES":"NO");
|
||||
} else if (pt2 != NULL && pt3 != NULL && strncmp(pt2, "system", 6) == 0 && strncmp(pt3, "set", 3) == 0 ) {
|
||||
} else if (pt2 != NULL && pt3 != NULL && strncmp(pt2, "calendar", 6) == 0 && strncmp(pt3, "set", 3) == 0 ) {
|
||||
//_sdconfig_.system=status==zcON?true:false;
|
||||
enable_system(status==zcON?true:false);
|
||||
logMessage(LOG_DEBUG, "MQTT: Turning System %s\n",status==zcON?"ON":"OFF");
|
||||
enable_calendar(status==zcON?true:false);
|
||||
logMessage(LOG_DEBUG, "MQTT: Turning calendar %s\n",status==zcON?"ON":"OFF");
|
||||
} else if (pt2 != NULL && pt3 != NULL && strncmp(pt2, "cycleallzones", 13) == 0 && strncmp(pt3, "set", 3) == 0 ) {
|
||||
zc_zone(zcALL, 0, status, 0);
|
||||
logMessage(LOG_DEBUG, "MQTT: Cycle all zones %s\n",status==zcON?"ON":"OFF");
|
||||
|
|
Binary file not shown.
|
@ -15,7 +15,7 @@ LOG_LEVEL = NOTICE
|
|||
#MQTT_DZ_PUB_TOPIC = domoticz/in
|
||||
#MQTT_DZ_SUB_TOPIC = domoticz/out
|
||||
|
||||
#DZIDX_SYSTEM = 197
|
||||
#DZIDX_CALENDAR = 197
|
||||
#DZIDX_24HDELAY = 198
|
||||
#DZIDX_ALL_ZONES = 199
|
||||
|
||||
|
|
24
sd_cron.c
24
sd_cron.c
|
@ -22,11 +22,11 @@ bool check_delay24h()
|
|||
return false;
|
||||
}
|
||||
|
||||
void enable_system(bool state)
|
||||
void enable_calendar(bool state)
|
||||
{
|
||||
if (_sdconfig_.system != state) {
|
||||
if (_sdconfig_.calendar != state) {
|
||||
_sdconfig_.eventToUpdateHappened = true;
|
||||
_sdconfig_.system = state;
|
||||
_sdconfig_.calendar = state;
|
||||
logMessage(LOG_NOTICE, "Turning %s calendar\n",state==true?"on":"off");
|
||||
} else {
|
||||
logMessage(LOG_NOTICE, "Ignore request to turn %s calendar\n",state==true?"on":"off");
|
||||
|
@ -52,16 +52,24 @@ void enable_delay24h(bool state)
|
|||
}
|
||||
}
|
||||
|
||||
void reset_delay24h_time()
|
||||
void reset_delay24h_time(unsigned long dtime)
|
||||
{
|
||||
if (_sdconfig_.delay24h != true) {
|
||||
_sdconfig_.eventToUpdateHappened = true;
|
||||
}
|
||||
|
||||
_sdconfig_.delay24h = true;
|
||||
time(&_sdconfig_.delay24h_time);
|
||||
_sdconfig_.delay24h_time = _sdconfig_.delay24h_time + DELAY24H_SEC;
|
||||
logMessage(LOG_NOTICE, "Reset rain Delay\n");
|
||||
time_t now;
|
||||
time(&now);
|
||||
if (dtime > now) {
|
||||
_sdconfig_.delay24h = true;
|
||||
_sdconfig_.delay24h_time = dtime;
|
||||
logMessage(LOG_NOTICE, "Reset rain Delay custom time\n");
|
||||
} else {
|
||||
_sdconfig_.delay24h = true;
|
||||
time(&_sdconfig_.delay24h_time);
|
||||
_sdconfig_.delay24h_time = _sdconfig_.delay24h_time + DELAY24H_SEC;
|
||||
logMessage(LOG_NOTICE, "Reset rain Delay\n");
|
||||
}
|
||||
}
|
||||
|
||||
void check_cron() {
|
||||
|
|
|
@ -13,6 +13,6 @@ void read_cron();
|
|||
void enable_delay24h(bool state);
|
||||
bool check_delay24h();
|
||||
void reset_delay24h_time();
|
||||
void enable_system(bool state);
|
||||
void enable_calendar(bool state);
|
||||
|
||||
#endif // SD_CRON_H_
|
||||
|
|
|
@ -143,7 +143,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
logMessage(LOG_NOTICE,"Starting %s version %s\n",argv[0],SD_VERSION);
|
||||
|
||||
_sdconfig_.system = true;
|
||||
_sdconfig_.calendar = true;
|
||||
_sdconfig_.currentZone.type = zcNONE;
|
||||
_sdconfig_.cron_update = 0;
|
||||
_sdconfig_.eventToUpdateHappened = false;
|
||||
|
|
|
@ -412,8 +412,8 @@
|
|||
</td>
|
||||
<td>
|
||||
<div class='switch'>
|
||||
<input id='btn-toggle-system' name='system' class='btn-toggle btn-toggle-round' type='checkbox' onclick='update(this);'>
|
||||
<label for='btn-toggle-system'></label>
|
||||
<input id='btn-toggle-calendar' name='calendar' class='btn-toggle btn-toggle-round' type='checkbox' onclick='update(this);'>
|
||||
<label for='btn-toggle-calendar'></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -88,8 +88,8 @@ bool zc_zone(zcRunType type, int zone, zcState state, int length) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (type == zcCRON && state == zcON && (_sdconfig_.system == false || _sdconfig_.delay24h == true) ) {
|
||||
logMessage (LOG_WARNING, "Request to turn zone %d on. Ignored due to %s!\n",zone,_sdconfig_.delay24h?"Rain Delay active":"System off");
|
||||
if (type == zcCRON && state == zcON && (_sdconfig_.calendar == false || _sdconfig_.delay24h == true) ) {
|
||||
logMessage (LOG_WARNING, "Request to turn zone %d on. Ignored due to %s!\n",zone,_sdconfig_.delay24h?"Rain Delay active":"Calendar off");
|
||||
return false;
|
||||
// Check cal & 24hdelay, return if cal=false or 24hdelay=true
|
||||
} else if (type == zcALL) {
|
||||
|
|
Loading…
Reference in New Issue