fix: a couple of issues with the yaml state sensor discovery (#6912)

This commit is contained in:
Tony Murray
2017-06-29 15:12:51 -05:00
committed by Neil Lathwood
parent 0854ff5f59
commit 14ed767edb

View File

@ -1086,8 +1086,9 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
$value = $value * $multiplier;
}
} else {
$state_name = $data['descr'];
$state_name = $data['state_name'];
$state_index_id = create_state_index($state_name);
if ($state_index_id != null) {
foreach ($data['states'] as $state) {
$insert = array(
'state_index_id' => $state_index_id,
@ -1099,6 +1100,7 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
dbInsert($insert, 'state_translations');
}
}
}
$tmp_index = $data['index'] ?: $index;
$uindex = str_replace('{{ $index }}', $index, $tmp_index);
if ($sensor_type === 'state') {