Dashticz - General Discussions

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Locked
Wheeling
Posts: 7
Joined: Tuesday 02 May 2017 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Holland
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Wheeling »

htilburgs wrote:
Wheeling wrote:
htilburgs wrote:
Hi @htilburgs

Nice Dash
Can you share the iPhone script with us :)
I've been looking for it for a long time, but do not get it to work.

Thx
Bennie
Just send you a PM....
Thx man
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Derik »

you forgot the / after v2
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Trigun »

EdKo66 wrote:
Trigun wrote:Hi All,

first of all, what a great dashboard!
Allthough it looks amazing, I am not able to get it working and I can't see where it goed wrong.
I changed the CONFIG-DEFAULT.js with my IP adress and saved it as CONFIG.js after putting all the files in www/dashticzv2 folder.
tried to open http://192.168.1.94:8080/dashticzv2 but get an 404 error.

Am I overlooking something??

thanks in advance!
Perhaps you can share your CONFIG.js here. Are you sure the address is correct?
Hi EdKo66,

thnks for your reply.

the code of the CONFIG.js file is as follows:

Code: Select all

var _LANGUAGE 				= 'nl_NL'; //or: en_US, fr_FR, hu_HU
var _HOST_DOMOTICZ		  	= 'http://192.168.1.94:8080';
var _DOMOTICZ_REFRESH		= 5; //in seconds
var _DASHTICZ_REFRESH		= 30; //in minutes

/*
IF YOU HAVE A MEDIABOX FROM ZIGGO (HORIZON), COPY SWITCH_HORIZON.PHP ON A WEBSERVER INSIDE YOUR NETWORK AND CHANGE THE IP.
ENTER THE PATH TO THIS FILE BELOW.
*/
var _HOST_ZIGGO_HORIZON	  	= ''; //e.g. http://192.168.1.3/domoticz/switch_horizon.php';
var _APIKEY_WUNDERGROUND  	= '';
var _WEATHER_CITY 			= 'Eindhoven';
var _WEATHER_CITYNAME 		= ''; //show a different city name, leave empty if same as _WEATHER_CITY
var _WEATHER_COUNTRY 		= 'NL';
var _USE_AUTO_POSITIONING 	= true; //don't want to configure positions, use auto positioning
var _USE_FAVORITES			= true; //only used when using auto positioning
var _HIDE_SECONDS_IN_CLOCK  = false; //do not show the seconds in the clock
var _HIDE_MEDIAPLAYER_WHEN_OFF = false; //when you have a mediaplayer connected, hide it if nothing is playing
var _NEWS_RSSFEED			= 'http://www.nu.nl/rss/algemeen';
var _USE_FAHRENHEIT			= false;
var _USE_BEAUFORT 			= true; //Bft instead of m/s
var _TRANSLATE_SPEED 		= false; //windspeed, north northwest instead of NNW
var _STANDBY_AFTER_MINUTES  = false; //enter amount of minutes like: 5 (5 minutes)
var _SCROLL_NEWS_AFTER 		= 7000; //milliseconds, so 7000 is 7 seconds
var _SHOW_LASTUPDATE 		= true;
var _LASTUPDATE_FORMAT 		= 'DD-MM-YY HH:mm';
var _SCREENSLIDER_EFFECT 	= 'slide'; //'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'

var _APIKEY_MAPS			= '';
var _MAPS_LATITUDE			= '';
var _MAPS_LONGITUDE			= '';

var _AUTO_SWIPEBACK_TO		= 1; //when no activity, swipe back to main screen after x seconds
var _AUTO_SWIPEBACK_TIME	= 10; //seconds

// Online Radio Stream Plugin, Note: you must enable  plugin in column section 'streamplayer', see columns[3]['blocks'] example below.
var _STREAMPLAYER_TRACKS  	= [
								{"track":1,"name":"Music FM","file":"http://stream.musicfm.hu:8000/musicfm.mp3"},
								{"track":2,"name":"Radio 1","file":"http://213.181.210.106:8000/high.mp3"},
								{"track":3,"name":"Test FM","file":"http://213.181.210.106:8000/high.mp3"},
							  ]; 

