<component name="ChangeListManager">
<list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/homeassistant_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/homeassistant_device_event.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/homeassistant.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/homeassistant.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<workItem from="1689026578748" duration="2434000" />
<workItem from="1689274022940" duration="239000" />
<workItem from="1689274317966" duration="657000" />
- <workItem from="1689326392784" duration="1671000" />
+ <workItem from="1689326392784" duration="3064000" />
</task>
<task id="LOCAL-00502" summary=".">
<created>1641726946298</created>
<option name="project" value="LOCAL" />
<updated>1687259667913</updated>
</task>
- <option name="localTasksCounter" value="573" />
+ <option name="localTasksCounter" value="574" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
const HA_ECO_SUPER = 'switch.ecomode_super';
const HA_HOTTE = 'switch.hotte';
const HA_BAR = 'switch.bar';
-const HA_PLANETARIUM='switch.0xa4c138788071821e';
+const HA_PLANETARIUM = 'switch.0xa4c138788071821e';
function haGetState($id, $attribute = null) { //ID to read - for example sensor.foo
"Authorization: Bearer " . HA_KEY . "\r\n"
]
];
- $ctx = stream_context_create($opts);
- $data = @file_get_contents(HA_URL . 'api/states/' . $id, false, $ctx);
- if (!$data) {
- return false;
+
+ $ids = !is_array($id) ? explode(',', $id) : $id;
+ $d = [];
+
+ foreach ($ids as $id) {
+ $ctx = stream_context_create($opts);
+ $data = @file_get_contents(HA_URL . 'api/states/' . $id, false, $ctx);
+ if (!$data) {
+ continue;
+ }
+ $d[$id] = json_decode($data);
}
- $data = json_decode($data);
+
+ usort($d, function ($a, $b) {
+ return strcmp($a->last_updated, $b->last_updated) * -1;
+ });
+
+
+ $data = array_shift($d);
if (null === $attribute) {
if (!$data)
$weather = json_decode(file_get_contents($cache), true);
$weather = $weather[0];
$res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
- $res['outdoor_temp'] = toNumber(haGetState('sensor.indoor_outdoor_meter_ddf7_temperature'), 1);
- $res['outdoor_humidity'] = toNumber(haGetState('sensor.indoor_outdoor_meter_ddf7_humidty'), true);
+ $res['outdoor_temp'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_temperature', 'sensor.w340001x_tempc']), 1);
+ $res['outdoor_humidity'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_humidity', 'sensor.w340001x_hum']), true);
$res['outdoor_pressure'] = toNumber(haGetState('sensor.0x00158d000464c885_pressure'), true);
$res['backyard_temp'] = toNumber(haGetState('sensor.0x00158d000464c885_temperature'), 1);
$res['backyard_humidity'] = toNumber(haGetState('sensor.0x00158d000464c885_humidity'), true);
$res['kitchen_humidity'] = toNumber(haGetState('sensor.0x00158d000418441f_humidity'), true);
$res['wc_temp'] = toNumber(haGetState('sensor.0x00158d00046574da_temperature'), 1);
$res['wc_humidity'] = toNumber(haGetState('sensor.0x00158d00046574da_humidity'), true);
- $res['office_temp'] = toNumber(haGetState('sensor.meter_c7c3_temperature'), 1);
- $res['office_humidity'] = toNumber(haGetState('sensor.meter_c7c3_humidite'), true);
+ $res['office_temp'] = toNumber(haGetState(['sensor.meter_c7c3_temperature', 'sensor.thx1_w230150x_tempc']), 1);
+ $res['office_humidity'] = toNumber(haGetState(['sensor.meter_c7c3_humidite', 'sensor.thx1_w230150x_hum']), true);
// $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true);
// $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1);
$res['cellar_humidity'] = 0;