-
Notifications
You must be signed in to change notification settings - Fork 8
/
const.py
144 lines (130 loc) · 2.72 KB
/
const.py
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
"""Constants for the FMI Weather and Sensor integrations."""
import logging
from datetime import timedelta
_LOGGER = logging.getLogger(__package__)
DOMAIN = "hslhrt"
NAME = DEFAULT_NAME = "HSLHRT"
MANUFACTURER = "Helsinki Regional Transport Authority"
COORDINATOR = "coordinator"
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
UNDO_UPDATE_LISTENER = "undo_update_listener"
BASE_URL = "https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql"
NAME_CODE = "user_name_code"
STOP_CODE = "stop_code"
STOP_NAME = "stop_name"
STOP_GTFS = "stop_gtfs"
ROUTE = "route"
ROUTE_DEST = "route_destination"
DESTINATION = "destination"
ALL = "all"
ERROR = "err"
# Graphql variables
VAR_NAME_CODE = "name_code"
VAR_ID = "id"
VAR_SECS_LEFT = "sec_left_in_day"
VAR_CURR_EPOCH = "current_epoch"
VAR_LIMIT = "limit"
# Dict keys
DICT_KEY_ROUTE = "route"
DICT_KEY_ROUTES = "routes"
DICT_KEY_DEST = "destination"
DICT_KEY_ARRIVAL = "arrival"
ATTR_ROUTE = "ROUTE"
ATTR_DEST = "DESTINATION"
ATTR_ARR_TIME = "ARRIVAL TIME"
ATTR_STOP_NAME = "STOP NAME"
ATTR_STOP_CODE = "STOP CODE"
ATTR_STOP_GTFS = "GTFS ID"
ATTRIBUTION = "Data provided by Helsinki Regional Transport(HSL HRT)"
LIMIT = 1500
SECS_IN_DAY = 24*60*60
STOP_ID_QUERY = """
query ($name_code: String!) {
stops (name: $name_code) {
gtfsId
name
code
routes {
shortName
patterns {
headsign
}
}
}
}
"""
STOP_CHECK_QUERY = """
query ($id: String!) {
stop (id: $id) {
name
code
routes {
shortName
}
}
}
"""
ROUTE_QUERY_WITH_RANGE = """
query ($id: String!, $current_epoch: Long!, $sec_left_in_day: Int!) {
stop (id: $id) {
name
code
gtfsId
routes {
shortName
patterns {
headsign
}
}
stoptimesWithoutPatterns (startTime: $current_epoch, numberOfDepartures: 500, timeRange: $sec_left_in_day){
scheduledArrival
realtimeArrival
arrivalDelay
scheduledDeparture
realtimeDeparture
departureDelay
realtime
realtimeState
serviceDay
headsign
trip {
route {
shortName
}
}
}
}
}
"""
ROUTE_QUERY_WITH_LIMIT = """
query ($id: String!, $current_epoch: Long!, $limit: Int!) {
stop (id: $id) {
name
code
gtfsId
routes {
shortName
patterns {
headsign
}
}
stoptimesWithoutPatterns (startTime: $current_epoch, numberOfDepartures: $limit){
scheduledArrival
realtimeArrival
arrivalDelay
scheduledDeparture
realtimeDeparture
departureDelay
realtime
realtimeState
serviceDay
headsign
trip {
route {
shortName
}
}
}
}
}
"""