Visualization TileBoard for ioBroker
MIT License
WEB visualisation for ioBroker platform based on TileBoard for Home Assistant. Big thanks to Alexey Ivanov.
TileBoard creates 3 variables:
Commands:
Message;;info
.If user changes the view or at start the variables will be filled by TileBoard with
You can write the JSON-string or Object into control.command as {instance: 'AABBCCDD', command: 'cmd', data: 'ddd'}
. In this case the instance and data will be taken from JSON object.
To get more settings for alert you can send following structure to adjust every parameter of the notification popup from script adapter.
setState('tileboard.0.control.command', JSON.stringify({
command: "alert",
instance: "*",
data: {
"icon": "mdi-car", // Material icon
"type": "info", // Type: info, warning, error, success
"title": "Information", // Header of the message
"message": "Hello world", // Text of the message
"lifetime": 5, // Seconds
}
}));
How to merge the original repository into this one:
Following files were change:
/index.html
- added ../tileboard.0/custom.css
, ../../lib/js/socket.io.js
, ./_socket/info.js
and scripts/vendors/conn.js
, removed styles/custom.css
/scripts/models/api.js
- completely replaced/scripts/controllers/main.js
-Extended function getItemEntity
:
$scope.getItemEntity = function (item) {
if(typeof item.id === "object") return item.id;
if(!(item.id in $scope.states)) { // IoB
if (typeof Api.getState === 'function') {
Api.getState(item.id);
} else {
warnUnknownItem(item);
}
return null;
}
return $scope.states[item.id];
};
added function setNewStates
:
// IoB - required for lazy load of the states, becasue every update of the single state cause the request of all states again.
// To avoid that all states must be updated at once and only then updateView should be called.
function setNewStates (states) {
states.forEach(function (state) {
if(!$scope.states[state.entity_id]) $scope.states[state.entity_id] = state.new_state;
// Is it required? If $scope.states[key] just assigned?
for(var k in state.new_state) $scope.states[state.entity_id][k] = state.new_state[k];
});
}
Modified function:
function handleEvent (event) {
try {
if (event.event_type === "state_changed") {
debugLog('state change', event.data.entity_id, event.data.new_state);
if (event.data instanceof Array) { // IoB
setNewStates(event.data);
event.data.forEach(function (state) {
checkStatesTriggers(state.entity_id, state.new_state);
});
} else {
setNewState(event.data.entity_id, event.data.new_state);
checkStatesTriggers(event.data.entity_id, event.data.new_state);
}
}
else if (event.event_type === "tileboard") {
debugLog('tileboard', event.data);
triggerEvents(event.data);
}
}
catch (e) {console.error(e);}
updateView();
}
At the end:
if(CONFIG.pingConnection !== false) {
=>
if (CONFIG.pingConnection) { // Changed for IoB
/styles/main.less(css)
@media screen and (max-height: 770px) { // IoB
.header {
display: none;
}
}
Copyright (c) 2019-2020 bluefox [email protected]
MIT License