Skip to content

Commit 812eb65

Browse files
authored
Merge pull request #66 from kaulketh/develop
update: grouping, hardware.md, changelog.md
2 parents 81c455b + e60a285 commit 812eb65

File tree

6 files changed

+143
-90
lines changed

6 files changed

+143
-90
lines changed

CHANGELOG

-4
This file was deleted.

CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
6+
## [v1.6.1](https://github.com/kaulketh/greenhouse/tree/v1.6.1) - 2019-03-16
7+
### changes
8+
* imports improved
9+
10+
## [v1.6](https://github.com/kaulketh/greenhouse/tree/v1.6) - 2019-03-16
11+
### added
12+
* feature grouping
13+
* [#31](https://github.com/kaulketh/greenhouse/issues/31) resolved
14+
### changes
15+
* minor code changes
16+
17+
## [1.5.3](https://github.com/kaulketh/greenhouse/tree/1.5.3) - 2019-02-13
18+
## [1.5.2]
19+
## [1.5.1]
20+
### changes
21+
* minor improvements and changes
22+
23+
## [1.5](https://github.com/kaulketh/greenhouse/tree/1.5) - 2019-02-11
24+
### added
25+
* emergency stop implemented
26+
* [#39](https://github.com/kaulketh/greenhouse/issues/39) resolved
27+
28+
### changes
29+
* start/stop standby timer improved
30+
* code refactored and some minor changes

bot/conf/lib_english.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# messages
4343
msg_grouping = '`Grouping, please select`'
44-
msg_grouping_selection = '`Selection: {}`'
44+
msg_grouping_selection = '`Selected group {}`'
4545
msg_live = '[Click here for the live stream]({})'
4646
msg_temperature = '`{}Current values\n{}, {}\n{}`'
4747
msg_welcome = '`Hello {}!`'

bot/conf/lib_german.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
# messages
4545
msg_grouping = '`Gruppierung, bitte auswählen!`'
46-
msg_grouping_selection = '`Auswahl: {}`'
46+
msg_grouping_selection = '`Ausgewählte Gruppe {}`'
4747
msg_live = '[Hier gehts zum Live Stream]({})'
4848
msg_temperature = '`{}Aktuelle Werte\n{}, {}\n{}`'
4949
msg_welcome = '`Hallo {}!`'

bot/greenhouse.py

+69-66
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __start(bot, update):
112112
return SELECTION
113113

114114

115-
# set the target, member of group or group
115+
# select targets
116116
def __selection(bot, update):
117117
global target
118118
target = update.message.text
@@ -148,10 +148,74 @@ def __selected_target(bot, update, selected_target):
148148
logger.info('Selection: {0}'.format(str(selected_target)))
149149
__start_standby_timer(bot, update)
150150
return DURATION
151-
# end: set targets
151+
# end: select targets
152152

153153

154-
# set water duration
154+
# [#31] grouping
155+
def __grouping(bot, update, chat_data):
156+
global selection
157+
query = update.callback_query
158+
btn_click = str(query.data)
159+
160+
if not (btn_click == str(lib.btn_finished) or btn_click == str(lib.cancel)):
161+
if not selection.__contains__(int(btn_click)):
162+
selection += (int(btn_click),)
163+
bot.edit_message_text(text=lib.msg_grouping_selection.format(selection),
164+
chat_id=query.message.chat_id,
165+
message_id=query.message.message_id,
166+
parse_mode=ParseMode.MARKDOWN,
167+
reply_markup=reply_markup)
168+
169+
elif btn_click == str(lib.btn_finished) and len(selection) > 0:
170+
global target
171+
target = lib.grouping
172+
bot.edit_message_text(text=lib.msg_grouping_selection.format(selection),
173+
chat_id=query.message.chat_id,
174+
message_id=query.message.message_id,
175+
parse_mode=ParseMode.MARKDOWN)
176+
bot.send_message(text=lib.msg_duration.format(target + str(selection)),
177+
chat_id=query.message.chat_id,
178+
parse_mode=ParseMode.MARKDOWN,
179+
reply_markup=markup2)
180+
logger.info('Selected: {0} {1}'.format(str(target), str(selection)))
181+
return DURATION
182+
183+
elif btn_click == lib.cancel:
184+
selection = ()
185+
bot.delete_message(chat_id=query.message.chat_id,
186+
message_id=query.message.message_id)
187+
bot.send_message(text=lib.msg_new_choice,
188+
chat_id=query.message.chat_id,
189+
parse_mode=ParseMode.MARKDOWN,
190+
reply_markup=markup1)
191+
return SELECTION
192+
193+
194+
def __group_menu(bot, update):
195+
global selection
196+
selection = ()
197+
logger.info('Grouping mode called.')
198+
inline_keyboard = [
199+
[__get_btn(lib.group1[1], conf.RELAIS_01), __get_btn(lib.group1[2], conf.RELAIS_02),
200+
__get_btn(lib.group1[3], conf.RELAIS_03), __get_btn(lib.group3[1], conf.RELAIS_04)],
201+
[__get_btn(lib.group3[2], conf.RELAIS_05), __get_btn(lib.group2[1], conf.RELAIS_06),
202+
__get_btn(lib.group2[2], conf.RELAIS_07), __get_btn(lib.group2[3], conf.RELAIS_08)],
203+
[InlineKeyboardButton(lib.btn_finished, callback_data=lib.btn_finished),
204+
InlineKeyboardButton(lib.btn_cancel, callback_data=lib.btn_cancel)]
205+
]
206+
207+
global reply_markup
208+
reply_markup = InlineKeyboardMarkup(inline_keyboard)
209+
update.message.reply_text(lib.msg_grouping, reply_markup=reply_markup, parse_mode=ParseMode.MARKDOWN)
210+
return GROUPING
211+
212+
213+
def __get_btn(text, callback):
214+
return InlineKeyboardButton('{0} ({1})'.format(text, callback), callback_data=callback)
215+
# end: grouping
216+
217+
218+
# water duration
155219
def __duration(bot, update):
156220
global water_time
157221
global g_duration_update
@@ -230,6 +294,7 @@ def __duration(bot, update):
230294

231295
__start_standby_timer(bot, update)
232296
return SELECTION
297+
# end: duration
233298

234299

235300
# watering targets
@@ -393,68 +458,6 @@ def __cam_off():
393458
# end: camera
394459

395460

396-
# [#31] grouping
397-
def __push_button(bot, update, chat_data):
398-
global selection
399-
query = update.callback_query
400-
added_selection = str(query.data)
401-
402-
if not (added_selection == str(lib.btn_finished) or added_selection == str(lib.cancel)):
403-
if not selection.__contains__(int(added_selection)):
404-
selection += (int(added_selection),)
405-
bot.edit_message_text(text=lib.msg_grouping_selection.format(selection),
406-
chat_id=query.message.chat_id,
407-
message_id=query.message.message_id,
408-
parse_mode=ParseMode.MARKDOWN,
409-
reply_markup=reply_markup)
410-
411-
elif added_selection == str(lib.btn_finished) and len(selection) > 0:
412-
global target
413-
target = lib.grouping
414-
bot.delete_message(chat_id=query.message.chat_id,
415-
message_id=query.message.message_id)
416-
bot.send_message(text=lib.msg_duration.format(target),
417-
chat_id=query.message.chat_id,
418-
parse_mode=ParseMode.MARKDOWN,
419-
reply_markup=markup2)
420-
logger.info('Grouped selection: {0} {1}'.format(str(target), str(selection)))
421-
return DURATION
422-
423-
elif added_selection == lib.cancel:
424-
selection = ()
425-
bot.delete_message(chat_id=query.message.chat_id,
426-
message_id=query.message.message_id)
427-
bot.send_message(text=lib.msg_new_choice,
428-
chat_id=query.message.chat_id,
429-
parse_mode=ParseMode.MARKDOWN,
430-
reply_markup=markup1)
431-
return SELECTION
432-
433-
434-
def __group_menu(bot, update):
435-
global selection
436-
selection = ()
437-
logger.info('Grouping mode called.')
438-
inline_keyboard = [
439-
[__get_btn(lib.group1[1], conf.RELAIS_01), __get_btn(lib.group1[2], conf.RELAIS_02),
440-
__get_btn(lib.group1[3], conf.RELAIS_03), __get_btn(lib.group3[1], conf.RELAIS_04)],
441-
[__get_btn(lib.group3[2], conf.RELAIS_05), __get_btn(lib.group2[1], conf.RELAIS_06),
442-
__get_btn(lib.group2[2], conf.RELAIS_07), __get_btn(lib.group2[3], conf.RELAIS_08)],
443-
[InlineKeyboardButton(lib.btn_finished, callback_data=lib.btn_finished),
444-
InlineKeyboardButton(lib.btn_cancel, callback_data=lib.btn_cancel)]
445-
]
446-
447-
global reply_markup
448-
reply_markup = InlineKeyboardMarkup(inline_keyboard)
449-
update.message.reply_text(lib.msg_grouping, reply_markup=reply_markup, parse_mode=ParseMode.MARKDOWN)
450-
return GROUPING
451-
452-
453-
def __get_btn(text, callback):
454-
return InlineKeyboardButton('{0} ({1})'.format(text, callback), callback_data=callback)
455-
# end: grouping
456-
457-
458461
def main():
459462
__init_bot_set_pins()
460463

@@ -486,7 +489,7 @@ def main():
486489
DURATION: [RegexHandler('^([0-9]+|{0}|{1})$'.format(str(lib.cancel), str(lib.panic)), __duration),
487490
RegexHandler('^{0}$'.format(lib.stop_bot), __stop)],
488491

489-
GROUPING: [CallbackQueryHandler(__push_button, pass_chat_data=True),
492+
GROUPING: [CallbackQueryHandler(__grouping, pass_chat_data=True),
490493
RegexHandler('^({0}|{1}|{2})$'.format(
491494
str(lib.cancel), str(lib.btn_finished), str(selection)),
492495
__selection)]

hardware/HARDWARE.md

+42-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
1-
### Casing
1+
# Overview of used and built in hardware
2+
3+
## Casing
24
* [Spelsberg AK24 | 73542401](https://www.spelsberg.de/nc/produkt/an/73542401/)
35

4-
### Raspberry Pi
5-
* [Raspberry Pi 3 Model B ARM-Cortex-A53 4x 1,2GHz, 1GB RAM, WLAN, Bluetooth, LAN, 4x USB](https://www.amazon.de/Raspberry-Pi-Model-ARM-Cortex-A53-Bluetooth/dp/B01CD5VC92)
6+
## Raspberry Pi
7+
* [Raspberry Pi 3 Model B](https://www.amazon.de/Raspberry-Pi-Model-ARM-Cortex-A53-Bluetooth/dp/B01CD5VC92)
68
* micro SD card 8GB
7-
8-
### Raspberry Pi housing
9-
* [RPI-BC 107,6 DEV-KIT KMGY | 2202874](https://www.phoenixcontact.com/online/portal/de?uri=pxc-oc-itemdetail:pid=2202874&library=dede&tab=1)
10-
11-
### Power supply Raspberry Pi
9+
* [Cooler and fan](https://www.amazon.de/gp/product/B07JGNF5F8/ref=ppx_yo_dt_b_asin_title_o02_s02?ie=UTF8&psc=1)
10+
* Raspberry Pi housing
11+
* [RPI-BC 107,6 DEV-KIT KMGY | 2202874](https://www.phoenixcontact.com/online/portal/de?uri=pxc-oc-itemdetail:pid=2202874&library=dede&tab=1)
12+
* [OLED DisplayIC2 096" 128x64](https://www.amazon.de/gp/product/B00NHKM1C0/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1)
13+
* to display state and several values
14+
* [4 digits 7 segment display IC2](https://www.amazon.de/AZDelivery-Digital-Display-Arduino-Raspberry/dp/B06X952QXS/ref=pd_rhf_ee_p_img_12?_encoding=UTF8&refRID=175F6J4SEV7W0YBYNSCF&th=1)
15+
* to show time, state, channel
16+
* [Camera module](https://www.amazon.de/gp/product/B07CMXJLXR/ref=ppx_yo_dt_b_asin_title_o08_s00?ie=UTF8&psc=1)
17+
18+
## Power supply Raspberry Pi
1219
* [Indexa DR1505, 5VDC max. 2,4A | 32212](https://www.indexa.de/w2/datenblatt/32212_datenblatt.pdf)
1320

14-
### Power supply 24VDC for valves
21+
## Power supply 24VDC for valves
1522
* [Wago EPSITRON COMPACT Power, 24VDC 6A | 787-1226](https://www.wago.com/de/stromversorgungen/primaer-getaktete-stromversorgung/p/787-1226)
1623

17-
### Relay card to control valves
18-
* i.e. tinxi 8 channel relay modul 5VDC
19-
* https://www.amazon.de/8-Kanal-Optokoppler-8-Channel-Arduino-Raspberry/dp/B00AEIDWXK
20-
* https://www.amazon.de/gp/product/B01C2IN2U2/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
24+
## Relay card to control valves
25+
* [i.e. any 8 channel low level relay modul 5VDC](https://www.amazon.de/8-Kanal-Optokoppler-8-Channel-Arduino-Raspberry/dp/B00AEIDWXK)
26+
* [also this ](https://www.amazon.de/gp/product/B01C2IN2U2/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1)
27+
* [or this](https://www.amazon.de/gp/product/B07CT7SLYQ/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1)
28+
29+
## Power connectors, plugs and sockets for valves
30+
* [Socket Phoenix Contact 1411605](https://www.phoenixcontact.com/online/portal/de?uri=pxc-oc-itemdetail:pid=1411605&library=dede&tab=1)
31+
* [Plug Phoenix Contact 1404641](https://phoenixcontact.de/online/portal/de/?uri=pxc-oc-itemdetail:pid=1404641&library=usen&pcck=P-20-07-06-01&tab=2&selectedCategory=ALL)
32+
33+
## Moisture and temperature sensor
34+
* [DHT22 AM2302](https://www.amazon.de/gp/product/B07CMXJLXR/ref=ppx_yo_dt_b_asin_title_o08_s00?ie=UTF8&psc=1)
35+
36+
## Adapter and output connectors
37+
* [Network adapter RJ45](https://www.amazon.de/gp/product/B07CMXJLXR/ref=ppx_yo_dt_b_asin_title_o08_s00?ie=UTF8&psc=1)
38+
* to get network connection outside the main casing
39+
* [USB 2.0 adapter](https://www.amazon.de/gp/product/B07CMXJLXR/ref=ppx_yo_dt_b_asin_title_o08_s00?ie=UTF8&psc=1)
40+
* to get an USB connection outside the main casing
41+
42+
## Some impressions
43+
Please refer other [images](./images) also!
44+
45+
![./images/20181201_101949.jpg](./images/20181201_101949.jpg)
46+
47+
![./images/20190202_152448.jpg](./images/20190202_152448.jpg)
2148

49+
![./images/20190202_152457.jpg](./images/20190202_152457.jpg)
2250

23-
### Power connectors, plugs and sockets for valves
24-
* [SACC-E-M12FSS-4P-M16XL/0,5 PE | 1411605](https://www.phoenixcontact.com/online/portal/de?uri=pxc-oc-itemdetail:pid=1411605&library=dede&tab=1)
25-
* [ACC-M12MSS-3PECON-PG11-M | 1404641](https://phoenixcontact.de/online/portal/de/?uri=pxc-oc-itemdetail:pid=1404641&library=usen&pcck=P-20-07-06-01&tab=2&selectedCategory=ALL)
51+
![./images/20190202_154306.jpg](./images/20190202_154306.jpg)
2652

27-
### USB and network adapter/output connectors
28-
....
2953

0 commit comments

Comments
 (0)