-
Notifications
You must be signed in to change notification settings - Fork 0
/
duinocoin.yaml
130 lines (114 loc) · 4.33 KB
/
duinocoin.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
duinocoin:
### Auto stake, show balance, verification status, number of warnings ###
## in configuration.yaml ##
python_script:
requirements:
- requests
## in configuration.yaml ##
#---- sensors ----#
#---- Need to install Python Scipts Pro component ----#
#-- "Python Scipts Pro" is a custom component from AlexxIT (https://github.com/AlexxIT/PythonScriptsPro) --#
sensor:
- platform: python_script
name: DUCO balance
scan_interval: '00:10:00'
unit_of_measurement: DUCO
icon: mdi:currency-btc
source: |
import requests
response = requests.get('https://server.duinocoin.com/balances/<username>')
response.raise_for_status()
data = response.json()
balance= str(round(data['result']['balance'], 2))
self.state = balance
- platform: python_script
name: DUCO is verified
scan_interval: '00:30:00'
source: |
import requests
response = requests.get('https://server.duinocoin.com/balances/<username>')
response.raise_for_status()
data = response.json()
is_verified = str((data['result']['verified']))
self.state = is_verified
- platform: python_script
name: DUCO warnings
scan_interval: '00:15:05'
icon: mdi:weather-cloudy-alert
source: |
import requests
response = requests.get('https://server.duinocoin.com/balances/<username>')
response.raise_for_status()
data = response.json()
warnings = str((data['result']['warnings']))
self.state = warnings
- platform: python_script
name: DUCO stake_date_timestamp
scan_interval: '00:30:10'
icon: mdi:weather-cloudy-clock
source: |
import requests
response = requests.get('https://server.duinocoin.com/balances/<username>')
response.raise_for_status()
data = response.json()
stake_date_timestamp = str((data['result']['stake_date']))
self.state = stake_date_timestamp
template:
#---- Secret data ----#
- sensor:
- name: duco_user
state: !secret duco_user #your username in secrets.yaml
- name: duco_password
state: !secret duco_password #your password in secrets.yaml
#---- End stake sensor ----#
- binary_sensor:
- name: duco_stake_end
state: >
{% if utcnow () >= as_datetime(states('sensor.duco_stake_date_timestamp'))%}
on
{%else %}
off
{%endif%}
#---- Automations ----#
automation:
- id: 'duco_stake_done'
initial_state: true
alias: 'duco_stake_done'
trigger:
- platform: state
entity_id: binary_sensor.duco_stake_end
to: 'on'
condition: []
action:
- service: telegram_bot.send_message
data:
message: 'Staking is done! Next in 2 hours. Time: {{ states(''sensor.date_time'') }} '
mode: single
- id: 'duco_stake_start'
initial_state: true
alias: 'duco_stake_start'
trigger:
- platform: state
entity_id: binary_sensor.duco_stake_end
to: 'on'
condition:
- condition: state
entity_id: sensor.duco_is_verified
state: "yes"
action:
- delay: 02:00:00
- service: telegram_bot.send_message
data:
message: 'Sending coins to stake... Balance DUCO: {{ states(''sensor.duco_balance'') }} '
- delay: 00:00:02
- service: python_script.exec
data:
file: python_scripts/duco_stake.py
username: "{{ states('sensor.duco_user') }}"
password: "{{ states('sensor.duco_password') }}"
amount: "{{ states('sensor.duco_balance') | round(1) }}"
cache: false
- service: telegram_bot.send_message
data:
message: 'Staking started! Time: {{ states(''sensor.date_time'') }} '
mode: single