Coder Social home page Coder Social logo

pifou25 / scratch Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 101.93 MB

A Scratch extension for Jeedom API call

Home Page: https://pifou25.github.io/scratch/scratch/

License: Apache License 2.0

Shell 8.90% Dockerfile 1.77% JavaScript 89.32%
api extension jeedom jsonrpc scratch-vm

scratch's Introduction

Jeedom extension for Scratch

What is Scratch ?

Scratch is the world's largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization.

https://scratch.mit.edu/about

It is just a simple Javascript app you can run directly in your usual browser, nothing to install !

What is this extension used for ?

This extension add some new blocks to the Scratch program, to act with your lovely Jeedom box ! Using the Jeedom API, you can build some simple Scratch scenario that will light your home or check your bedroom temp...

Starting instructions

Try it here : https://pifou25.github.io/scratch/scratch/

Click on the bottom left icon to open the list of available extensions : Then, select the Jeedom extension

starting

You can now see some new blocks added at the bottom of the block list :

Jeedom blocks added

Befor you can start to play with your box, you need few configuration. Hopefully you can make it with new block too !

Get your Jeedom URL (just the root with protocol, e.g. https://your-jeedom-box.example.com ) and your API key. API key is in the menu Settings / System / Configuration / API. Copy the first one API key.

You can now drag & drop you first block that will initialize the URL and API key for future interactions.

Initialization

I added a first API call just after the init, to check that every things works well !

A custom block That can execute different commands according to the current state of the light :

Test your first custom block

Check the complete Json RPC API documentation for more custom blocks.

  • The API order is the one described into the doc. e.g. cmd::byId
  • The Json parameters are dependant of the selected API order. e.g. for cmd::byId it is the command id in json format : {"id":1655} For some commands, no parameters are required, so you should let the default empty json : {}
  • The 3rd parameter, optional, is the json path you want to read in the API response. Let it empty to read the full response content, then you will select the relevant part to return.

Now an example using the "listener" block : this bloc will 'listen' to some device at regular interval, and trigger if some change is detected.

Listenner

The 3 other custom blocks are to get and set some value into a json object. Every API response is a json object written into a variable. You can take it and read a path into the variable - get key from json object - or you can put a new value into a specific path of the json object - set key to value into json object - ... Finally you can count the number of elements of a json list.

json getter and setter

Development environment for creating unofficial Scratch extensions

I made it with Delane Scratch ext development

scratch's People

Contributors

pifou25 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.