Skip to content

Instantly share code, notes, and snippets.

View stas-dovgodko's full-sized avatar

Stas Dovgodko stas-dovgodko

View GitHub Profile
@stas-dovgodko
stas-dovgodko / README.md
Created October 17, 2015 15:48 — forked from hakre/README.md
Iterators for PHP XMLReader for ease of parsing

Iterators for PHP XMLReader for ease of parsing

Change Log:

  • 0.1.10 maintenance release with fixes.

  • 0.1.9 maintenance release with fixes. added XMLReaderNode::expand().

  • 0.1.8 maintenance release with fixes.

FROM php:5.5-fpm
RUN apt-get update && \
apt-get install -y php5-dev php-pear php5-common curl libcurl4-openssl-dev libpng-dev libfreetype6-dev libjpeg-dev libxml2-dev libpq-dev php5-memcached wget php5-intl libicu-dev default-jre libmemcached-dev && \
rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install bcmath
RUN docker-php-ext-enable bcmath
#include <SoftwareSerial.h>
#include <SPFD5408_Adafruit_GFX.h> // Core graphics library
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPFD5408_TouchScreen.h> // Touch library
#include <math.h>
#include "EmonLib.h"
#include <TimerOne.h>
#include <stdint.h> // needed for uint8_t
SoftwareSerial ESPserial(19, 18); // RX | TX
@stas-dovgodko
stas-dovgodko / sketch.uno
Last active November 7, 2017 11:12
Arduino 220 detector with debounce + interrupts
#define AC_PIN 3
#define RF_PIN 2
#define LED_PIN 13
volatile int counter = 0;
volatile int ac_status = 0;
volatile unsigned long ac_timer;
int ON[] = {2, 2, 2, 2, 1, 4, 4, 4, 4, 5, 1, 4, 4, 4, 4, 4, 4, 5, 2, 2, 1, 4, 4, 4, 6}; //The RF code that will turn the ON
int OFF[] = {2, 2, 2, 2, 1, 4, 4, 4, 4, 5, 1, 4, 4, 4, 4, 4, 4, 5, 2, 2, 2, 2, 2, 2, 3}; //The RF code that will turn the OFF
mkdir /app/nano
curl https://github.com/Ehryk/heroku-nano/raw/master/heroku-nano-2.5.1/nano.tar.gz --location --silent | tar xz -C /app/nano
export PATH=$PATH:/app/nano
///////////////////////
// Кабінет
Group GF_Office "Кабінет" <office> (Home_GroundFloor) ["Office"]
Group GF_Office_HVAC "Клімат кабінету" <heating> (GF_Office, gHVAC) ["HVAC"] {ga="Thermostat" [ modes="heat,eco=ECO,auto" ]}
Number:Temperature GF_Office_Temperature "Температура у кабінеті [%.1f %unit%]" <hvac_temperature> (GF_Office_HVAC, gTemperature) ["Measurement", "Temperature"] {ga="thermostatTemperatureAmbient"}
Number:Temperature GF_Office_SetpointTemperature "Бажана температура у кабінеті [%.1f %unit%]" <hvac_setpoint> (GF_Office_HVAC, gSetpointTemperature) ["Setpoint", "Temperature"] {ga="thermostatTemperatureSetpoint"}
Number:Dimensionless GF_Office_Humidity "Вологість у кабінеті [%d %%]" <hvac_humidity> (GF_Office_HVAC) ["Measurement", "Humidity"] {ga="thermostatHumidityAmbient"}
Number:Dimensionless GF_Office_Co2 "Co2 у кабінеті [%d ppm]" <hvac_co2> (GF_Office_HVAC) ["Measurement", "CO2"] { ga="Sensor" [ sensorName="CarbonDioxideLevel", valueUnit="PARTS_PER_MILLION" ] }
Number Netatmo_Indoor_Humidex "Humidex [%.0f]" <temperature_hot> {channel="netatmo:NAMain:home:inside:Humidex", expire="60m" }
Number:Temperature Netatmo_Indoor_HeatIndex "HeatIndex [%.1f %unit%]" <temperature_hot> {channel = "netatmo:NAMain:home:inside:HeatIndex", expire="60m" }
Number:Temperature Netatmo_Indoor_Dewpoint "Dewpoint [%.1f %unit%]" <temperature_cold> {channel = "netatmo:NAMain:home:inside:Dewpoint", expire="60m" }
Number:Temperature Netatmo_Indoor_DewpointDepression "DewpointDepression [%.1f %unit%]" <temperature_cold> {channel = "netatmo:NAMain:home:inside:DewpointDepression", expire="60m"}
Number:Dimensionless Netatmo_Indoor_Co2 "Co2 [%d %unit%]" <carbondioxide> {channel = "netatmo:NAMain:home:inside:Co2", expire="60m"}
let proxy = require('openhab-proxy-pattern');
proxy.bind("GF_Office_Co2", "Netatmo_Indoor_Co2")
.update(function(value) {
const ppm = parseInt(value);
return (typeof value == 'string') ? `${ppm} ppm` : undefined;
});
proxy.bind("GF_Office_Humidity", "Netatmo_Indoor_Humidity")
let proxy = require('openhab-proxy-pattern');
/*
proxy.bind(proxy_item_name, hardware_item_name).update([callback]).forward([callback]);
*/
// проксирование от железа в виртуалку
proxy.bind('Equipment_WF_OutTemperature', 'SmartMAC_D105_1_T2').update();
// проксирование в обе стороны
// донгл /dev/usbModbus на швидкості 9600 з'єднано із реле slave=7
Bridge modbus:serial:ion8cs_1 [ port="/dev/usbModbus", id=7, baud=9600, stopBits="2.0", parity="none",dataBits=8, encoding="rtu"] {
// 8 coil регістрів починаючи з 0, це керування станом реле
// я не знайшов це в документації і якось здогадався шо воно може бути саме так
Bridge poller output [ start=0, length=8, type="coil" ] {
Thing data i1 "Стан 1" [ readStart="0", readValueType="bit", writeStart="0", writeType="coil"]
Thing data i2 "Стан 2" [ readStart="1", readValueType="bit", writeStart="1", writeType="coil"]
Thing data i3 "Стан 3" [ readStart="2", readValueType="bit", writeStart="2", writeType="coil"]
Thing data i4 "Стан 4" [ readStart="3", readValueType="bit", writeStart="3", writeType="coil"]
Thing data i5 "Стан 5" [ readStart="4", readValueType="bit", writeStart="4", writeType="coil"]