Skip to content

Commit

Permalink
blockly plugin: fix deprecated block definition
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Oct 25, 2023
1 parent 36db8ce commit 72761f0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
12 changes: 6 additions & 6 deletions blockly/webif/static/shblocks/sh_items.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Blockly.Blocks['sh_item_obj'] = {
}
};

Blockly.Python['sh_item_obj'] = function(block) {
python.pythonGenerator.forBlock['sh_item_obj'] = function(block) {
var iName = block.getFieldValue('N');
var iPath = block.getFieldValue('P');

Expand Down Expand Up @@ -84,7 +84,7 @@ Blockly.Python['sh_item_obj'] = function(block) {
},
};
Blockly.Python['sh_item'] = function(block) {
python.pythonGenerator.forBlock['sh_item'] = function(block) {
// Variable getter.
var code = 'sh.' + block.getFieldValue('ITEM');
return [code, Blockly.Python.ORDER_ATOMIC];
Expand All @@ -108,7 +108,7 @@ Blockly.Blocks['sh_item_get'] = {
}
};

Blockly.Python['sh_item_get'] = function(block) {
python.pythonGenerator.forBlock['sh_item_get'] = function(block) {
var itemobj = Blockly.Python.valueToCode(block, 'ITEMOBJECT', Blockly.Python.ORDER_ATOMIC) || 'item';
var code = itemobj + '.property.value';
return [code, Blockly.Python.ORDER_NONE];
Expand All @@ -135,7 +135,7 @@ Blockly.Blocks['sh_item_set'] = {
}
};

Blockly.Python['sh_item_set'] = function(block) {
python.pythonGenerator.forBlock['sh_item_set'] = function(block) {
var itemobject = Blockly.Python.valueToCode(block, 'ITEMOJECT', Blockly.Python.ORDER_ATOMIC) || 'item';
var value = Blockly.Python.valueToCode(block, 'VALUE', Blockly.Python.ORDER_ATOMIC) || '0';
// TODO: Assemble Python into code variable.
Expand All @@ -161,7 +161,7 @@ Blockly.Blocks['sh_item_hasattr'] = {
}
};

Blockly.Python['sh_item_hasattr'] = function(block) {
python.pythonGenerator.forBlock['sh_item_hasattr'] = function(block) {
var value_item = Blockly.Python.valueToCode(block, 'ITEM', Blockly.Python.ORDER_ATOMIC);
var text_attr = block.getFieldValue('ATTR');
// TODO: Assemble Python into code variable.
Expand Down Expand Up @@ -197,7 +197,7 @@ Blockly.Blocks['sh_item_attr'] = {
}
};
Blockly.Python['sh_item_attr'] = function(block) {
python.pythonGenerator.forBlock['sh_item_attr'] = function(block) {
var dropdown_attr = block.getFieldValue('ATTR');
var value_item = Blockly.Python.valueToCode(block, 'ITEM', Blockly.Python.ORDER_ATOMIC);
// TODO: Assemble Python into code variable.
Expand Down
11 changes: 5 additions & 6 deletions blockly/webif/static/shblocks/sh_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Blockly.Blocks['shlogic_by'] = {
this.setTooltip('');
}
};
Blockly.Python['shlogic_by'] = function(block) {
python.pythonGenerator.forBlock['shlogic_by'] = function(block) {
var code = "trigger['by']";
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
Expand All @@ -43,7 +43,7 @@ Blockly.Blocks['shlogic_value'] = {
this.setTooltip('');
}
};
Blockly.Python['shlogic_value'] = function(block) {
python.pythonGenerator.forBlock['shlogic_value'] = function(block) {
var code = "trigger['value']";
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
Expand All @@ -63,7 +63,7 @@ Blockly.Blocks['shlogic_source'] = {
this.setTooltip('');
}
};
Blockly.Python['shlogic_source'] = function(block) {
python.pythonGenerator.forBlock['shlogic_source'] = function(block) {
var code = "trigger['source']";
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
Expand All @@ -83,7 +83,7 @@ Blockly.Blocks['shlogic_dest'] = {
this.setTooltip('');
}
};
Blockly.Python['shlogic_dest'] = function(block) {
python.pythonGenerator.forBlock['shlogic_dest'] = function(block) {
var code = "trigger['dest']";
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
Expand All @@ -107,11 +107,10 @@ Blockly.Blocks['shlogic_trigger'] = {
this.setTooltip('');
}
};
Blockly.Python['shlogic_trigger'] = function(block) {
python.pythonGenerator.forBlock['shlogic_trigger'] = function(block) {
var value_datetime = Blockly.Python.valueToCode(block, 'DATETIME', Blockly.Python.ORDER_ATOMIC);
// TODO: Assemble Python into code variable.
var code = '...';
return code;
};
*/

12 changes: 6 additions & 6 deletions blockly/webif/static/shblocks/sh_logics.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function NextLevel(trigger_block, logicname, ignore_crontab, ignore_watchitem)
};
};

Blockly.Python['sh_logic_main'] = function(block)
python.pythonGenerator.forBlock['sh_logic_main'] = function(block)
{
this.data = 'sh_logic_main'
var trigger_block = block.getChildren();
Expand Down Expand Up @@ -323,7 +323,7 @@ Blockly.Blocks['sh_trigger_item'] = {
}
};

Blockly.Python['sh_trigger_item'] = function(block)
python.pythonGenerator.forBlock['sh_trigger_item'] = function(block)
{
var code = '';
return code;
Expand Down Expand Up @@ -360,7 +360,7 @@ Blockly.Blocks['sh_trigger_cycle'] = {
}
};

Blockly.Python['sh_trigger_cycle'] = function(block) {
python.pythonGenerator.forBlock['sh_trigger_cycle'] = function(block) {
var code = ''
return code;
};
Expand Down Expand Up @@ -396,7 +396,7 @@ Blockly.Blocks['sh_trigger_sun'] = {
}
};

Blockly.Python['sh_trigger_sun'] = function(block)
python.pythonGenerator.forBlock['sh_trigger_sun'] = function(block)
{
var code = '';
return code;
Expand Down Expand Up @@ -437,7 +437,7 @@ Blockly.Blocks['sh_trigger_daily'] = {
}
};

Blockly.Python['sh_trigger_daily'] = function(block)
python.pythonGenerator.forBlock['sh_trigger_daily'] = function(block)
{
var code = '';
return code;
Expand Down Expand Up @@ -469,7 +469,7 @@ Blockly.Blocks['sh_trigger_init'] = {
}
};

Blockly.Python['sh_trigger_init'] = function(block)
python.pythonGenerator.forBlock['sh_trigger_init'] = function(block)
{
var code = '';
return code;
Expand Down
5 changes: 2 additions & 3 deletions blockly/webif/static/shblocks/sh_notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Blockly.Blocks['shnotify_email'] = {
this.setTooltip('');
}
};
Blockly.Python['shnotify_email'] = function(block) {
python.pythonGenerator.forBlock['shnotify_email'] = function(block) {
var to = block.getFieldValue('TO');
var subject = block.getFieldValue('SUBJECT');
var text = Blockly.Python.valueToCode(block, 'TO', Blockly.Python.ORDER_ATOMIC);
Expand Down Expand Up @@ -71,7 +71,7 @@ Blockly.Blocks['shnotify_nma'] = {
this.setTooltip('');
}
};
Blockly.Python['shnotify_nma'] = function(block) {
python.pythonGenerator.forBlock['shnotify_nma'] = function(block) {
var text_subject = block.getFieldValue('SUBJECT');
var value_text = Blockly.Python.valueToCode(block, 'TEXT', Blockly.Python.ORDER_ATOMIC);
// TODO: Assemble Python into code variable.
Expand All @@ -92,4 +92,3 @@ Blockly.Blocks['shnotify_pushbullit'] = {
this.appendDummyInput().appendField('Sende Nachricht mit Pushbullit:');
},
};

7 changes: 3 additions & 4 deletions blockly/webif/static/shblocks/sh_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Blockly.Blocks['shtime_now'] = {
this.setTooltip('');
}
};
Blockly.Python['shtime_now'] = function(block) {
python.pythonGenerator.forBlock['shtime_now'] = function(block) {
// var code = 'sh.now()';
var code = 'sh.shtime.now()';
// TODO: Change ORDER_NONE to the correct strength.
Expand Down Expand Up @@ -61,7 +61,7 @@ Blockly.Blocks['shtime_time'] = {
}
};

Blockly.Python['shtime_time'] = function(block) {
python.pythonGenerator.forBlock['shtime_time'] = function(block) {
var text_time = block.getFieldValue('TIME');
var code = 'datetime.strptime("'+text_time+'", "%H:%M")';
// TODO: Change ORDER_NONE to the correct strength.
Expand Down Expand Up @@ -89,7 +89,7 @@ Blockly.Blocks['shtime_sunpos'] = {
this.setTooltip('');
}
};
Blockly.Python['shtime_sunpos'] = function(block) {
python.pythonGenerator.forBlock['shtime_sunpos'] = function(block) {
var delta = Blockly.Python.valueToCode(block, 'DELTA', Blockly.Python.ORDER_ATOMIC);
var aa = block.getFieldValue('AA');
var pm = block.getFieldValue('PM');
Expand Down Expand Up @@ -120,4 +120,3 @@ Blockly.Blocks['shtime_auto'] = {
this.appendDummyInput().appendField('Autotimer:');
},
};

9 changes: 4 additions & 5 deletions blockly/webif/static/shblocks/sh_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Blockly.Blocks['shtools_logger'] = {
this.setTooltip('');
}
};
Blockly.Python['shtools_logger'] = function(block) {
python.pythonGenerator.forBlock['shtools_logger'] = function(block) {
var loglevel = block.getFieldValue('LOGLEVEL').toLowerCase();
var logtext = Blockly.Python.valueToCode(block, 'LOGTEXT', Blockly.Python.ORDER_NONE) || '\'\'';
var code = "logger." + loglevel + "(" + logtext + ")\n";
Expand All @@ -54,7 +54,7 @@ Blockly.Blocks['shtools_dewpoint'] = {
this.setTooltip('');
}
};
Blockly.Python['shtools_dewpoint'] = function(block) {
python.pythonGenerator.forBlock['shtools_dewpoint'] = function(block) {
var value_hum = Blockly.Python.valueToCode(block, 'HUM', Blockly.Python.ORDER_ATOMIC);
var value_temp = Blockly.Python.valueToCode(block, 'TEMP', Blockly.Python.ORDER_ATOMIC);
var code = 'sh.tools.dewpoint(' + value_temp + ', ' + value_hum + ')';
Expand All @@ -78,7 +78,7 @@ Blockly.Blocks['shtools_fetchurl'] = {
this.setTooltip('');
}
};
Blockly.Python['shtools_fetchurl'] = function(block) {
python.pythonGenerator.forBlock['shtools_fetchurl'] = function(block) {
var text_url = block.getFieldValue('URL');
var code = 'sh.tools.fetch_url("' + text_url + '")' ;
// TODO: Change ORDER_NONE to the correct strength.
Expand All @@ -104,12 +104,11 @@ Blockly.Blocks['shtools_fetchurl2'] = {
this.setTooltip('');
}
};
Blockly.Python['shtools_fetchurl2'] = function(block) {
python.pythonGenerator.forBlock['shtools_fetchurl2'] = function(block) {
var text_url = block.getFieldValue('URL');
var text_user = block.getFieldValue('USER');
var text_password = block.getFieldValue('PASSWORD');
var code = 'sh.tools.fetch_url("' + text_url + '", "' + text_user + '", "' + text_password + '")';
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

0 comments on commit 72761f0

Please sign in to comment.