// iCalendar Plugin, supports all .ics calendar types like Google Calendar, Apple Calendar
var _ICALENDAR_URL			= 'https://testurl.com/ical.ics'; //supports .ics type calendars (Google Calendar, Apple Calendar etc.)
var _ICALENDAR_DATEFORMAT	= 'friendly'; //'friendly', 'MM.DD.YYYY HH:mm', 'DD.MM.YYYY HH:mm', 'YYYY.MM.DD HH:mm'
var _ICALENDAR_LOCALE		= 'en'; //en,hu, etc. 

//Buttons or images to open webpages in an iframe, like a news website or weather forecast
var buttons = {}
buttons.buienradar = {width:12, isimage:true, refreshimage:60000, image: 'http://api.buienradar.nl/image/1.0/RadarMapNL?w=285&h=256', url: 'http://www.weeronline.nl/Europa/Nederland/Son/4058667'}
buttons.radio = {width:12, image: 'img/radio_on.png', title: 'Radio', url: 'http://nederland.fm'}
buttons.nunl = {width:12, icon: 'fa-newspaper-o', title: 'Nu.nl', url: 'http://www.nu.nl'}


//CUSTOM POSITIONING:
//defining wich blocks to show, de numbers represents the IDX of the device in Domoticz
//only define if you want to use a custom width instead of the default

//var blocks = {}

//blocks[1] = {}
//blocks[1]['width'] = 4; //1 to 12, remove this line if you want to use the default (4)
//blocks[1]['title'] = 'Living room' //if you want change the name of switch different then domoticz
//blocks[1]['icon'] = 'fa-eye'; //if you want an other icon instead of the default, choose from: http://fontawesome.io/cheatsheet/
//blocks[1]['image'] = 'bulb_off.png'; //if you want to show an image instead if icon, place image in img/ folder

//blocks[204] = {} //dimmer
//blocks[204]['width'] = 12;
//blocks[204]['title'] = 'Living room' //if you want change the name of switch different then domoticz

//blocks['blocktitle_1'] = {}
//blocks['blocktitle_1']['type'] = 'blocktitle';
//blocks['blocktitle_1']['title'] = 'Schakelaars';

//var columns = {}

//columns[1] = {}
//columns[1]['blocks'] = ['blocktitle_1',1,2,62,'144_2',204,248,295] //remark: idx 144 produces 2 blocks, so you can use: '144_1' and '144_2' (or of course, just 144 if you want one)
//columns[1]['width'] = 5;

//columns[2] = {}
//columns[2]['blocks'] = ['currentweather_big','weather',5,'144_1']
//columns[2]['width'] = 5; 

//columns[3] = {}
//columns[3]['blocks'] = ['clock','sunrise','horizon','streamplayer',buttons.buienradar,buttons.radio,buttons.calendar,buttons.nunl,buttons.nzbget]
//columns[3]['width'] = 2;

//var columns_standby = {}
//columns_standby[1] = {}
//columns_standby[1]['blocks'] = ['clock','currentweather_big','weather']
//columns_standby[1]['width'] = 12;

//if you want to use multiple screens, use the code below:
//var screens = {}
//screens[1] = {}
//screens[1]['background'] = 'bg1.jpg';
//screens[1]['background_morning'] = 'bg_morning.jpg';
//screens[1]['background_noon'] = 'bg_noon.jpg';
//screens[1]['background_afternoon'] = 'bg_afternoon.jpg';
//screens[1]['background_night'] = 'bg_night.jpg';
//screens[1]['columns'] = [1,2,3]

//screens[2] = {}
//screens[2]['background'] = 'bg3.jpg';
//screens[2]['background_morning'] = 'bg_morning.jpg';
//screens[2]['background_noon'] = 'bg_noon.jpg';
//screens[2]['background_afternoon'] = 'bg_afternoon.jpg';
//screens[2]['background_night'] = 'bg_night.jpg';
//screens[2]['columns'] = [4,5,6]

