Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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...")
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'}
message = {'message': 'not ok: randomly generated status is not okay...'}
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