Compare commits
	
		
			4 Commits
		
	
	
		
			9c1cd1d31f
			...
			cc6a3848ca
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| cc6a3848ca | |||
| 29acd92122 | |||
| 455b3c5f3c | |||
| fdf7e5c642 | 
							
								
								
									
										18
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							@@ -59,11 +59,11 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    "nixpkgs": {
 | 
					    "nixpkgs": {
 | 
				
			||||||
      "locked": {
 | 
					      "locked": {
 | 
				
			||||||
        "lastModified": 1718318537,
 | 
					        "lastModified": 1724224976,
 | 
				
			||||||
        "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=",
 | 
					        "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
 | 
				
			||||||
        "owner": "NixOS",
 | 
					        "owner": "NixOS",
 | 
				
			||||||
        "repo": "nixpkgs",
 | 
					        "repo": "nixpkgs",
 | 
				
			||||||
        "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420",
 | 
					        "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "original": {
 | 
					      "original": {
 | 
				
			||||||
@@ -84,11 +84,11 @@
 | 
				
			|||||||
        "treefmt-nix": "treefmt-nix"
 | 
					        "treefmt-nix": "treefmt-nix"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "locked": {
 | 
					      "locked": {
 | 
				
			||||||
        "lastModified": 1718285706,
 | 
					        "lastModified": 1724208502,
 | 
				
			||||||
        "narHash": "sha256-DScsBM+kZvxOva7QegfdtleebMXh30XPxDQr/1IGKYo=",
 | 
					        "narHash": "sha256-TCRcEPSfgAw/t7kClmlr23s591N06mQCrhzlAO7cyFw=",
 | 
				
			||||||
        "owner": "nix-community",
 | 
					        "owner": "nix-community",
 | 
				
			||||||
        "repo": "poetry2nix",
 | 
					        "repo": "poetry2nix",
 | 
				
			||||||
        "rev": "a5be1bbbe0af0266147a88e0ec43b18c722f2bb9",
 | 
					        "rev": "884b66152b0c625b8220b570a31dc7acc36749a3",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "original": {
 | 
					      "original": {
 | 
				
			||||||
@@ -156,11 +156,11 @@
 | 
				
			|||||||
        ]
 | 
					        ]
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "locked": {
 | 
					      "locked": {
 | 
				
			||||||
        "lastModified": 1717850719,
 | 
					        "lastModified": 1719749022,
 | 
				
			||||||
        "narHash": "sha256-npYqVg+Wk4oxnWrnVG7416fpfrlRhp/lQ6wQ4DHI8YE=",
 | 
					        "narHash": "sha256-ddPKHcqaKCIFSFc/cvxS14goUhCOAwsM1PbMr0ZtHMg=",
 | 
				
			||||||
        "owner": "numtide",
 | 
					        "owner": "numtide",
 | 
				
			||||||
        "repo": "treefmt-nix",
 | 
					        "repo": "treefmt-nix",
 | 
				
			||||||
        "rev": "4fc1c45a5f50169f9f29f6a98a438fb910b834ed",
 | 
					        "rev": "8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "original": {
 | 
					      "original": {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ from typing_extensions import Annotated
 | 
				
			|||||||
import typer
 | 
					import typer
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import paho.mqtt.publish as pub
 | 
					import paho.mqtt.publish as pub
 | 
				
			||||||
 | 
					import paho.mqtt.subscribe as sub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LightState(str, Enum):
 | 
					class LightState(str, Enum):
 | 
				
			||||||
@@ -185,6 +186,30 @@ def set_brightness(
 | 
				
			|||||||
    payload = json.dumps({"brightness": brightness})
 | 
					    payload = json.dumps({"brightness": brightness})
 | 
				
			||||||
    pub.single(topic, payload, hostname=get_mqtt_broker())
 | 
					    pub.single(topic, payload, hostname=get_mqtt_broker())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@app.command()
 | 
				
			||||||
 | 
					@app.command("get", hidden=True)
 | 
				
			||||||
 | 
					def get_state(
 | 
				
			||||||
 | 
					    id: Annotated[
 | 
				
			||||||
 | 
					        LightID, typer.Argument(help="ID of light.", autocompletion=complete_id)
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    as_json: Annotated[
 | 
				
			||||||
 | 
					        bool, typer.Option("--json", help="Print state as json."),
 | 
				
			||||||
 | 
					    ] = False
 | 
				
			||||||
 | 
					    ):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Get the state of ID
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    str_id = NAME_TO_ID[id]
 | 
				
			||||||
 | 
					    topic = f"zigbee2mqtt/{str_id}/get"
 | 
				
			||||||
 | 
					    resp_topic = f"zigbee2mqtt/{str_id}"
 | 
				
			||||||
 | 
					    payload = json.dumps({"state": ""})
 | 
				
			||||||
 | 
					    pub.single(topic, payload, hostname=get_mqtt_broker())
 | 
				
			||||||
 | 
					    resp = sub.simple(resp_topic, hostname=get_mqtt_broker())
 | 
				
			||||||
 | 
					    data = json.loads(resp.payload.decode("utf-8"))
 | 
				
			||||||
 | 
					    if as_json:
 | 
				
			||||||
 | 
					        print(json.dumps(data))
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        print(f"{data['state']}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.command()
 | 
					@app.command()
 | 
				
			||||||
def version():
 | 
					def version():
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							@@ -41,13 +41,13 @@ proxy = ["pysocks"]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "typer-slim"
 | 
					name = "typer-slim"
 | 
				
			||||||
version = "0.12.3"
 | 
					version = "0.12.4"
 | 
				
			||||||
description = "Typer, build great CLIs. Easy to code. Based on Python type hints."
 | 
					description = "Typer, build great CLIs. Easy to code. Based on Python type hints."
 | 
				
			||||||
optional = false
 | 
					optional = false
 | 
				
			||||||
python-versions = ">=3.7"
 | 
					python-versions = ">=3.7"
 | 
				
			||||||
files = [
 | 
					files = [
 | 
				
			||||||
    {file = "typer_slim-0.12.3-py3-none-any.whl", hash = "sha256:142c73d91ac1df79a49cec5a1c2210c00b1b4040a91014b539792af5ba81c65c"},
 | 
					    {file = "typer_slim-0.12.4-py3-none-any.whl", hash = "sha256:790a9cd6589494ce063a178473ccdad878fa36bc03f428710f5864670e988144"},
 | 
				
			||||||
    {file = "typer_slim-0.12.3.tar.gz", hash = "sha256:633965eb413074aa6c47549d1820832f229709e9a59857a4f57ee82b655602af"},
 | 
					    {file = "typer_slim-0.12.4.tar.gz", hash = "sha256:4629238b526feb8ea71ad663d058ae8370b1520bb40f48b2f8e0c67a551b399f"},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[package.dependencies]
 | 
					[package.dependencies]
 | 
				
			||||||
@@ -70,5 +70,5 @@ files = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[metadata]
 | 
					[metadata]
 | 
				
			||||||
lock-version = "2.0"
 | 
					lock-version = "2.0"
 | 
				
			||||||
python-versions = "^3.11"
 | 
					python-versions = ">=3.11"
 | 
				
			||||||
content-hash = "e7a8f7b8e008727e2b2d940eb79f1cfe53af0c193bb83edd4a01e60eb44a81ad"
 | 
					content-hash = "15cbc74f82a40827f2d9b5a07001209098c73e8ac1f66e47a01cc2a799730406"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,15 @@
 | 
				
			|||||||
[tool.poetry]
 | 
					[tool.poetry]
 | 
				
			||||||
name = "huecli"
 | 
					name = "huecli"
 | 
				
			||||||
version = "0.1.4"
 | 
					version = "0.1.5"
 | 
				
			||||||
description = "Set Philips Hue lights using MQTT"
 | 
					description = "Set Philips Hue lights using MQTT"
 | 
				
			||||||
authors = ["Torjus Håkestad <torjus@uio.no>"]
 | 
					authors = ["Torjus Håkestad <torjus@uio.no>"]
 | 
				
			||||||
license = "MIT"
 | 
					license = "MIT"
 | 
				
			||||||
readme = "README.md"
 | 
					readme = "README.md"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[tool.poetry.dependencies]
 | 
					[tool.poetry.dependencies]
 | 
				
			||||||
python = "^3.11"
 | 
					python = ">=3.11"
 | 
				
			||||||
paho-mqtt = "^2.1.0"
 | 
					paho-mqtt = ">=2.1.0"
 | 
				
			||||||
typer-slim = "^0.12.3"
 | 
					typer-slim = ">=0.12.3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[tool.poetry.scripts]
 | 
					[tool.poetry.scripts]
 | 
				
			||||||
huecli = "huecli.__main__:main"
 | 
					huecli = "huecli.__main__:main"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user