Looking forward to your feedback.

thnks in advnce!
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by htilburgs »

Trigun wrote:
EdKo66 wrote:
Trigun wrote: tried to open http://192.168.1.94:8080/dashticzv2 but get an 404 error.
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
Blueone
Posts: 130
Joined: Friday 29 November 2013 11:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Blueone »

It looks like the domoticz refresh is broken in the latest version, if I look in main.js there is also no code which is using the "_DOMOTICZ_REFRESH" value, only some code which is commented". Removing the comment fixes the issue ;)

Code: Select all

//if(typeof(_DEBUG)=='undefined' || _DEBUG===false) setTimeout(function(){ getDevices(); },(_DOMOTICZ_REFRESH*1000));
			}
		});
	}
	else {
		//if(typeof(_DEBUG)=='undefined' || _DEBUG===false) setTimeout(function(){ getDevices(); },(_DOMOTICZ_REFRESH*1000));
	}
}
I'm also seeing a class is added to a thermostat setpoint at every domoticz refresh:
Untitled.png
Untitled.png (37.85 KiB) Viewed 1707 times
Last edited by Blueone on Wednesday 03 May 2017 23:12, edited 1 time in total.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by poudenes »

Wheeling wrote:
htilburgs wrote:
EdKo66 wrote:
Hi @htilburgs

Nice Dash
Can you share the iPhone script with us :)
I've been looking for it for a long time, but do not get it to work.

Thx
Bennie
Create a DUMMY TEXT device with name "Position PERSOON" and a DUMMY % Device with name "iPhone Battery PERSOON"

Replace PERSOON to what you want and replace that as well in the script

Code: Select all

-- test if they are "home" and represent this using virtual switches

commandArray = {}
-- polling interval in minutes (1-59), setting this too low may drain the phones' batteries
interval = 10
local m = os.date('%M')
if (m % interval == 0) then

  json = (loadfile "/home/osmc/domoticz/scripts/lua/JSON.lua")()

  -- Array of users to be checked
  users = {
            PERSOON = {username = "APPLE ID EMAIL" ; password = "PASSWORD" ; devicename = "iPhone Peter"};
              }
              
  -- The latitude and longitude of your house (use Google Maps or similar to find this)
  homelongitude = 4.870349
  homelatitude = 52.333368
  
  -- Radius (in km) which will be used to determine if a device is at home
  radius = 0.1

  function address(longitude, latitude)
    command = "curl -s https://maps.googleapis.com/maps/api/geocode/json?latlng=" .. latitude .. "," .. longitude .. "&sensor=false"
    local handle = io.popen(command)
    local result = handle:read("*a")
    handle:close()
    output = json:decode(result)
    return output.results[1].formatted_address
  end

  for user,credentials in pairs(users) do
    getlocation = "curl -s -X POST -L -u '" .. credentials.username .. ":" .. credentials.password .. "' -H 'Content-Type: application/json; charset=utf-8' -H 'X-Apple-Find-Api-Ver: 2.0' -H 'X-Apple-Authscheme: UserIdGuest' -H 'X-Apple-Realm-Support: 1.0' -H 'User-agent: Find iPhone/1.3 MeKit (iPad: iPhone OS/4.2.1)' -H 'X-Client-Name: iPad' -H 'X-Client-UUID: d98c8ae0db3311e687b92890643032df' -H 'Accept-Language: en-us' -H 'Connection: keep-alive' https://fmipmobile.icloud.com/fmipservice/device/" .. credentials.username .."/initClient"
    local handle = io.popen(getlocation)
    local result = handle:read("*a")
    handle:close()

    output = json:decode(result)
    for key,value in pairs(output.content) do
      if value.name == credentials.devicename then
        lon = value.location.longitude
        lat = value.location.latitude
        bat = value.batteryLevel * 100 / 1
        powerstateval = value.batteryStatus
        table.insert(commandArray,{['UpdateDevice'] = otherdevices_idx['iPhone Battery ' .. user] .. '|0|' .. bat})
        distance = math.sqrt(((lon - homelongitude) * 111.320 * math.cos(math.rad(lat)))^2 + ((lat - homelatitude) * 110.547)^2)  -- approximation
        position = address(lon,lat)
        position_text = string.gsub(position, ', Netherlands', '') .. ' (' .. (math.floor(distance*10+0.5)/10) .. ' km)'
        prev_distance_str = string.match(otherdevices['Position ' .. user], '%(.*%)') or '(1000 km)'
      prev_distance = tonumber(string.sub(prev_distance_str, 2,-5))
        -- update text device, but only if postion has changed more than defined in "radius" to reduce log size
        if math.abs(prev_distance - distance) > radius then  
          table.insert(commandArray,{['UpdateDevice'] = otherdevices_idx['Position ' .. user] .. '|0|' .. position_text})
        end
        print('iPhone ' .. user .. ': ' .. math.floor(distance*100+0.5)/100 .. ' km from home, ' .. bat .. '% battery remaining. PowerState: '.. powerstateval ..' ')
        if distance < radius  then
          if otherdevices['iPhone ' .. user] == 'Off' then
            commandArray['iPhone ' .. user] = 'On'
            table.insert(commandArray, {['SendNotification'] = 'Presence update#' .. user .. ' came home'})
          end
        else
          if otherdevices['iPhone ' .. user] == 'On' then
            commandArray['iPhone ' .. user] = 'Off'
            table.insert(commandArray, {['SendNotification'] = 'Presence update#' .. user .. ' left home'})
          end
        end
      end
    end
  end
