StateMachine now supports attributes for states

This commit is contained in:
Paulus Schoutsen committed 2013-10-24 07:57:08 +01:00
1 parent c1819e19a4
commit 66d432d0a2
4 files changed
+38 -19

No files matched your search

+12 -4
View File
@@ -110,7 +110,7 @@ class RequestHandler(BaseHTTPRequestHandler):
write(("<table><tr>"
"<th>Name</th><th>State</th>"
"<th>Last Changed</th></tr>"))
"<th>Last Changed</th><th>Attributes</th></tr>"))
for category in \
sorted(self.server.statemachine.categories,
@@ -120,9 +120,17 @@ class RequestHandler(BaseHTTPRequestHandler):
state = self.server.statemachine.get_state(category)
write("<tr><td>{}</td><td>{}</td><td>{}</td></tr>".
format(category, state.state,
util.datetime_to_str(state.last_changed)))
attributes = "<br>".join(
["{}: {}".format(attr, state.attributes[attr])
for attr in state.attributes])
write(("<tr>"
"<td>{}</td><td>{}</td><td>{}</td><td>{}</td>"
"</tr>").
format(category,
state.state,
util.datetime_to_str(state.last_changed),
attributes))
write("</table>")