ChatGPT

Posted on
Thu Dec 08, 2022 12:50 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

ChatGPT

Thought you all might like to see what's going on at https://chat.openai.com/chat

I put this mess of a script in to it:
Code: Select all
from PIL import Image
import time
from PIL import ImageFont
from PIL import ImageDraw
import matplotlib.pyplot as plt
import numpy as np
import datetime

time.sleep(0.5)
original = Image.open(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/1.jpg")
#time.sleep(0.8)
draw = ImageDraw.Draw(original)
font = ImageFont.truetype("Arial", 55)
draw.text((55, 23), datetime.datetime.now().strftime("%a %d %I:%M %p text"), (255, 70, 90), font=font)
plt.subplot(1, 2, 1)
plt.title("white text")
# plt.imshow(original)
original.save(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/1.jpg", optimize=True, quality=45)
original.save(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/2.jpg", optimize=True, quality=45)


It gave me back
Code: Select all
from datetime import datetime
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
import matplotlib.pyplot as plt
import numpy as np
import time

image_path = Path(indigo.server.getInstallFolderPath()) / "Web Assets" / "public"

time.sleep(0.5)

with Image.open(image_path / "1.jpg") as original:
    draw = ImageDraw.Draw(original)
    font = ImageFont.truetype("Arial", 55)
    draw.text((55, 23), datetime.now().strftime("%a %d %I:%M %p text"), (255, 70, 90), font=font)
    plt.subplot(1, 2, 1)
    plt.title("white text")
    # plt.imshow(original)
    original.save(image_path / "1.jpg", optimize=True, quality=45)
    original.save(image_path / "2.jpg", optimize=True, quality=45)


I'm super impressed and imagine this will enable me to wildly expand python scripting in my setup.

It's not so great at AppleScript though. This folder action gets and error:
Code: Select all
on adding folder items to this_folder after receiving added_items
    tell application "Photos"
        set display_folder to folder "display"
        repeat with i in items of display_folder
            delete i
        end repeat
    end tell

    repeat with i in added_items
        set file_name to the name of i
        if file_name ends with ".jpg" or file_name ends with ".png" or file_name ends with ".gif" then
            tell application "Photos"
                import i to display_folder. (error is on this line)
            end tell
        end if
    end repeat
end adding folder items to

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Thu Dec 08, 2022 9:32 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: ChatGPT

Right!? Your code chops are substantially above mine, but this is a transformative tool!

Posted on
Sat Dec 10, 2022 8:35 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: ChatGPT

I tried to ask it some questions about Indigo but it didn't appear to have any training. But it wrote me a quick script to analyze whether a picture of my alarm panel was armed or disabled.

Code: Select all

# Import the necessary modules
import cv2
import numpy as np

# Read the image file
img = cv2.imread("/Users/ryanbuckner/Downloads/redexample.png")

# Convert the image to the HSV color space
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

# Define the lower and upper bounds for the red and green colors
lower_red = np.array([0,100,100])
upper_red = np.array([10,255,255])
lower_green = np.array([50,100,100])
upper_green = np.array([70,255,255])

# Create masks for the red and green colors
mask_red = cv2.inRange(hsv, lower_red, upper_red)
mask_green = cv2.inRange(hsv, lower_green, upper_green)

# Check if there are any red or green pixels in the image
if np.any(mask_red):
    print("Alarm is Set")
elif np.any(mask_green):
    print("Alarm is not Set")
else:
    print("Neither red nor green light is present in the picture")


Posted on
Sat Dec 10, 2022 9:21 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: ChatGPT

ryanbuckner wrote:
I tried to ask it some questions about Indigo but it didn't appear to have any training. But it wrote me a quick script to analyze whether a picture of my alarm panel was armed or disabled.

Code: Select all

# Import the necessary modules
import cv2
import numpy as np

# Read the image file
img = cv2.imread("/Users/ryanbuckner/Downloads/redexample.png")

# Convert the image to the HSV color space
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

# Define the lower and upper bounds for the red and green colors
lower_red = np.array([0,100,100])
upper_red = np.array([10,255,255])
lower_green = np.array([50,100,100])
upper_green = np.array([70,255,255])

# Create masks for the red and green colors
mask_red = cv2.inRange(hsv, lower_red, upper_red)
mask_green = cv2.inRange(hsv, lower_green, upper_green)

# Check if there are any red or green pixels in the image
if np.any(mask_red):
    print("Alarm is Set")
elif np.any(mask_green):
    print("Alarm is not Set")
else:
    print("Neither red nor green light is present in the picture")

Awesome quick and dirty implementation

Posted on
Sat Dec 10, 2022 2:55 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: ChatGPT

Check it out.

living_room.png
living_room.png (82.86 KiB) Viewed 1720 times

Posted on
Sat Dec 10, 2022 10:53 pm
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: ChatGPT

Seems like in the last day or so chatgpt digested the indigo scripting tutorial. I worked out a script today and it knew how to trigger an action group with python without me explaining, and it definitely didn’t know that when I posted my first script.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Dec 12, 2022 10:19 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: ChatGPT

ryanbuckner wrote:
Check it out.

living_room.png


LOL - too bad that's wrong, the command is:

Code: Select all
indigo.device.turnOn('living_room_light')


And we don't recommend using the name to get the device since the name can change (but that would be harder for GPT to get right).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Dec 13, 2022 6:27 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: ChatGPT

ha yeah I saw that it was wrong. But a few days ago it wouldn't even answer

Posted on
Tue Dec 13, 2022 8:21 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: ChatGPT

Heh, the word is definitely out.

ChatGPT wrote:
ChatGPT is at capacity right now

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Dec 13, 2022 10:18 am
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: ChatGPT

Yeah pretty much the only time I can get an answer to anything with significant input from me is late in the evenings, or on the weekends.

I tried inputting an entire "style.css" file for Hubzilla with instructions to "make it more modern" and it started, looked promising... and never finished then errored out.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Dec 13, 2022 10:39 am
Different Computers offline
User avatar
Posts: 2552
Joined: Jan 02, 2016
Location: East Coast

Re: ChatGPT

Just going on about this a bit:

Here's something I've wanted to do for years, knew was possible, but could not put it all together without pulling hair out over syntax, process, etc.

I have my Nanoleaf lights react to music, and I have them changing the music light effect with each song change in Apple Music. The only way I could figure out how to do this in Indigo previously was to have a set order of triggers that looked at the current Nanoleaf scene value and changed it to another set one when triggered by a change of song. That meant a different action group and trigger with different conditions for each scene I wanted to do.

In about 10 minutes with ChatGPT, I changed all that to one trigger and one action group that runs this script:
Code: Select all
import random

# Create an array of the IDs of the action groups that you want to include in the subset (and these ids have been edited for security)
subset = [
  97870712,
  13836112,
  19560082,
  3870625,
  26797751,
  15247221,
  18884308,
  19247221,
  8937550,
  1208860,
  2653673,
  737059,
  18789262
]

# Select a random action group from the subset
selected_group = random.choice(subset)

# Trigger the selected action group
indigo.actionGroup.execute(selected_group)


It works faster, more cleanly, and is easier to modify than the previous kludge. Super basic python I know, but pulling together all the documentation to format it all correctly would have been frustrating. This script ran correctly the very first time!

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Dec 13, 2022 2:32 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: ChatGPT

ryanbuckner wrote:
ha yeah I saw that it was wrong. But a few days ago it wouldn't even answer


So the question really is, which is worse: no answer at all or an incorrect one?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 14, 2022 6:53 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: ChatGPT

Good point. For a learning system, I'd prefer some answer. Then we can fix it

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests