Skip to content

Instantly share code, notes, and snippets.

@DaleGia
Created March 10, 2019 13:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DaleGia/fa5c573e2777fa65de77e705ae936e84 to your computer and use it in GitHub Desktop.
Node3Dvd Device Node example
# Only required for placeholder status function
import random
def TurnOn(arg = None):
print("Turning Dvd On")
print("Turning Dvd On function not yet implemented. Doing nothing...")
UpdateStatus();
def UpdateStatus(arg = None):
print('Dvd 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("DvdStatus").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'] = 'DvdStatus'
create_local_event("DvdStatus", statusMetadata)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment