Skip to content

Commit

Permalink
Updating a few enahncements
Browse files Browse the repository at this point in the history
  • Loading branch information
JZ-SmartThings committed May 13, 2017
1 parent 20ced5d commit ffa07cb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
21 changes: 11 additions & 10 deletions Devices/TVDevice/IRremoteESP8266-Using5Volts/IRSender5V.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* TV Device Sample v1.0.20160806
* TV Device Sample v1.0.20170512
* Source code can be found here: https://github.com/JZ-SmartThings/SmartThings/blob/master/Devices/TVDevice
* Copyright 2016 JZ
*
Expand All @@ -11,10 +11,7 @@
* for the specific language governing permissions and limitations under the License.
*/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
// CHOOSE WHICH LIBRARY TO USE FOR IR
#include <IRremoteESP8266at5V.h>
//#include <IRremoteESP8266.h>

Expand All @@ -25,15 +22,18 @@ MDNSResponder mdns;
ESP8266WebServer server(80);
IRsend irsend(D2);

void handleRoot() {
String htmlContent = "<html><head><title>ESP8266 IR Remote</title></head><body><h1>ESP8266 IR Remote</h1></br>";
//OTHER VARIABLES
String currentIP;

htmlContent += "\n";
void handleRoot() {
String htmlContent = "<html><head><title>ESP8266 IR Remote</title></head><body><a href='/'><h1>ESP8266 IR Remote</h1><br>";
htmlContent += currentIP;
htmlContent += "</a><br>\n";
for (uint8_t i=0; i<server.args(); i++){
htmlContent += server.argName(i);
htmlContent += "=";
htmlContent += server.arg(i);
htmlContent += "\n<br\>";
htmlContent += "\n<br>";
}


Expand Down Expand Up @@ -138,7 +138,7 @@ void setup(void){

irsend.begin();

Serial.begin(9600);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Expand All @@ -153,6 +153,7 @@ void setup(void){
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
currentIP = WiFi.localIP().toString();

if (mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("MDNS responder started");
Expand Down
5 changes: 1 addition & 4 deletions Devices/TVDevice/IRremoteESP8266/IRSender.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
* for the specific language governing permissions and limitations under the License.
*/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
// CHOOSE WHICH LIBRARY TO USE FOR IR
//#include <IRremoteESP8266at5V.h>
#include <IRremoteESP8266.h>

Expand Down
26 changes: 22 additions & 4 deletions Devices/TVDevice/TVDevice.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* TVDevice v1.0.20170504
* TVDevice v1.0.20170505
*
* Source code can be found here: https://github.com/JZ-SmartThings/SmartThings/blob/master/Devices/TVDevice/TVDevice.groovy
*
Expand Down Expand Up @@ -97,7 +97,7 @@ metadata {
state "default", label: 'MUTE', action: "tvmute", icon: "st.custom.sonos.muted", backgroundColor: "#9966CC", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.custom.sonos.muted", backgroundColor: "#FFAA33"
}
controlTile("levelSliderControl", "device.level", "slider", width: 6, height: 1, inactiveLabel: false, range:"(1..4)") {
controlTile("levelSliderControl", "device.level", "slider", width: 6, height: 1, inactiveLabel: false, range:"(0..100)") {
state "level", label:'HDMI Input', action:"switch level.setLevel"
}

Expand All @@ -122,8 +122,26 @@ def ResetTiles() {

def setLevel(value) {
def level=value as int
//log.debug level + "---test"
runCmd("/ir?hdmi=" + level)
def cmd="" as String
log.debug "setLevel >> value: $value"
if (value<25) {
level=0
cmd="/ir?tv=input"
} else if (value==25 && value<=49) {
level=25
cmd="/ir?hdmi=" + 1
} else if (value==50 && value<=74) {
level=50
cmd="/ir?hdmi=" + 2
} else if (value==75 && value<=99) {
level=75
cmd="/ir?hdmi=" + 3
} else if (value==100) {
level=100
cmd="/ir?hdmi=" + 4
}
sendEvent(name: "level", value: level, isStateChange: true)
runCmd(cmd)
}

def on() {
Expand Down

0 comments on commit ffa07cb

Please sign in to comment.