end
return commandArray
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Trigun »

htilburgs wrote:
Trigun wrote:
EdKo66 wrote:
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Unfortunately not working



Sent from my iPhone using Tapatalk
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by htilburgs »

Trigun wrote:
htilburgs wrote:
Trigun wrote:
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Unfortunately not working

Sent from my iPhone using Tapatalk
In which folder have you installed Dashticz ??
/domoticz/www/dashticzv2 ??
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Trigun »

htilburgs wrote:
Trigun wrote:
htilburgs wrote:
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Unfortunately not working

Sent from my iPhone using Tapatalk
In which folder have you installed Dashticz ??
/domoticz/www/dashticzv2 ??
Yes correct, should be ok right?


Sent from my iPhone using Tapatalk
robgeerts
Posts: 1273
Joined: Saturday 24 January 2015 22:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: RE: Re: Dashticz v2.0, custom positioning and multiple screens

Post by robgeerts »

Trigun wrote:
htilburgs wrote:
Trigun wrote:
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Unfortunately not working



Sent from my iPhone using Tapatalk
Tried adding /index.html ?
User avatar
Phantom
Posts: 87
Joined: Saturday 31 December 2016 14:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11652
Location: The Netherlands
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Phantom »

i have a request, can you also make a variable for the "state" just like you did for "lastupdate"
Now i see my name with my state below it and i would like to remove that.
Image
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

Phantom wrote:i have a request, can you also make a variable for the "state" just like you did for "lastupdate"
Now i see my name with my state below it and i would like to remove that.
Image
Have you tried blocks[idx]['hide_data'] = true
Blah blah blah
User avatar
Phantom
Posts: 87
Joined: Saturday 31 December 2016 14:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11652
Location: The Netherlands
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Phantom »

HansieNL wrote:
Phantom wrote:i have a request, can you also make a variable for the "state" just like you did for "lastupdate"
Now i see my name with my state below it and i would like to remove that.
Image
Have you tried blocks[idx]['hide_data'] = true
Great thanks that worked, where did you find that before i ask a silly question here again xD
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

Phantom wrote:
HansieNL wrote:
Phantom wrote:i have a request, can you also make a variable for the "state" just like you did for "lastupdate"
Now i see my name with my state below it and i would like to remove that.
Image
Have you tried blocks[idx]['hide_data'] = true
Great thanks that worked, where did you find that before i ask a silly question here again xD
I can't remember when I've added it to my config.js. Must be some time ago. Just added to the Wiki.
AND There are no silly questions as it is not added to the Wiki ;)
Blah blah blah
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Derik »

Got some output...:-)
ScreenShot240.jpg
ScreenShot240.jpg (81.48 KiB) Viewed 1619 times
Now try to to customizing.
Looks great!!

Please a first step to simple begin.
When i put off the favorites and the automatic.
I don't have any screen [ see no thing ] anymore :-)
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
crashingdutchman
Posts: 21
Joined: Monday 05 December 2016 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by crashingdutchman »

robgeerts wrote:Ah, please specify blocks for the standby mode, like:

Code: Select all

var columns_standby = {}
columns_standby[1] = {}
columns_standby[1]['blocks'] = ['clock']
columns_standby[1]['width'] = 12;
Okay, that solved it I don't have a black screen anymore... I think I missed that step somehow. I just don't want the clock but the same screen with all my blocks and have it dim after a while... looking into more details...

Thanks Rob
User avatar
Phantom
Posts: 87
Joined: Saturday 31 December 2016 14:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11652
Location: The Netherlands
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Phantom »

Derik wrote:Got some output...:-)
ScreenShot240.jpg
Now try to to customizing.
Looks great!!

Please a first step to simple begin.
When i put off the favorites and the automatic.
I don't have any screen [ see no thing ] anymore :-)
When you turn those off you need to activate the the custom position: http://www.domoticz.com/wiki/Dashticz_V2_-_Positioning
There you can add the devices you want to see and the location where you want to see them.
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Trigun »

robgeerts wrote:
Trigun wrote:
htilburgs wrote:
Try to open http://192.168.1.94:8080/dashticzv2/ with a / at the end.
Unfortunately not working



Sent from my iPhone using Tapatalk
Tried adding /index.html ?
Unfortunately not working either :(
Shouldn't be that hard right?


Sent from my iPhone using Tapatalk
crashingdutchman
Posts: 21
Joined: Monday 05 December 2016 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by crashingdutchman »

If I would like to make the block of the traffic map twice as high as it is now, how would I need to do that?
Blueone
Posts: 130
Joined: Friday 29 November 2013 11:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by Blueone »

I am handling my thermostat setpoint buttons in the custom.js but I had to change the "Add thermostatFunction" a little bit to make it work:

I had to change this in main.js so you can also use the function from custom.js:

Code: Select all

function addThermostatFunctions(thermelement){									
	//$(thermelement+' .btn-number').click(function(e) {
	$(document).delegate((thermelement+' .btn-number'),"click",function(e){	
		sliding=true;
	  fieldName = $(this).attr('data-field');
	  type = $(this).attr('data-type');
	  var input = $(thermelement+" strong");
	  var currentVal = input.text().split('°');
	  currentVal = parseFloat(currentVal[0]);
	  if (!isNaN(currentVal)) {
		if (type == 'minus') {

		  if (currentVal > input.attr('min')) {
			input.text(currentVal - 0.5 + _TEMP_SYMBOL).change();
			switchThermostat(parseFloat(input.text()),input);
		  }
		  if (parseFloat(input.text()) == input.attr('min')) {
			$(this).attr('disabled', true);
		  }

		} else if (type == 'plus') {

		  if (currentVal < input.attr('max')) {
			input.text(currentVal + 0.5 + _TEMP_SYMBOL).change();
			switchThermostat(parseFloat(input.text()),input);
		  }
		  if (parseFloat(input.text()) == input.attr('max')) {
			$(this).attr('disabled', true);
		  }

		}
	  } else {
		input.text(0);
	  }
	});

	$(thermelement+' .input-number').focusin(function() {
	  $(this).data('oldValue', $(this).text());
	});

	$(thermelement+' .input-number').change(function() {
	  minValue = parseFloat($(this).attr('min'));
	  maxValue = parseFloat($(this).attr('max'));
	  valueCurrent = parseFloat($(this).text());

	  name = $(this).attr('name');
	  if (valueCurrent >= minValue) {
		$(thermelement+" .btn-number[data-type='minus']").removeAttr('disabled')
	  } else {
		  $(this).val($(this).data('oldValue'));
	  }
	  if (valueCurrent <= maxValue) {
		$(thermelement+" .btn-number[data-type='plus']").removeAttr('disabled')
	  } else {
		  $(this).val($(this).data('oldValue'));
	  }
	});
}
I changed "$(thermelement+' .btn-number').click(function(e) {" to "$(document).delegate((thermelement+' .btn-number'),"click",function(e){". otherwise the clickevent doesn't work when it is added from custom.js with the following code:

Code: Select all

function getBlock_628(device,idx){ //Setpoint block
	//CHstate = getDevicestatus(224)
	//DHWstate = getDevicestatus(225)
	//debugger;
	//debug with dummy devices
	CHstate = getDevicestatus(631)
	DHWstate = getDevicestatus(632)
	console.log('CHstate: ' + CHstate)
	console.log('DHWstate: ' + DHWstate)
	var html='';
		html+=iconORimage(idx+'_1','','heating.png','on icon','style="max-height:35px;"');
	html+='<div class="col-xs-8 col-data">';
		if(typeof(blocks[idx])!=='undefined' && typeof(blocks[idx]['switch'])!=='undefined' && blocks[idx]['switch']==true){
			html+='<strong class="title">'+device['Name']+'</strong><br />';
			html+='<span class="state">'+device['Data']+_TEMP_SYMBOL+'</span>';

		}
		else {
			html+='<strong class="title">'+device['Data']+_TEMP_SYMBOL+'</strong><br />';
			html+='<span class="state">'+device['Name']+'</span>';
		}
		if(_SHOW_LASTUPDATE && (typeof(blocks[idx])=='undefined' || typeof(blocks[idx]['hide_lastupdate'])=='undefined' || blocks[idx]['hide_lastupdate']===false)){
			html+='<br /><span class="lastupdate">'+moment(device['LastUpdate']).format(_LASTUPDATE_FORMAT)+'</span>';
		}
	html+='</div>';

	$('div.block_'+idx+'_1').html(html);
	addHTML=false;

	html='';
	var random = getRandomInt(1,100000);
	html+='<ul class="col-thermostat input-groupBtn">';
	  html+='<li class="up"><a href="javascript:void(0)" class="btn btn-number plus" data-type="plus" data-field="quant['+device['idx']+']" onclick="this.blur();">';
				html+='<em class="fa fa-plus fa-small fa-thermostat"></em>';
			html+='</a></li>';
	  html+='<li class="down"><a href="javascript:void(0)" class="btn btn-number min" data-type="minus" data-field="quant['+device['idx']+']" onclick="this.blur();">';
	  html+='<em class="fa fa-minus fa-small fa-thermostat"></em>';
			html+='</a></li>';
	html+='</ul>';

	 if(DHWstate == 'On') {
	 html+=iconORimage(idx+'_2','','hotwater.png','on icon iconheating','','2');
	 }
	 else if(CHstate == 'On') {
	 html+=iconORimage(idx+'_2','','CH_Active.png','on icon iconheating','','2');
	 }
	 else {
	 html+=iconORimage(idx+'_2','','heating.png','on icon iconheating','','2');
	 }
	html+='<div class="col-xs-8 col-data">';
		html+='<strong class="title input-number title-input" min="12" max="25" data-light="'+device['idx']+'">'+device['Data']+_TEMP_SYMBOL+'</strong>';
		html+='<div class="state stateheating">'+device['Name']+'</div>';

	html+='</div>';

	$('div.block_'+idx+'_2').addClass('thermostat'+random).html(html);
	$('div.block_'+idx).addClass('thermostat'+random).html(html);
	addHTML=false;

	thermelement = ('.thermostat'+random);
	addThermostatFunctions(thermelement);
	return html;
}
Last edited by Blueone on Thursday 04 May 2017 9:48, edited 1 time in total.
Locked

Who is online

Users browsing this forum: No registered users and 1 guest