Node2Tv Device Node example
# Only required for placeholder status function | |
import random | |
def TurnOn(arg = None): | |
print("Turning Tv On") | |
print("Turning Tv On function not yet implemented. Doing nothing...") | |
UpdateStatus(); | |
def UpdateStatus(arg = None): | |
print('TV Status: Status requested') | |
print('UpdateStatus function not yet implemented, emiting random message...') | |
if(random.choice([True, False])): | |
message = {'message': 'ok'} | |
else: | |
message = {'message': 'not ok: randomly generated status is not okay...'} | |
lookup_local_event("TvStatus").emit(message) | |
statusMetadata = {'Group': 'Status', 'schema': | |
{'title': '', 'type': 'array', 'items': | |
{'type': 'object', 'properties': | |
{ | |
'message': {'type': 'string'}, | |
} | |
} | |
}} | |
def main(arg = None): | |
print("Node started...") | |
create_local_action("TurnOn", TurnOn, None) | |
statusMetadata['schema']['title'] = 'TvStatus' | |
create_local_event("TvStatus", statusMetadata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment