Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to Dynamodb #22

Open
hounded opened this issue Jan 10, 2019 · 3 comments
Open

Write to Dynamodb #22

hounded opened this issue Jan 10, 2019 · 3 comments

Comments

@hounded
Copy link

hounded commented Jan 10, 2019

This is a bit odd and may require me forking but worth raising anyho, what about the option to write to a dynamodb, as I keep a list of my device in a device-table for access via appsync and user mapping

something like

DynamoTable: gen-devices
       # in __init__
        self._dynamodb = s.resource('dynamodb')

        # in create
        if 'DynamoTable' in self.group:
            self._create_table_entry()

    #create table function
    def _create_table_entry(self):
        thingTable = self._dynamodb.Table(self.group['tables']['thingTable'])
        self.group['thing']['id'] = self.id
        thingTable.put_item(
            Item=self.thing
        )

Also while on odd user cases, the name for your group, anychance this could be auto generated, as we will deploy to potential thousands of devices and save adjusting the yaml everytime

something like

# in __init__
        self.state = _load_state()
        if self.state:
            self.uuid = self.state['id']
        else:
            self.uuid = str(uuid.uuid4())
        self.name = "G"+self.uuid
# in create 
        self.state['id'] = self.uuid

Just some ideas, I can fork when you finish v2 but it would be nice to keep using the original repo

@hounded hounded changed the title Write to Dynamodd Write to Dynamodb Jan 10, 2019
@hounded
Copy link
Author

hounded commented Jan 12, 2019

happy to make pull requests on both issues if you are interested

@dzimine
Copy link
Owner

dzimine commented Jan 28, 2019

I'd look at solving your case differently. Given you want to use device info from appsync, you could 1) use IoT API to query device shadows or 2) populate dynamoDB on MQTT triggers when device is deployed, with IoT rules.

What I think we DO need to add here is rule definitions right in greengo.yaml.

@hounded
Copy link
Author

hounded commented Feb 1, 2019

Yeah I do save readings from a device with IoT rules, but on init I save out my device config to dynamodb, that way I can map cognito users against devices they register to (also I can save third party integration settings against a device in dynamodb allowing a user to configure there devices). The "save reading" IoT Lambda action references the dynamodb device to pick up any third party integrations and calls corresponding lambdas if required when saving a reading. You are right though, I would very much like to incorporate device shadow when setting set points and calibration data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants