Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Don't destroy attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Oct 1, 2018
1 parent 143de44 commit 96feda7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lovelace-fullykiosk.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,30 @@ var LovelaceFullyKiosk = LovelaceFullyKiosk || (function() {

_sendScreenState = function() {
let hass = document.querySelector('home-assistant').hass;
hass.callApi('post', "states/"+_screen, {
state: _screen_state?'on':'off',
attributes: {
let attr = Object.assign(hass.states[_screen].attributes, {
brightness: fully.getScreenBrightness()*255/170,
supported_features: 1,
battery_level: fully.getBatteryLevel(),
charging: fully.isPlugged(),
},
});
hass.callApi('post', "states/"+_screen, {
state: _screen_state?'on':'off',
attributes: attr,
});
}

_sendMotionState = function() {
clearTimeout(_sync_timer);
let timeout = _motion_state?5000:10000;
let hass = document.querySelector('home-assistant').hass;
hass.callApi('post', "states/"+_motion, {
state: _motion_state?'on':'off',
attributes: {
let attr = Object.assign(hass.states[_motion].attributes, {
battery_level: fully.getBatteryLevel(),
charging: fully.isPlugged(),
device_class: 'motion',
},
});
hass.callApi('post', "states/"+_motion, {
state: _motion_state?'on':'off',
attributes: attr,
});
_sendScreenState();
_sync_timer = setTimeout(() => {
Expand Down

0 comments on commit 96feda7

Please sign in to comment.